Skip to content

Commit

Permalink
debugx: make it work with 16-bit dpmi clients again
Browse files Browse the repository at this point in the history
  • Loading branch information
Baron-von-Riedesel committed Apr 15, 2024
1 parent ef6ef10 commit 9a7c66c
Show file tree
Hide file tree
Showing 7 changed files with 110 additions and 24 deletions.
16 changes: 10 additions & 6 deletions DEBUG.TXT
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@
the breakpoints may be entered in the usual format ( segment:offset ), they
are stored internally just as linear addresses, and so BP will display this
linear address only.
The type argument is a combined field of bits. Bits 0-1 define the type:
The type argument is a combined field of bits. Bits 0-1 define the type:

0 code breakpoint
1 write watchpoint
Expand All @@ -177,15 +177,17 @@
1 word access
3 dword access

If no type argument is given, a code breakpoint is assumed. Note that I/O
If no type argument is given, a code breakpoint is assumed. Note that I/O
watchpoints may be rejected by the DPMI host; in any case they require
bit DE to be set in register CR4.
To be able to continue the program after a breakpoint has been hit (without
to clear the breakpoint), the debugger will set the Resume flag ( bit 16 in
the EFlags register ). Be aware that not all DPMI hosts will reliably preserve
that flag when an interrupt occurs, thus making it appear as if the program
cannot continue.

Command BC is used to clear a previously set breakpoint.

WinNT platforms and DosEmu don't allow access to the debug registers, hence
BP/BC are inactive there.

Syntax: BP [[address] type]
BC bp#
---]
Expand Down Expand Up @@ -872,7 +874,9 @@
real-mode - it is a bimodal application, in this regard rather unique.
While the debugger is active in protected-mode, it may display faults
that happen when one tries to display memory that is inaccessible;
such faults usually can be safely ignored.
such faults usually can be safely ignored. However, on NT platforms
the debugger isn't notified of page faults - instead, the DOS session
usually just will be terminated.

As it has been mentioned at the Q command: when the debuggee is in
protected-mode, the behavior of DebugX's Q command differs from that
Expand Down
8 changes: 5 additions & 3 deletions HISTORY.TXT
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,9 @@
- DebugX: several bugfixes for A and U handling 32bit code segments.
- bugfix: U split lines if instruction size exceeded 6.
- bugfix: M didn't work with "upper bound" ranges.
- DebugX change: in 32bit code segments, U displayed ECX as first
operand for LOOPx to indicate that ECX is used instead of CX.
Now a 'D' is attached to the opcode (LOOPxD, x=Z|NZ|E|NE) instead.
- DebugX change: the 32-bit variant of the LOOPx instruction was
indicated by displaying ECX as first operand. Now a suffix (W/D)
is attached to the opcode instead.
- bugfix: A didn't choose the short (=signed) form of arith
instructions (adc, add, ...) if E/AX was first operand.
1.10 [25 January 2008]
Expand Down Expand Up @@ -318,6 +318,8 @@
- fix a cmd: regression since v1.18: "call/jmp [mem_ref]" without a size
given did default to a far call/jmp.
- fix u cmd: operand size prefix 66h for 8/16/32-bit relative jmps.
- fix a cmd: NEar qualifier was accepted/ignored for immediate far
jmp/call.
- u cmd, call far [mem]: qualifiers "FAR"/"DWORD FAR" changed to
"FAR16"/"FAR32".
- DebugR(L): Q cmd may be activated for this variant.
Expand Down
18 changes: 18 additions & 0 deletions Test/TEST1.SCR
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@

; test a(ssemble) cmd

a
mov cx,1
movzx cx,cl
movzx ecx,cl
mov cx,[0]
movzx cx,[0]
movzx ecx,[0] ; should be an error
movzx ecx,wo [0]
call far 0:0
call ne 0 ; should be ok
cmp [0],0 ; should be an error
cmp wo [0],0

