Debugging with GDB (February 2008)

Table Of Contents
166 Debugging with GDB
make a packcore.tar.Z file. This is a compressed tar file which contains the core
file, the executable, and all the shared libraries that were used by the program when it
generated the core file.The core file is removed after it is added to the packcore.tar.Z
file.
The packcore command has one optional argument, basename, which can be used
instead of packcore to make packcore.tar.Z.
The packcore.tar.Z file can be copied to a different system and the gdb command
unpackcore unpacks the packcore.tar.Z file in the current directory, creating a
new packcore directory. After unpacking the packcore file, the unpackcore command
invokes getcore to load the executable and the core file from the packcore directory,
and sets GDB_SHLIB_PATH to the modules directory in the packcore directory. The
modules directory holds all of the shared libraries that were used when the core file
was generated.
The unpackcore command has two optional arguments. The first defaults to
packcore.tar.Z and is the name of the packcore file to be unpacked. The second
argument is given if the core file is too large to fit in the packcore file. It is the
path to the core file to be used if the packcore directory does not contain a core file.
If used,this second argument causes a symbolic link to be created in the packcore
directory in place of the missing core file.
The getcore command can be used to examine a packcore directory which was pre-
viously created by unpackcore. It takes one optional argument, the name of the
packcore directory, which defaults to packcore.
14.14.2 Support for the dumpcore command
HP WDB provides the command, dumpcore to generate a core image file for a process
running under the debugger during execution.
The dumpcore command does not require any argument. It saves the core image for
the current process being debugged in the file named core.<pid>, where <pid> is the
process ID number.
To dump the core for a live process, you must pass the following commands:
(gdb) run Starting program: sample Breakpoint 3, main () at sample.c:1010 b
= foo(a); (gdb) dumpcore Dumping core to the core file core.24091(gdb)
When starting from the HP WDB command line:
(gdb) file sample
Reading
symbols from sample...done
(gdb) set live-core 1
(gdb) core-file core.24091
Core was generated by ’sample’.#0 main () at sample.c:1010 b = foo(a);
(gdb) backtrace#0 main () at sample.c:10
(gdb)
When starting from the shell prompt: