The commands described in this chapter allow you to inquire about the symbols (names of variables, functions and types) defined in your program. This information is inherent in the text of your program and does not change as your program executes. GDB finds it in your program's symbol table, in the file indicated when you started GDB (see File Options), or by one of the file-management commands (see Files).
Occasionally, you may need to refer to symbols that contain unusual
characters, which GDB ordinarily treats as word delimiters. The
most frequent case is in referring to static variables in other
source files (see Variables). File names
are recorded in object files as debugging symbols, but GDB would
ordinarily parse a typical file name, like `foo.c
', as the three words
`foo
' `.
' `c
'. To allow GDB to recognize
`foo.c
' as a single symbol, enclose it in single quotes; for example,
p 'foo.c'::x
looks up the value of x
in the scope of the file `foo.c
'.
info address symbol
Note the contrast with `print &symbol
', which does not work
at all for a register variable, and for a stack local variable prints
the exact address of the current instantiation of the variable.
whatis expr
whatis
$
, the last value in the value history.
ptype typename
class class-name
', `struct struct-tag
', `union union-tag
' or `enum enum-tag
'.
ptype expr
ptype
ptype
differs from whatis
by printing a detailed description, instead
of just the name of the type.
For example, for this variable declaration:
struct complex {double real; double imag;} v;
the two commands give this output:
(gdb) whatis v type = struct complex (gdb) ptype v type = struct complex { double real; double imag; }
As with whatis
, using ptype
without an argument refers to
the type of $
, the last value in the value history.
info types regexp
info types
i type value
' gives information on all types in your program whose
names include the string value
, but `i type ^value$
' gives
information only on types whose complete name is value
.
This command differs from ptype
in two ways: first, like
whatis
, it does not print a detailed description; second, it
lists all source files where a type is defined.
info source
info sources
info functions
info functions regexp
info fun step
' finds all functions whose names
include step
; `info fun ^step
' finds those whose names
start with step
.
info variables
info variables regexp
Some systems allow individual object files that make up your program to be replaced without stopping and restarting your program. For example, in VxWorks you can simply recompile a defective object file and keep on running. If you are running on one of these systems, you can allow GDB to reload the symbols for automatically relinked modules:
set symbol-reloading on
set symbol-reloading off
symbol-reloading
off, since otherwise GDB
may discard symbols when linking large programs, that may contain
several modules (from different directories or libraries) with the same
name.
show symbol-reloading
on
or off
setting.
set opaque-type-resolution on
struct
, class
, or
union
---for example, struct MyType *
---that is used in one
source file although the full declaration of struct MyType
is in
another source file. The default is on.
A change in the setting of this subcommand will not take effect until the next time symbols for a file are loaded.
set opaque-type-resolution off
{<no data fields>}
show opaque-type-resolution
maint print symbols filename
maint print psymbols filename
maint print msymbols filename
maint print symbols
', GDB includes all the symbols for which it has already
collected full details: that is, filename reflects symbols for
only those files whose symbols GDB has read. You can use the
command info sources
to find out which files these are. If you
use `maint print psymbols
' instead, the dump shows information about
symbols that GDB only knows partially---that is, symbols defined in
files that GDB has skimmed, but not yet read completely. Finally,
`maint print msymbols
' dumps just the minimal symbol information
required for each object file from which GDB has read some symbols.
See Files, for a discussion of how
GDB reads symbols (in the description of symbol-file
).
Packaging copyright © 1988-2000 OAR Corporation
Context copyright by each document's author. See Free Software Foundation for information.