Debugging with GDB (September 2007)
Chapter 8: Examining Data 69
value each time your program stops. Each expression added to the list is given a numbe r to
identify it; to remove an expression from the list, you spec ify that number. The automatic
display looks like this:
2: foo = 38
3: bar[5] = (struct hack *) 0x3804
This display shows item numbers, expressions and their current values . As with displays
you request manually using x or print, you can sp ec ify the output format you prefer; in
fact, display decides whether to use print or x depending on how elab orate your format
specification is—it uses x if you specify a unit size, or one of the two formats (‘i’ and ‘s’)
that are only supported by x; otherwise it uses print.
display expr
Add the expression expr to the list of expressions to display each time your
program stops. See Section 8.1 [Expressions], page 63.
display does not repeat if you press
h
RET
i
again after using it.
display/fmt expr
For fmt specifying only a display format and not a size or count, add the
expression expr to the auto-display list but arrange to display it each time in
the specified format fmt. See Section 8.4 [Output formats], page 66.
display/fmt addr
For fmt ‘i’ or ‘s’, or including a unit-size or a number of units, add the expres-
sion addr as a memory address to be examined each time your program stops.
Examining means in effect doing ‘x/fmt addr’. See Section 8.5 [Examining
memory], page 67.
For example, ‘display/i $pc’ can be helpful, to view the machine instruction about to
be executed each time execution stops (‘$pc’ is a common name for the program counter;
see Section 8.10 [Registers], page 77).
undisplay dnums ...
delete display dnums...
Remove item numbers dnums from the list of expressions to display.
undisplay does not repeat if you press
h
RET
i
after using it. (Otherwise you
would just get the error ‘No display number ...’.)
disable display dnums...
Disable the display of item numbers dnums. A disabled display item is not
printed automatically, but is not forgotten. It may be enabled again later.
enable display dnums...
Enable display of item numbers dnums. It becomes effective once again in auto
display of its expression, until you spec ify otherwise.
display Display the current values of the expressions on the list, just as is done when
your program stops.
info display
Print the list of expressions previously set up to display automatically, each
one with its item number, but without showing the values. This includes dis-
abled expressions, which are marked as such. It also includes expressions which