Debugging Core Files Using HP WDB
Example 8 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.
(gdb) set $glob=0x40001180
(gdb) x/s *($glob+0x0)
0x7f7e6000: "./example"
(gdb) x/x $glob+0x4
0x40001184: 0x00000001
(gdb) x/s *($glob+0x8)
0x0: Error accessing memory address 0x0: Invalid argument.
(gdb) x/s *($glob+0xc)
0x7f7e62f9: "/opt/softbench/bin:/usr/bin:/opt/butthead/bin:/opt/an
sic/bin:/usr/ccs/bin:/usr/contrib/bin:/opt/nettladm/bin:/opt/fc/bi
n:/opt/fcms/bin:/opt/upgrade/bin:/opt/pd/bin:/usr/bin/X11:/usr/con
trib/bin/X11:/o"...
(gdb) x/d $glob+0x10
0x40001190: 112233
40