Help using dbx
guy at sun.UUCP
guy at sun.UUCP
Fri Apr 25 11:55:48 AEST 1986
> By the way, I am running 'dbx' on a Sun workstation.
Which is different from the 4.2BSD "dbx", which is in turn different from
the 4.3BSD "dbx", so note that this discussion applies only to the Sun
version.
> 1. I'd like to be able to specify the format in which a variable is to be
> displayed.
To print the variable "foo" in a particular format, &foo/<format> should
suffice.
> If I have a variable (char *cp), I could do the following with 'sdb': ...
In this case, you don't want to display "cp", you want to display what "cp"
points to. The Sun UNIX 3.2 version (probably the 3.0 version as well) will
print what a "char *" points to, as a string, as well as its value. If you
say "print *cp", it will print the char that "cp" points to.
> 2. The man page for 'dbx' claims that the command to display a memory
> location is: ...
> ... rather than showing me the next location. This makes it quite a chore
> to examine an array. Arrays of structures are even worse.
The fact that the man page says anything indicates you definitely don't have
3.0. I don't know what 3.0 added.
First, why are you using the display command to examine an array? "print
array[N]" seems sufficient to examine the Nth element. If the entire array
is small enough that printing it in its entirety is reasonable, try "print
array".
Second, if you've just displayed a location using "/", you don't want to use
something like a naked "/" to display the same location again. You want to
display the next location, which can be done (at least in 3.0 and later
releases) using "+/".
> 3. With 'sdb', I could display lines of code relative to the current line.
> 'dbx' appears to limit me to specifying absolute line numbers. This
> means that anytime I hit a breakpoint and want to see some context, I
> have to ...
"l" by itself will, after hitting a breakpoint, print the line the
breakpoint occurred on and the next 10 lines. Repeating the "l" will step
through the file. Unfortunately, this doesn't give you a window *around*
the breakpoint. If you have "dbxtool", and are doing your debugging on a
workstation, you can use that.
> 4. A common construct in C is a linked list of structures. ...
> (discussion of stepping through the list)
What's needed here is a notion of variables inside "dbx", so that you can
have an alias which prints whatever <variable> points to and sets <variable>
to <variable>->next. This is a more general solution than what "sdb"
offers; I can imagine data structures which "sdb" would not be able to scan
through conveniently.
Unfortunately, "dbx" doesn't have this notion. The 4.3BSD one might.
Perhaps "dbx" should have more such programming-language characteristics, so
that it could be "programmed" to display more complicated data structures.
I also note from this an other examples that you seem to be using "sdb" and
"dbx" as a symbolic debugger which knows about source lines, but not one
which knows about data structures. "dbx" can be used that way, but it
wasn't really intended to be so used.
--
Guy Harris
{ihnp4, decvax, seismo, decwrl, ...}!sun!guy
guy at sun.arpa
More information about the Comp.unix.wizards
mailing list