| Red Hat Documentation |
|
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 (see 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.
On systems with memory-mapped files, an auxiliary file, 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 in the following), for more information.
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 use Return again after executing it once. When GDB is configured for a particular environment, it understands debugging information in whatever format is the standard generated for that environment; you may use either a GNU compiler, or other compilers that adhere to the local conventions. Best results are usually obtained from GNU compilers; for example, using gcc you can generate debugging information for optimized code. 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 GDB 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 Optional warnings and messages.) 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.
file filename[-readnow][-mapped]
If memory-mapped files are available on your system through the mmap system call, you can use another option, ‘-mapped’, to cause GDB to write the symbols for your program into a reusable file. Future GDB debugging sessions map in symbol information from this auxiliary symbol file (if the program has not changed), rather than spending time reading the symbol table from the executable program. Using the ‘-mapped’ option has the same effect as starting GDB with the ‘-mapped’ command-line option. You can use both options together, to make sure the auxiliary symbol file has all the symbol information for your program. The auxiliary symbol file for a program called myprog is called ‘myprog.syms’. Once this file exists (so long as it is newer than the corresponding executable), GDB always attempts to use it when you debug myprog; no special options or commands are needed. The ‘.syms’ file is specific to the host machine where you run GDB. It holds an exact image of the internal GDB symbol table. It cannot be shared across multiple host platforms.
core-file with no argument specifies that no core file is to be used.
The core file is ignored when your program is actually running under GDB. So, if you have been running your program and you wish to debug a core file instead, you must kill the subprocess in which the program is running. To do this, use the kill command (see Killing the child process).
If your GDB does not have a load command, attempting to execute it gets the error message, You can’t do that when your target is .... 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. On VxWorks, load links filename dynamically on the current target system as well as adding its symbols in GDB. With the Nindy interface to an Intel 960 board, load downloads filename to the 960 as well as adding its symbols in GDB. When you select remote debugging to a Hitachi SH, H8/300, or H8/500 board (see GDB and Hitachi Microprocessors), the load command downloads your program to the Hitachi board and also opens it as the current executable target for GDB on your host (like the file command). load does not repeat if you use Return again after using it. add-symbol-file filename address[-readnow][-mapped]
The symbol table of the file, filename, is added to the symbol table originally read with the symbol-file command. You can use the command, add-symbol-file, any number of times; the new symbol data thus read keeps adding to the old. To discard all old symbol data instead, use the symbol-file command. add-symbol-file does not repeat if, after using it, you use Return. You can use the ‘-mapped’ and ‘-readnow’ options, just as with the symbol-file command, to change how GDB manages the symbol table information for filename.
info target
All file-specifying commands allow both absolute and relative file names as arguments. GDB always converts the file name to an absolute file name and remembers it that way. GDB supports SunOS, SVr4, Irix 5, and IBM RS/6000 shared libraries. GDB automatically loads symbol definitions from shared libraries when you use the run command, or when you examine a core file. (Before you issue the run command, remember that GDB does not understand references to a function in a shared library, unless you are debugging a core file).
info sharedlibrary
share regex
|
|
© 2001 Red Hat, Inc. All rights reserved. About Red Hat : Legal statement : Privacy statement : Y2K statement : Contact Red Hat |