Debugging Core Files Using HP WDB (5900-1573; WDB 6.2; January 2011)
Example 10 Debugging a Core File Created by a Stripped Binary When the Symbol Table
is Available
Sample Program
The program in this example has the following global structure, global_vars:
struct gvals {
char *program; +0x0
int arg_count; +0x4
char *first_arg; +0x8
char *path; +0xC
int secret; +0x10
};
struct gvals global_vars;
Sample Debugging Session
This sample debugging session illustrates how to debug a core file that is created by the
stripped binary of this program.
$ nm -x example | grep global_var
global_vars |0x40001180|extern|data |$BSS$
$ strip example
$ ./example
Abort(core dump)
$ gdb example core
HP gdb
...
..(no debugging symbols found)...
Core was generated by `example'.
Program terminated with signal 6, Aborted.
(no debugging symbols found)...(no debugging symbols found)...
(no debugging symbols found)...#0 0xc01082b8 in kill () from /usr/lib/libc.2
(gdb) bt
#0 0xc01082b8 in kill () from /usr/lib/libc.2
#1 0xc00a52e8 in raise () from /usr/lib/libc.2
#2 0xc00e5c8c in abort_C () from /usr/lib/libc.2
#3 0xc00e5ce4 in abort () from /usr/lib/libc.2
#4 0x2394 in <unknown_procedure> () from /home/u492893/examples/./example
The addresss obtained from the output from nm command works only for the main module
of the binary. In the case of the shared libraries, the relocation offset (due to the relocation
of the addresses) must be applied to the addresses that displayed as output for the
nmcommand.
The debugger does not provide the function names for stripped binaries, only the program
counter (PC) is displayed.
However, you can use the symbol information from the unstripped program for debugging.
The symbol table is displayed as output from the nm command for the unstripped program.
In this example, the address of the global variable global_vars (0x40001180) is
displayed as output from the nm command, and this address is used for debugging the
core file.
50