Article View: comp.unix.programmer
Article #3350Announcing DUEL 1.10 - a <practical> C debugging language
From: Michael Golan
Date: Mon, 15 Mar 1993 16:06
Date: Mon, 15 Mar 1993 16:06
151 lines
8346 bytes
8346 bytes
*REPOST* of a crossposting. I am truely sorry -- someone from europe canceled
the original, I am still waiting to hear from him why, I assume a mistake.
followups to comp.lang.c.
Duel is supposed to change the way you debug C programs. It is a stable, fully
functional, public domain implementation. Can work with any debugger, but
currently only gdb is supported. anon ftp from ftp.cs.princeton.edu:/duel.
If you are programming in C - try it! If you don't try it, I would
appreciate it if you tell me why not (e.g., it looks stupid). Duel attempts
to address some of the problems that caused you to never use debuggers.
Please send all comments, good and bad (be cruel!) to mg@cs.princeton.edu
[no C++ support, but somewhat usable, gcc/gdb-names demangleing works]
-----------------------------------------------------------------------------
DUEL - A high level language for debugging C programs.
-----------------------------------------------------------------------------
Duel is a special purpose language designed for concise state exploration
of debugged C programs under existing debuggers. It lets you to explore
the program's state better than either the debugger's commands, a C
interpreter, or print statements added to your code. The debugger is
extended with the new 'dl' command for Duel expressions, e.g.,
gdb> dl x[0..10].level >? 5
x[3].level = 14
x[8].level = 6
prints the "level" fields of array elements x[0] to x[10] that are greater
than 5. The output includes the values 14 and 6, as well as their
symbolic representation "x[3].level" and "x[8].level". Linked list and
other complex data structures are just as easy. Most of C (e.g. for, if)
is also supported, e.g., int i; for(i=0; i<11; i++) if(x[i].level>5) x[i].
Duel is debugger-independent, but the current distribution interfaces only
with gdb. You will need the source for gdb-4.6, 4.7 or 4.8. All supported
gdb environments should work with Duel. It was tried at least on dec/mips,
sparc, sgi/iris, sony, hp9000, aix/rs6000, and sysV. Duel is public
domain code. Do whatever you like with it - add it to commercial debuggers,
to dbx/sdb or even make it part of the GNU project. No part of this
distribution contains any copyright or derived code, (i.e. no GPL code,
either). No disclaimer - free public domain software don't need one!
Even if you don't normally use debuggers, but you are programming in C, give
Duel a try! The man page & help even include a summary of useful gdb commands.
Duel is available for anonymous ftp from ftp.cs.princeton.edu, in
/duel/duel.tar.Z. A "tar.Z" format means you should use the command
"zcat duel.tar.Z | tar xf -" to unpack the files.
The Usenix Jan/93 paper about Duel is also available as tech report 399,
in /reports/1992/399.ps.Z on ftp.cs.princeton.edu. Duel 1.02 was posted to
alt.sources, and this version, 1.10 will be posted in a few days.
DUEL is "Debugging U (might) Even Like" or "Don't Use this Exotic Language"
you should judge which is better!
Michael Golan
mg@cs.princeton.edu [Send comments. please!]
-----------------------------------------------------------------------------
The tutorial part from the manual page follows:
Duel is based on expressions which return multiple values. The x..y
operator returns the integers from x to y; the x,y operator returns x
and then y, e.g.
gdb> dl (1,9,12..15,22)
prints 1, 9, 12, 13, 14, 15 and 22. Such expressions can be used wher-
ever a single value is used, e.g.
gdb> dl x[0..99]=0 ;
assigns zero to the first 100 elements of array x. The semantics of x[i]
are the same as in C. They are applied for each of the values returned
by 0..99, which can be thought of as an implied external loop. The
trailing semicolon indicates evaluation for side-effects only, with no
output. Duel incorporates C operators, casts C statements as expres-
sions, and supports limited variable declaration:
gdb> dl int i;for(i=0;i<100;i++)
if(x[i]<0) printf("x[%d]=%d\n",i,x[i]);
x[7] = -4
The semicolon prevents Duel output; only output from printf is printed.
Aliases are defined with x:=y and provide an alternative to variable
declaration. We could also return x[i] instead of using printf:
gdb> dl if(x[i:=0..99]<0) x[i]
x[i] = -4
The symbolic output "x[i]" can be fixed by surrounding i with {}, i.e.
gdb> dl if(x[i:=0..99]<0) x[{i}]
x[7] = -4
The {} are like (), but force the symbolic evaluation to use i's value,
instead of "i". You can usually avoid this altogether with direct Duel
operators:
gdb> dl x[..100] <? 0
x[7] = -4
The ..n operator is a shorthand for 0..n-1, i.e. ..100 is the same as
0..99. The x<?y, x==?y, x>=?y, etc., operators compare their left side
operand to their right side operand as in C, but return the left side
value if the comparison result is true. Otherwise, they look for the
next values to compare, without returning anything.
Duel's x.y and x->y allow an expression y, evaluated under x's scope:
gdb> dl emp[..100].(if(code>400) (code,name))
emp[46].code = 682
emp[46].name = "Ela"
The if() expression is evaluated under the scope of each element of
emp[], an array of structures. In C terms, we had to write:
gdb> dl int i; for(i=0; i<100 ; i++)
if(emp[i].code>400) emp[{i}].code,emp[{i}].name
A useful alternative to loops is the x=>y operator. It returns y for
each value of x, setting `_' to reference x's value, e.g.
gdb> ..100 => if(emp[_].code>400) emp[_].code,emp[_].name
Using `_' instead of `i' also avoids the need for {i}. Finally, the
x-->y operator expands lists and other data structures. If head points
to a linked list threaded through the next field, then:
gdb> dl head-->next->data
head->data = 12
head->next->data = 14
head-->next[[2]]->data = 20
head-->next[[3]]->data = 26
produce the data field for each node in the list. x-->y returns x, x->y,
x->y->y, x->y->y->y, ... until a NULL is found. The symbolic output
"x-->y[[n]]" indicates that ->y was applied n times. x[[y]] is also the
selection operator:
gdb> dl head-->next[[50..60]]->data
return the 50th through the 60th elements in the list. The #/x operator
counts the number of values, so
gdb> dl #/( head-->next->data >? 50 )
counts the number of data elements over 50 on the list.
[There is a lot more in the full manual. Cyclic lists, strings, arrays like
argv, etc]
---------------------------------------------------------------------------
Technical Details
Message-ID:
<1993Mar15.160650.4008@Princeton.EDU>Path:
arc1-ca.pugleaf.net!sparky!uunet!enterpoop.mit.edu!ai-lab!prep.ai.mit.edu!gnulistsShow Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: fc89c,2ac2383d967ae8e,start X-Google-Attributes: gidfc89c,public X-Google-Thread: 1014db,2ac2383d967ae8e,start X-Google-Attributes: gid1014db,public X-Google-Thread: 1025b4,2ac2383d967ae8e,start X-Google-Attributes: gid1025b4,public X-Google-Thread: fba7b,2ac2383d967ae8e,start X-Google-Attributes: gidfba7b,public X-Google-Thread: 108717,2ac2383d967ae8e,start X-Google-Attributes: gid108717,public X-Google-Thread: f43e6,2ac2383d967ae8e,start X-Google-Attributes: gidf43e6,public X-Google-Thread: 10121b,2ac2383d967ae8e,start X-Google-Attributes: gid10121b,public X-Google-Thread: 10f9b1,2ac2383d967ae8e,start X-Google-Attributes: gid10f9b1,public X-Google-ArrivalTime: 1993-03-15 13:48:49 PST Newsgroups: comp.unix.programmer,comp.unix.wizards,comp.lang.c,comp.software-eng,comp.programming,comp.os.os2.programmer,gnu.announce,gnu.misc.discuss From: mg@princeton.edu (Michael Golan) Subject: Announcing DUEL 1.10 - a <practical> C debugging language Message-ID: <1993Mar15.160650.4008@Princeton.EDU> Followup-To: comp.lang.c Organization: Department of Computer Science, Princeton University Date: Mon, 15 Mar 1993 16:06:50 GMT Apparently-To: gnu-announce%rutgers.edu@phoenix.Princeton.EDU Distribution: world Approved: info-gnu@prep.ai.mit.edu Path: arc1-ca.pugleaf.net!sparky!uunet!enterpoop.mit.edu!ai-lab!prep.ai.mit.edu!gnulists Lines: 152