u 100 l 30
q
8 changes: 4 additions & 4 deletions src/ASMTBL.INC
Original file line number Diff line number Diff line change
Expand Up @@ -83,14 +83,14 @@ oplists label byte
opl 49,OP_DR, OP_32+OP_R_MOD ; idx=73, ofs=D0h
opl 4A,OP_32+OP_R_MOD, OP_TR ; idx=74, ofs=D3h
opl 4B,OP_TR, OP_32+OP_R_MOD ; idx=75, ofs=D6h
if MMXSUPP
ife MMXSUPP
ASMMOD EQU 76
else
opl 4C,OP_MMX, OP_32+OP_RM ; idx=76, ofs=D9h
opl 4D,OP_32+OP_RM, OP_MMX ; idx=77, ofs=DCh
opl 4E,OP_MMX, OP_64+OP_RM ; idx=78, ofs=DFh
opl 4F,OP_64+OP_RM, OP_MMX ; idx=79, ofs=E2h
ASMMOD EQU 50h
else
ASMMOD EQU 4Ch
ASMMOD EQU 80
endif

;--- Assembler: data on groups.
Expand Down
57 changes: 52 additions & 5 deletions src/DEBUG.ASM
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
; - better syntax checks for A (so i.e. "mov ax,al" is rejected)
; - add MMX instructions for A and U
; - support loading *.HEX files
; - hide debug's IVT vectors 0,1,3? Alternately, init them only when the
; - hide debug's IVT vectors 0,1,3 for d(i)? Alternately, init them only when the
; first G/P/T cmd is run, like MS Debug does for 1 & 3?

VERSION textequ <2.03>
Expand Down Expand Up @@ -93,7 +93,8 @@ DGCMD = 0 ; support DG cmd
DICMD = 0 ; support DI cmd
DLCMD = 0 ; support DL cmd
DMCMD = 1 ; support DM cmd
DPCMD = 0 ; support DP cmd
DPCMD = 0 ; support DP cmd (dump partition)
DPCMDR0 = 0 ; support DP cmd (dump paging table, ring0 only)
DTCMD = 0 ; support DT cmd
DXCMD = 0 ; support DX cmd
QCMD = 1 ; support Q cmd
Expand Down Expand Up @@ -207,6 +208,7 @@ CATCHINT0C = 0
endif
CATCHINT0D = 1
CATCHINT41 = 0
DPCMDR0 = 0
LCMD = 0
QCMD = 0 ; may be set to 1
WCMD = 0
Expand Down Expand Up @@ -1049,6 +1051,8 @@ if DMCMD
endif
if DPCMD
db 'dump partitions', TAB, 'DP physical_disk',CR,LF
elseif DPCMDR0
db 'dump page table', TAB, 'DP [linear_address]',CR,LF
endif
if DTCMD
db 'dump TSS', TAB, 'DT',CR,LF
Expand Down Expand Up @@ -1561,6 +1565,7 @@ initdpmi proc
pop edx
.286
adc al,0
jz @F
mov cl, 66h
mov ah, 4
@@:
Expand Down Expand Up @@ -2189,11 +2194,52 @@ cc2:
ret
c_cmd endp

if DPCMD
if DPCMD or DPCMDR0

dp_cmd proc

if DPCMDR0

.386
CONST segment
szCr3 db "CR3=",0
szMappedCr3 db ", mapped at ",0
CONST ends

mov si, offset szCr3
call copystring
mov eax, cr3
call hexdword
mov esi, cr3
and si, 0F000h ;esi=physical address
mov cx, 4 ; cx=size in bytes
mov ax, 2 ; return linear address (in esi) of physical region

;--- callout int 22h requires to set the host ring0 stack!

mov bp, sp
mov dx, ss
lss esp, [r0SSEsp]
int 22h ; win396 debugger interface
mov ss, dx
mov sp, bp

cmp ax, 1
jnz exit
push esi
mov si, offset szCr3
call copystring
pop eax
call hexdword
exit:
call putsline
ret

else

;--- DP disk - display partition table of a fixed disk

dp_cmd proc
call getbyte ;get byte into DL
call chkeol ;expect end of line here
mov bp, sp
Expand Down Expand Up @@ -2242,6 +2288,7 @@ error:
mov sp, bp
call int21ah9
ret
endif
dp_cmd endp
endif

Expand Down Expand Up @@ -3131,7 +3178,7 @@ dcmds label byte
@condcmd DICMD,'i',di_cmd
@condcmd DLCMD,'l',dgl_cmd
@condcmd DMCMD,'m',dm_cmd
@condcmd DPCMD,'p',dp_cmd
@condcmd DPCMD or DPCMDR0,'p',dp_cmd
@condcmd DTCMD,'t',dt_cmd
@condcmd DXCMD,'x',dx_cmd
size_dcmds equ ($ - offset dcmds) / 3
Expand Down
25 changes: 20 additions & 5 deletions src/LINEASM.INC
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@

