Debugging Core Files Using HP WDB

Forcing a Core Dump
WDB enables you to force a core dump of a running process, and analyze the core file.
The dumpcore command forces a core dump and generates a core image file for a process that
is running under the debugger. If no arguments are given, it saves the core image for the current
debugged process in a file named core.<pid>, where <pid> is the process ID number.
Before debugging a forced core dump, you must enter the set live-core 1 command at the
gdb prompt. The set live-core command enables the debugging of a core file created by a
forced core dump. Alternately, you can use the --lcore start-up option to debug a core file
created by a forced core dump.
Saving the Core File to a Specific File Name
You can specify a <corefile-name> as an option in the dumpcore command. This saves the
dumped core file in the specified file, <corefile-name>, instead of core.<pid>.
To specify the filename as an option in the dumpcore command, enter the following command
at the gdb prompt:
(gdb) dumpcore <corefile-name>
Debugging a Core File Created by a Forced Core Dump
To debug a core file that is created by a forced core dump, complete the following steps:
1. To dump the core for a live process, enter the following command at the gdb prompt:
(gdb) dumpcore
For example:
(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)
2. To analyze the dumped core file, enter one of the following commands:
At gdb prompt:
(gdb) core [core.<pid>|<corefile-name>]
For example:
(gdb) file sample
Reading symbols from sample...done
(gdb) set live-core 1
(gdb) core 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)
(Or)
At shell prompt:
% gdb --lcore a.out [core.<pid>|<corefile-name>]
For example:
% ./gdb --lcore sample core.24091
HP gdb for PA-RISC (narrow), HP-UX 11.23. Copyright 1986 -
2001 Free Software Foundation, Inc. Hewlett-Packard Wildebeest
(based on GDB) is covered by the GNU General Public License.
Type "show copying" to see the conditions to change it and/or
distribute copies.
26