Debugging Core Files Using HP WDB
Example 9 Debugging of a Core File Created by a Stripped Binary When the Symbol Table is
Available from Another Program
In this example, three copies of a program (program a1, program a2, and program a3 ) are
compiled and linked with a different order.
For example:
Program a1 is stripped.
Program a2 is an unstripped copy of program a1.
Program a3 is functionally the same as program a1. However, the code and the symbols are in
a different link order.
Using the symbol information from a3 to debug the core file generated by a1 does not provide
reliable symbol information as illustrated in the following example:
$ aCC main.c a.c b.c -o a1
$ aCC b.c main.c a.c -o a3
$ cp a1 a2
$ strip a1
$ ./a1
Abort(core dump)
$ gdb a1 core
HP gdb
... (Some output dropped)
Core was generated by `a1'.
Program terminated with signal 6, Aborted.
warning: Unable to find __dld_flags symbol in object file.
(no debugging symbols found)...(no debugging symbols found)...
(no debugging symbols found)...#0 0xc01f2740 in kill () from /usr/lib/libc.2
The backtrace of a1 does not display information about the routines, because the program is
stripped.
The symbol information of a2 can be used to analyze the backtrace from a1.
The symbol information from a3 does not provide reliable results, because the link order is
different. Unless the program a3 has a similar link order, the symbol information is not reliable
for debugging the core file created by a1. The version of the compiler and the compiler options
used can also alter the reliability of this approach.
The following example shows the backtrace for a1, a2, and a3.
(gdb) bt
#0 0xc01f2740 in kill () from /usr/lib/libc.2
#1 0xc018fc94 in raise () from /usr/lib/libc.2
#2 0xc01d00dc in abort_C () from /usr/lib/libc.2
#3 0xc01d0134 in abort () from /usr/lib/libc.2
#4 0x2498 in <unknown_procedure> () from /home/shane/test/./a1
#5 0x2430 in <unknown_procedure> () from /home/shane/test/./a1
(gdb) symbol a2
Reading symbols from a2...(no debugging symbols found)...done.
(gdb) bt
#0 0xc01f2740 in kill () from /usr/lib/libc.2
#1 0xc018fc94 in raise () from /usr/lib/libc.2
#2 0xc01d00dc in abort_C () from /usr/lib/libc.2
#3 0xc01d0134 in abort () from /usr/lib/libc.2
#4 0x2498 in b () from /home/shane/test/./a1
#5 0x2430 in main () from /home/shane/test/./a1
(gdb) symbol a3
Reading symbols from a3...(no debugging symbols found)...done.
(gdb) bt
#0 0xc01f2740 in kill () from /usr/lib/libc.2
#1 0xc018fc94 in raise () from /usr/lib/libc.2
#2 0xc01d00dc in abort_C () from /usr/lib/libc.2
#3 0xc01d0134 in abort () from /usr/lib/libc.2
Examples Illustrating Core File Debugging 41