Chapter 18. The Debugger Files

Table of Contents
18.1. Commands to Specify Files
18.2. Errors Reading Symbol Files

The debugger 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.

18.1. Commands to Specify Files

The usual way to specify an executable file name is with the command argument given when you start the debugger, (see Chapter 8.).

Occasionally it is necessary to change to a different file during the debugger session. Or you may run the debugger and forget to specify a file you want to use. In these situations the debugger 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 debugger working directory, the debugger 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 the debugger and your program, using the path command.

On systems with memory-mapped files, an auxiliary file filename.syms may hold symbol table information for filename. If so, the debugger 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 the debugger 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. The debugger 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 the debugger information on your program's symbol table.

The symbol-file command causes the debugger 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 the debugger.

symbol-file does not repeat if you press Enter again after executing it once.

On some kinds of object files, the symbol-file command does not normally read the symbol table in full right away. Instead, it scans the symbol table quickly to find which source files and which symbols are present. The details are read later, one source file at a time, as they are needed.

The purpose of this two-stage reading strategy is to make the debugger start up faster. For the most part, it is invisible except for occasional pauses while the symbol table details for a particular source file are being read. (The set verbose command can turn these pauses into messages if desired. See Section 20.6.)

We have not implemented the two-stage strategy for COFF yet. When the symbol table is stored in COFF format, symbol-file reads the symbol table data in full right away.

symbol-file filename [ -readnow ] [ -mapped ], file filename [ -readnow ] [ -mapped ]

You can override the debugger two-stage strategy for reading symbol tables by using the -readnow option with any of the commands that load symbol table information, if you want to be sure the debugger has the entire symbol table available.

load filename

The file is loaded at whatever address is specified in the executable. For some object file formats, you can specify the load address when you link the program; for other formats, like a.out, the object file format specifies a fixed address.

If you are using the simulator, then the program will be automatically loaded into the simualtor when you enter the run command. If you have selected the remote target, then you may use the load command to download the program. Note that the debugger may be used with a program that is already loaded.

load does not repeat if you press Enter again after using it.

section sect addr

The section command changes the base address of section sect of the exec file to addr. This can be used if the exec file does not contain section addresses, (such as in the a.out format), or when the addresses specified in the file itself are wrong. Each section must be changed separately. The info files command lists all the sections and their addresses.

info files, info target

info files and info target are synonymous; both print the current target (see Chapter 19.), including the name of the executable file currently in use by the debugger, and the files from which symbols were loaded. The command help target lists all possible targets rather than current ones.

All file-specifying commands allow both absolute and relative file names as arguments. The debugger always converts the file name to an absolute file name and remembers it that way.