Bug 1121

Summary: Debug: parsing incompatibilities
Product: Debug Reporter: dolmen_hotmail.com@freedos.org <dolmen_hotmail.com@freedos.org>
Component: coreAssignee: debug@freedos.org <debug@freedos.org>
Status: RESOLVED FIXED    
Severity: normal    
Priority: P2    
Version: unspecified   
Hardware: PC   
OS: FreeDOS   

Description:   Opened: 2002-05-04 21:58
I've found three incompatibilities in 'debug' with Microsoft debug.
FreeDOS debug is more restrictive than Microsoft one:
- comma (,) is not accepted as a separator for values in commands 'e'
(edit), 'f' (fill), 'h' (hex) and 's'. I haven't tested other commands
as they don't accept "list" parameters.
- in assemble mode the DB directive requires a comma between two elements.
- the prompt is '=' instead of '-'. This is a problem for programs
that parse 'debug' output
Here is a test script:
h1,4
f100lf 0
f100lf 0,1
d100lf
e100 "abc",45,"def"
d100l7
a107
DB 1"abc"2"def"
d107l8
f100lB 0 0 0 0 0 "Dolmen"
d100lB
s100lf 44,6F
q
Olivier Mengu
------- Comment #1 From dolmen_hotmail.com@freedos.org 2002-05-04 22:03:33 -------
Subject: Full test case

h1,4
f100lf 0
f100lf 0,1
d100lf
e100 "abc",45,"def"
d100l7
a107
DB 1"abc"2"def"
d107l8
f100lB 0 0 0 0 0 "Dolmen"
d100lB
s100lf 44,6F
q
------- Comment #2 From eric_coli.uni-sb.de.nospamplease@freedos.org 2002-11-13 04:41:55 -------
Subject: Bug analysis of FreeDOS debug not accepting "," as argument separator

Hi, actually, debug is mostly a single 6000 line .a86 assembly
language
program. Not nicely modularized, maybe a86 cannot handle include
directives. And I do not have a86, so I cannot recompile (reassemble)
debug.
Actually, all commands with 2 or more arguments are affected, those
are
C, H, M, S, E, F, G, P, R (no issue, as for MS debug, R requires a
newline
to be between both arguments), T, O, L, W and possibly N and L as
well.
Example:
;       O command - output to I/O port.
oo:     call    getword <- reads a 16bit hex number to dx
        push    dx
        call    skipwh0 <- skips over " " and tab
        call    getbyte <- reads an 8bit hex number to dl
        call    chkeol  <- makes sure that only " " and tab may follow
and then CR
        xchg    ax,dx
        pop     dx
        out     dx,al
        ret
The "skipwh0" function only accepts " " and TAB as whitespace.
However,
you can use the "ifsep" function instead, which accepts " " and TAB
and ","
and ";" and "=" ... the problem is that "skipwh0" will skip over
multiple spaces
(if whitespace, lodsb next char and skipwh0 again), while ifsep only
allows
a single space. What you can do, however:
;       O command - output to I/O port.
oo:     call    getword  ; <- reads a 16bit hex number to dx
        push    dx
        call    skipwh0 ; <- skips over " " and tab
	call ifsep ; <- at this point we know that it is no " " or tab
already!
	jnz oo1
	lodsb	; <- skip over separator non-whitespace separator
		; and load following character
	call skipwh0 ; <- skip over additional whitespace if needed
oo1:
        call    getbyte ; <- reads an 8bit hex number to dl
        call    chkeol  ; <- makes sure that only " " and tab may
follow and then CR
        xchg    ax,dx
        pop     dx
        out     dx,al
        ret
Or you could even write a generic "skipsep":
skipsep:	call skipwh0
	call ifsep
	jnz skipsep0
	lodsb
	call skipwh0
skipsep0:	ret
You could then replace all appropriate occurances of "call skipwh0"
by "call skipsep".
Basically ALL FreeDOS debug commands use skipwh0 or skipwhite
and NOT something like "skipsep". Please check whether ALL MS debug
commands accept "," as argument separator, and if yes, if whitespace
before
and/or after "," is allowed then. I think it is acceptable to replace
basically
ALL calls to skipwh0 by calls to skipsep.
Question to the FreeDOS debug maintainer: Is this change okay for you?
Eric ( eric at coli.uni-sb.de.nospamplease )
------- Comment #3 From dolmen_hotmail.com.nospamplease@freedos.org 2002-11-18 11:13:26 -------
Subject: Other testcases

Here are more Microsoft Debug test cases.
Microsoft Debug accepts the following:
e100
e,100
e,,100
e100 1 2 3
e100 1,2,3
e100 1,2,3,
e100,1,2,3
e100,1,2,3,
e100 , 1 , 2 , 3 ,
e,100,1,2,3,
e, , 100
a120
a,,,120
d100
d,100
d,,100
d,,,100
d, , 100
d100-140
d,100-140
d,100
d100l20
d100,l20
d100l,20
d,100,l,20
r,AX
-------------------------
Microsoft Debug doesn't accepts:
e,,,100
e, , ,100
e100 1 ,, 2
d,,,,100
d100,-,140
d100,-140
--------------------------
Here is a test case of quotes parsing in different contexts (Microsoft
Debug):
Input script:
f 100l20 00
e 100 "abc""def"
a 110
DB "abc""def"
d 100l20
q
Output:
-f 100l20 00
-e 100 "abc""def"
-a 110
0C5E:0110 DB "abc""def"
0C5E:0116
-d 100l20
0C5E:0100  61 62 63 22 64 65 66 00-00 00 00 00 00 00 00 00
abc"def.........
0C5E:0110  61 62 63 64 65 66 00 00-00 00 00 00 00 00 00 00
abcdef..........
-q
Olivier Mengu
------- Comment #4 From vojta_math.berkeley.edu@freedos.org 2002-11-23 01:57:09 -------
Subject: what I'm likely to do

In light of the above test cases (e.g., MS debug accepts d,,,100 but
not e,,,100), I think it would be pretty much impossible to get 100%
compatibility.  So I won't try to do that.
The proposed change to the "o" command (calling ifsep, etc.) is not a
problem for that command, but wouldn't work for the g command, since
'=' is not treated as a separator there.  Generally ifsep is only for
telling when a file name ends.
I am willing to make it so that command arguments can be separated by:
    o   One or more whitespace characters, or
    o   One comma, preceded and followed by zero or more whitespace
        characters.
and likewise for the DB directive in the assembler.
However, right now I'm in the middle of a different large change to
DEBUG, and I'd like to take care of that first.  So things might take
a while.
--Paul Vojta, vojta@math.berkeley.edu
------- Comment #5 From Paul Vojta 2003-09-11 01:04:26 -------
Fixed in version 0.95f:

      http://math.berkeley.edu/~vojta/debug95f.zip