Debugging with GDB Manual (5900-1473; WDB 6.2; January 2011)

Table Of Contents
12 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.
12.1 Commands to specify files
You can specify executable and core dump file names as arguments to the GDB start-up
command (see“Getting In and Out of GDB” (page 23)).
Occasionally it is necessary to change to a different file during a GDB session. 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 environment
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 file- name. GDB searches
the environment variable PATH if necessary to
locate your program. Omitting filename means to
discard information on the executable file.
118 GDB Files