Chapter 15.
Examining the Symbol Table
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 (refer to Section 4.1.1
Choosing files
), or by one of the file-
management commands (refer to Section 17.1
Commands to specify 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 (refer to Section 10.2
Program 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
Describe where the data for
symbol
is stored. For a register variable, this says which register it
is kept in. For a non-register local variable, this prints the stack-frame offset at which the variable
is always stored.
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.
info symbol
addr
Print the name of a symbol which is stored at the address
addr
. If no symbol is stored exactly at
addr
, gdb prints the nearest symbol and an offset from it:
(gdb) info symbol 0x54320
_initial 396 in section .text
This is the opposite of the
info address
command. You can use it to find out the name of a
variable or a function given its address.
whatis
expr
Print the data type of expression
expr
.
expr
is not actually evaluated, and any side-effecting
operations (such as assignments or function calls) inside it do not take place. Refer to Section
10.1
Expressions
.
whatis
Print the data type of
$
, the last value in the value history.
ptype
typename
Print a description of data type
typename
.
typename
may be the name of a type, or for C code
it may have the form
class
class-name
,
struct
struct-tag
,
union
union-tag
or
enum
enum-tag
.
Summary of Contents for ENTERPRISE LINUX 4 - DEVELOPER TOOLS GUIDE
Page 1: ...Red Hat Enterprise Linux 4 Debugging with gdb ...
Page 12: ...2 Chapter 1 Debugging with gdb ...
Page 28: ...18 Chapter 4 Getting In and Out of gdb ...
Page 34: ...24 Chapter 5 gdb Commands ...
Page 44: ...34 Chapter 6 Running Programs Under gdb ...
Page 68: ...58 Chapter 8 Examining the Stack ...
Page 98: ...88 Chapter 10 Examining Data ...
Page 112: ...102 Chapter 12 Tracepoints ...
Page 118: ...108 Chapter 13 Debugging Programs That Use Overlays ...
Page 138: ...128 Chapter 14 Using gdb with Different Languages ...
Page 144: ...134 Chapter 15 Examining the Symbol Table ...
Page 170: ...160 Chapter 19 Debugging remote programs ...
Page 198: ...188 Chapter 21 Controlling gdb ...
Page 204: ...194 Chapter 22 Canned Sequences of Commands ...
Page 206: ...196 Chapter 23 Command Interpreters ...
Page 216: ...206 Chapter 25 Using gdb under gnu Emacs ...
Page 296: ...286 Chapter 27 gdb Annotations ...
Page 300: ...290 Chapter 28 Reporting Bugs in gdb ...
Page 322: ...312 Chapter 30 Using History Interactively ...
Page 362: ...352 Appendix D gdb Remote Serial Protocol ...
Page 380: ...370 Appendix F GNU GENERAL PUBLIC LICENSE ...
Page 386: ...376 Appendix G GNU Free Documentation License ...
Page 410: ......