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 25)).

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 -mappedand -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

12.1 Commands to specify files 125

Page 125
Image 125
HP gnu source-level debugger 5992-4701 manual GDB Files, Commands to specify files