Debugging with GDB Manual HP WDB v6.3 (5900-2180, August 2012)
Many options have both long and short forms; both are shown in the following list. GDB also
recognizes the long forms if you truncate them, so long as enough of the option is present to be
unambiguous. (If you prefer, you can flag option arguments with `--' rather than `-', though we
illustrate the more usual convention.)
-symbols file
-s file Read symbol table from file file.
-exec file
-e file Use file file as the executable file to execute when appropriate,
and for examining pure data in conjunction with a core dump.
-se file Read symbol table from file file and use it as the executable file.
-core file
-c file Use file file as a core dump to examine.
-c number Connect to process ID number, as with the attach command
(unless there is a file in core-dump format named number, in which
case `-c' specifies that file as a core dump to read).
-command file
-x file Execute GDB commands from file file. See “Command files”
(page 230).
-directory directory
-d directory Add directory to the path to search for source files.
-m, -mapped Warning: this option depends on operating system facilities that
are not supported on all systems.
If memory-mapped files are available on your system through the
mmap system call, you can use this option to have GDB write the
symbols from your program into a reusable file in the current
directory. If the program you are debugging is called
'/tmp/fred', the mapped symbol file is '/tmp/fred.syms'.
Future GDB debugging sessions notice the presence of this file,
and can quickly map in symbol information from it, rather than
reading the symbol table from the executable program.
The '.syms' file is specific to the host machine where GDB is run.
It holds an exact image of the internal GDB symbol table. It cannot
be shared across multiple host platforms.
-r, -readnow Read each symbol file's entire symbol table immediately, rather
than the default, which is to read it incrementally as it is needed.
This makes startup slower, but makes future operations faster.
You typically combine the -mapped and -readnow options in order to build a '.syms' file that
contains complete symbol information. (See “Commands to specify files” (page 95), for information
on '.syms' files.) A simple GDB invocation to do nothing but build a '.syms' file for future use
is:
gdb -batch -nx -mapped -readnow programname
2.1.2 Choosing modes
You can run GDB in various alternative modes―for example, in batch mode or quiet mode.
-nx, -n Do not execute commands found in any initialization files (normally
called '.gdbinit', or 'gdb.ini' on PCs). Normally, GDB executes
the commands in these files after all the command options and
arguments have been processed. See “Command files” (page 230).
22 Getting In and Out of GDB