Debugging with GDB (February 2008)

Table Of Contents
Chapter 12: GDB Files 105
To do this, use the kill command (see Section 4.8 [Killing the child process],
page 28).
add-symbol-file filename address
add-symbol-file filename address [ -readnow ] [ -mapped ]
add-symbol-file filename address data_address bss_address
add-symbol-file filename -ssection address
The add-symbol-file command reads additional symbol table information
from the file filename. You would use this command when filename has been
dynamically loaded (by some other means) into the program that is running.
address should be the memory address at which the file has been loaded; GDB
cannot figure this out for itself. You can specify up to three addresses, in which
case they are taken to be the addresses of the text, data, and bss segments
respectively. For complicated cases, you can specify an arbitrary number of
-ssection address pairs, to give an explicit section name and base address for
that section. You can specify any address as an expression.
The symbol table of the file filename is added to the symbol table originally read
with the symbol-file command. You can use the add-symbol-file command
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 without
any arguments.
add-symbol-file does not repeat if you press
h
RET
i
after using it.
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.
section The section command changes the base address of section SECTION 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, described below, 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 13 [Specifying a Debugging Target], page 109), including the
names of the executable and core dump files currently in use by GDB, 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.
GDB always converts the file name to an absolute file name and remembers it that way.
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, GDB
does not understand references to a function in a shared library, however—unless you are
debugging a core file).
On HP-UX, if the program loads a library explicitly, GDB automatically loads the
symbols at the time of the shl_load call. See Section 5.1 [Stopping and starting in shared
libraries], page 33, for more information.