Debugging with GDB Manual The GNU Source-Level Debugger (769148-001, March 2014)
show demangle-style Display the encoding style currently in use for decoding
C++ symbols.
set print object, set print
object on
When displaying a pointer to an object, identify the actual
(derived) type of the object rather than the declared type,
using the virtual function table.
set print object off Display only the declared type of objects, without reference
to the virtual function table. This is the default setting.
show print object Show whether actual or declared object types are displayed.
set print static-members,
set print static-members
on
Print static members when displaying a C++ object. The
default is on.
set print static-members
off
Do not print static members when displaying a C++ object.
show print static-members Show whether C++ static members are printed, or not.
set print vtbl, set print
vtbl on
Pretty print C++ virtual function tables. The default is off.
(The vtbl commands do not work on programs compiled
with the HP aC++ compiler (aCC).)
set print vtbl off Do not pretty print C++ virtual function tables.
show print vtbl Show whether C++ virtual function tables are pretty printed,
or not.
Value history
Values printed by the print command are saved in the GDB value history. This allows you to
refer to them in other expressions. Values are kept until the symbol table is re-read or discarded
(for example with the file or symbol-file commands). When the symbol table changes, the
value history is discarded, since the values may contain pointers back to the types defined in the
symbol table.
The values printed are given history numbers by which you can refer to them. These are a range
of integers starting with one. print shows you the history number assigned to a value by printing
'$num = ' before the value; here num is the history number.
To refer to any previous value, use '$' followed by the history number of the value. The way print
labels its output is designed to remind you of this. Just $ refers to the most recent value in the history,
and $$ refers to the value before that. $$n refers to the nth value from the end; $$2 is the value
just prior to $$, $$1 is equivalent to $$, and $$0 is equivalent to $.
For example, suppose you have just printed a pointer to a structure and want to see the contents
of the structure. It suffices to type
p *$
If you have a chain of structures where the component next points to the next one, you can print
the contents of the next one with this:
p *$.next
You can print successive links in the chain by repeating this command using the RET key.
Note that the history records values, not expressions. If the value of x is 4 and you type these
commands:
print x
set x=5
then the value recorded in the value history by the print command remains 4 even though the
value of x has changed.
Value history 67