Chapter 17.
gdb Files
gdb needs to know the file name of the program to be debugged, both in order to read its symbol table
and in order to start your program. To debug a core dump of a previous run, you must also tell gdb the
name of the core dump file.
17.1. Commands to specify files
You may want to specify executable and core dump file names. The usual way to do this is at start-up
time, using the arguments to gdb’s start-up commands (refer to Chapter 4
Getting In and Out of gdb
).
Occasionally it is necessary to change to a different file during a gdb session. Or you may run gdb and
forget to specify a file you want to use. In these situations the gdb commands to specify new files are
useful.
file
filename
Use
filename
as the program to be debugged. It is read for its symbols and for the contents of
pure memory. It is also the program executed when you use the
run
command. If you do not
specify a directory and the file is not found in the gdb working directory, gdb uses the environ-
ment variable
PATH
as a list of directories to search, just as the shell does when looking for a
program to run. You can change the value of this variable, for both gdb and your program, using
the
path
command.
On systems with memory-mapped files, an auxiliary file named
filename
.syms
may
hold symbol table information for
filename
. If so, gdb maps in the symbol table from
filename
.syms
, starting up more quickly. See the descriptions of the file options
-mapped
and
-readnow
(available on the command line, and with the commands
file
,
symbol-file
, or
add-symbol-file
, described below), for more information.
file
file
with no argument makes gdb discard any information it has on both executable file and the
symbol table.
exec-file [
filename
]
Specify that the program to be run (but not the symbol table) is found in
filename
. gdb searches
the environment variable
PATH
if necessary to locate your program. Omitting
filename
means
to discard information on the executable file.
symbol-file [
filename
]
Read symbol table information from file
filename
.
PATH
is searched when necessary. Use the
file
command to get both symbol table and program to run from the same file.
symbol-file
with no argument clears out gdb information on your program’s symbol table.
The
symbol-file
command causes gdb to forget the contents of its convenience variables, the
value history, and all breakpoints and auto-display expressions. This is because they may contain
pointers to the internal data recording symbols and data types, which are part of the old symbol
table data being discarded inside gdb.
symbol-file
does not repeat if you press [RET] again after executing it once.
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: ......