@@ -1144,7 +1144,7 @@ endif
11441144if RING0
11451145segerr db "Debuggee segments invalid" , CR , LF , '$'
11461146endif
1147- cantwritebp db "Can' t write breakpoint" , 0
1147+ cantwritebp db "Can' t write breakpoint ",CR,LF,' $'
11481148
11491149if WCMDFILE
11501150nowhexe db 'EXE and HEX files cannot be written' , CR , LF , '$'
@@ -5410,6 +5410,10 @@ setbp1::
54105410 mov al , 0CCh
54115411 call writemem ; write byte at bx:e/dx
54125412 mov [ si ], ah ; save the current contents
5413+ jc @F
5414+ retn
5415+ @@:
5416+ call bp ; either ignore error (g cmd) or abort with msg (p cmd)
54135417 retn
54145418resetbp1::
54155419 mov al ,[ si ]
@@ -5551,6 +5555,8 @@ g_cmd proc
55515555
55525556;--- Store breakpoint bytes in the given locations.
55535557
5558+ mov bp , offset _ret ; ignore write errors for g
5559+ gg_1:: ; <--- called by p ( run an int/call/... - set 1 bp )
55545560 mov di , offset setbp1
55555561 call setbps
55565562
@@ -5566,7 +5572,7 @@ endif
55665572
55675573if ?PM
55685574 call getcsattr
5569- mov [ bCSAttr ], al ; must be set for getcseipbyte() & IsUnexpInt3()
5575+ mov [ bCSAttr ], al ; must be set for getcseipbyte()
55705576endif
55715577
55725578if 0 ; v2.0: not needed for soft/hard bp detection
@@ -5586,16 +5592,30 @@ else
55865592endif
55875593
55885594;--- Finish up. Check if it was one of _our_ breakpoints.
5589- ;--- if yes, (E)IP isdecremented ( inside IsUnexpInt3() ).
5595+ ;--- if yes, decrement (E)IP
55905596
55915597if 0 ; v2.0: not needed for soft/hard bp detection
55925598 pop ax
55935599 cmp al , 0CCh ; was a CC at CS:[EIP-1]?
55945600 jnz gg_exit
55955601endif
5596- call IsUnexpInt3 ; was bp set by debugger?
5597- jc gg_exit
5602+ cmp [ run_int ], EXC03MSG
5603+ jnz gg_exit
5604+ mov cx , - 1
5605+ call getcseipbyte ; modifies (E)BX
5606+ cmp al , 0CCh ; still a INT3 at [cs:eip-1] ?
5607+ jz gg_exit
5608+ if ?PM
5609+ test [ bCSAttr ], 40h
5610+ jz $ + 3
5611+ db 66h ;mov [regs.rIP],ebx
5612+ endif
5613+ mov [ regs. rIP ], bx ; decrement (E)IP
5614+ if RING0
5615+ mov [ run_int ], - 1 ; v2.0: reset entry ( so SK cmd won't accept soft bps )
5616+ endif
55985617 call dumpregs ; then just display register dump
5618+ _ret:
55995619 ret ; and done ( no "unexpected breakpoint" msg )
56005620gg_exit:
56015621 jmp ue_int ;print messages and quit.
@@ -6910,7 +6930,7 @@ is_rm:
69106930 lea esi , [ esi + ebx ]
69116931 movzx eax , [ scratchsel ]
69126932 add edi , eax
6913- ; @dprintf "IsWriteableBX: esi=%lX, edi=%lX", esi, edi
6933+ @dprintf "IsWriteableBX: esi=%lX, edi=%lX" , esi , edi
69146934 push ds
69156935 mov ds , [ wFl at ]
69166936 lodsd ds : [ esi ]
@@ -7152,48 +7172,14 @@ readmem_1:
71527172 ret
71537173readmem endp
71547174
7155- ;--- check if an unexpected int 3 has occured;
7156- ;--- called by G and P/T ( for "INT xx" )
7157- ;--- rewritten for v2.0.
7158- ;--- when called, resetbps() has happened already!
7159- ;--- checks if [run_int] = EXC03MSG
7160- ;--- checks if [cs:(e)ip-1] still contains a CC; if yes, it's a "hard" bp.
7161- ;--- in:
7162- ;--- out: NC if soft bp set by debugger
7163- ;--- C if hard bp or another exception
7164- ;--- modifies al, (e)bx, cx and - if it WAS a soft bp - [regs.rIP]
7165-
7166- IsUnexpInt3 proc
7167- cmp [ run_int ], EXC03MSG
7168- jnz exit
7169- mov cx , - 1
7170- call getcseipbyte ; modifies (E)BX
7171- cmp al , 0CCh ; still a INT3 at [cs:eip-1] ?
7172- jz exit
7173- if ?PM
7174- test [ bCSAttr ], 40h
7175- jz $ + 3
7176- db 66h ;mov [regs.rIP],ebx
7177- endif
7178- mov [ regs. rIP ], bx ; decrement (E)IP
7179- if RING0
7180- mov [ run_int ], - 1 ; v2.0: reset entry ( so SK cmd won't accept soft bps )
7181- endif
7182- clc
7183- ret
7184- exit:
7185- stc
7186- ret
7187- IsUnexpInt3 endp
7188-
71897175;--- P command - proceed (i.e., skip over call/int/loop/string instruction).
71907176
71917177p_cmd proc
71927178 call parse_pt ;process arguments
71937179
71947180;--- Do it <CX=count> times. First check the type of instruction.
71957181
7196- pp1 :
7182+ instrloop :
71977183 push cx ;save cx
71987184 mov dx , 15 ;DL = number of bytes to go; DH = prefix flags.
71997185if ?PM
@@ -7211,6 +7197,7 @@ pp2:
72117197 mov cx , PPLEN
72127198 repne scasb
72137199 jne pp5 ;if not one of these
7200+
72147201 mov al ,[ di + PPLEN - 1 ] ;get corresponding byte in ppinfo
72157202 test al , PP_PREFIX
72167203 jz @F ;if not a prefix
@@ -7219,6 +7206,7 @@ pp2:
72197206 jnz pp2 ;if not out of bytes
72207207 jmp pp12 ;more than 15 prefixes will cause a GPF
72217208@@:
7209+
72227210 test al , 40h
72237211 jz @F ;if no size dependency
72247212 and al , 3fh
@@ -7273,64 +7261,11 @@ pp9:
72737261 call inceip
72747262pp10:
72757263 call inceip
7276-
72777264pp11:
7278- mov bx ,[ regs.rCS ]
7279- jmp pp11x_1
7265+ call process2
7266+ jmp pp13
72807267pp14:
7281- jmp pp1 ;back for more
7282-
7283- ;--- Special instruction. Set a breakpoint and run until we hit it.
7284- ;--- BX:(E)SI == address where a breakpoint is to be set.
7285-
7286- process1:: ;<--- used by T if an INT is to be processed
7287- @dprintf "process1: bx:esi=%X:%lX" , bx , esi
7288- mov cx , 1
7289- push cx
7290- pp11x_1: ;BX=CS
7291- mov di , offset line_out ;use the same breakpoint structure as in G
7292- sizeprfX ;mov edx,esi
7293- mov dx , si
7294- mov al , 0cch
7295- call writemem
7296- mov al , ah
7297- jnc @F
7298- mov si , offset cantwritebp
7299- call copystring
7300- call putsline
7301- jmp cmdloop
7302- @@:
7303- push ax
7304- mov ax , 1 ;bp cnt
7305- stosw
7306- sizeprfX ;xchg eax,esi
7307- xchg ax , si
7308- sizeprfX ;stosd
7309- stosw
7310- mov ax , bx
7311- stosw
7312- pop ax
7313- stosb
7314- if ?DPMI
7315- push [ regs.msw ]
7316- endif
7317- call run ;this might change mode and/or terminate the debuggee!
7318- if ?PM
7319- call getcsattr ;set variable bCSAttr
7320- mov [ bCSAttr ], al
7321- if ?DPMI
7322- pop dx
7323- call resetbpsEx
7324- else
7325- call resetbps
7326- endif
7327- else
7328- call resetbps
7329- endif
7330-
7331- call IsUnexpInt3 ; stopped at a hard bp?
7332- jnc pp13
7333- jmp pp15
7268+ jmp instrloop ;back for more
73347269
73357270;--- Ordinary instruction. Just do a trace.
73367271
@@ -7339,15 +7274,11 @@ pp12:
73397274 call run
73407275 cmp [ run_int ], EXC01MSG
73417276 jne pp15 ; stop if some other interrupt
7342-
7343- ;--- Common part to finish up.
7344-
7345- pp13:
73467277 call dumpregs
7278+ pp13: ;<--- Common part to finish up.
73477279 pop cx
73487280 loop pp14 ;back for more
73497281 ret
7350-
73517282pp15:
73527283 jmp ue_int ;print message about unexpected interrupt and quit
73537284
@@ -7358,7 +7289,7 @@ if ?PM
73587289 db 66h ;inc esi
73597290endif
73607291 inc si
7361- ret
7292+ retn
73627293
73637294addeip:
73647295if ?PM
@@ -7371,7 +7302,7 @@ if ?PM
73717302@@:
73727303endif
73737304 add si , ax
7374- ret
7305+ retn
73757306
73767307;--- getnextb - Get next byte in instruction stream.
73777308;--- [e]si = eip
@@ -7386,7 +7317,32 @@ if ?PM
73867317endif
73877318 lodsb
73887319 pop ds
7389- ret
7320+ retn
7321+
7322+ process2:
7323+ mov bx , [ regs.rCS ]
7324+
7325+ ;--- Special instruction. Set a breakpoint and run until we hit it.
7326+ ;--- BX:(E)SI == address where a breakpoint is to be set.
7327+
7328+ process1:: ;<--- used by T if an INT is to be processed
7329+ @dprintf "process1: bx:esi=%X:%lX" , bx , esi
7330+ mov di , offset line_out ;use the same breakpoint structure as in G
7331+ mov ax , 1 ;bp cnt
7332+ stosw
7333+ sizeprfX ;xchg eax,esi
7334+ xchg ax , si
7335+ sizeprfX ;stosd
7336+ stosw
7337+ mov ax , bx
7338+ stosw
7339+ mov bp , offset pp_err1 ; abort if bp couldn't be written
7340+ call gg_1 ; use g_cmd to write bp, run program, reset bp
7341+ retn
7342+ pp_err1:
7343+ mov dx , offset cantwritebp
7344+ call int21ah9
7345+ jmp cmdloop
73907346
73917347p_cmd endp
73927348
0 commit comments