;--- A command - tiny assembler.

;--- todo:
;--- 1. fix regression since v1.09: cmp [x], yy assumes word operand if no size given
;--- 2. MS debug accepts call near/far [x], Debug rejects near [x], accepts far [x]
;--- 3. MS debug accepts call near/far x (adding current cs as seg if far), Debug rejects both

;--- macros for asmtbl.inc

;--- mne macro, used for the assembler mnemonics table
Expand Down Expand Up @@ -54,6 +59,7 @@ endm
;--- opl macro, used to define operand list types
;--- the macro defines an EQUate, OPLIST_XX, which
;--- is refered to by array opindex.
;--- v2.03: "terminating" 0 no longer required.

opl macro index, value:VARARG
OPLIST_&index equ $ - oplists
Expand Down Expand Up @@ -90,8 +96,9 @@ OP_AX equ 14 ;al or ax or eax
;--- order must match items in asm_jmp1, bittab and dis_optab.
;--- additionally, order of OP_M64 - OP_FARMEM is used
;--- in table asm_siznum
;--- v2.03: value 0 was used to terminate an operand list ( macro opl )
;--- it's free now.

;--- value 0 is used to terminate an operand list ( see macro opl )
OP_M64 equ 2 ; 0 qword memory (obsolete?)
OP_MFLOAT equ 4 ; 1 float memory
OP_MDOUBLE equ 6 ; 2 double-precision floating memory
Expand Down Expand Up @@ -953,6 +960,13 @@ ab14:
jg ab17 ;if we can't have a colon here
cmp al,':'
jne ab17 ;if not xxxx:yyyy
if 1 ;v2.03: size for ssss:oooo must be none or far
cmp [di].OPRND.sizearg, SIZ_NONE
jz @F
cmp [di].OPRND.sizearg, SIZ_FAR
jnz ab24
@@:
endif
call skipwhite
call aageti
mov cx,word ptr [di].OPRND.num+0
Expand Down Expand Up @@ -1317,7 +1331,7 @@ ac06: ;<--- next operand
; shr al,cl ;move bits 0-3 back
db 0d4h,10h ;=aam 10h (AX=00XY -> AX=0X0Y)
mov [ai.reqsize],ah ;save size away
@dprintf "ac08: size requested, AH in AX=%X", ax
@dprintf "ac08: di=%X size requested, AH in AX=%X", di, ax
jmp ac08
@@: ;AL = OP_M64 - ...
add al,ASM_OPOFF - OP_M64 ;adjust for the start entries im asm_jmp1
Expand All @@ -1327,7 +1341,7 @@ ac08:
mov cx,[asm_jmp1+bx] ;subroutine address
shr bx,1
mov al,[bittab+bx]
@dprintf "ac08: si=%X, offset=%X, func=%X, al=%X", si, bx, cx, ax
@dprintf "ac08: di=%X si=%X, offset=%X, func=%X, al=%X", di, si, bx, cx, ax
test al,[di].OPRND.flags
jz ac09 ;if no required bits are present
call cx ;call its specific routine
Expand Down Expand Up @@ -1709,8 +1723,9 @@ aop_ax:

ao07: ;<--- entry for OP_RM, OP_M, OP_R_MOD, OP_R, OP_R_ADD...
or [ai.varflags],VAR_SIZ_NEED
mov al,[ai.reqsize]
sub al,5 ;OP_1632 >> 4
@dprintf "ao07: size check, reqsizeB=%X, sizeargB=%X", word ptr ai.reqsize, word ptr [di].OPRND.sizearg
mov al,[ai.reqsize] ;4 OP_ALL, 5 OP_1632, 6 OP_8, 7 OP_16, 8 OP_32, 9 OP_64
sub al,5
jl ao12 ;if OP_ALL
jz ao13 ;if OP_1632
;--- OP_8=1, OP_16=2, OP_32=3, OP_64=4
Expand Down
2 changes: 1 addition & 1 deletion src/TRAPP.INC
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ if SAFESS
endif
endm

;--- store value of cr2 in exc msg
;--- store value of cr2/cr3 in exc msg
rendercr2:
cld
push es
Expand Down

0 comments on commit 9a7c66c

Please sign in to comment.