Debugging Core Files Using HP WDB

$ aCC -g example2.c -o example2
$ aCC -g example.c -o example
$ strip example
$ ./example
Abort(coredump)
$ gdb example core
HP gdb
...
Core was generated by `example'.
Program terminated with signal 6, Aborted.
warning: The shared libraries were not privately mapped; setting a
breakpoint in a shared library will not work until you rerun the program.
(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 0x2428 in function_abort () from /home/u492893/example/temp/./example
#5 0x23d8 in function_b () from /home/u492893/example/temp/./example
#6 0x23a8 in function_a () from /home/u492893/example/temp/./example
#7 0x2378 in main () from /home/u492893/example/temp/./example
(gdb) up
#1 0xc00a52e8 in raise () from /usr/lib/libc.2
(gdb)
#2 0xc00e5c8c in abort_C () from /usr/lib/libc.2
(gdb)
#3 0xc00e5ce4 in abort () from /usr/lib/libc.2
(gdb)
#4 0x2428 in function_abort () from /home/u492893/example/temp/./example
(gdb) x/x $sp
0x7f7e67b0:
0x00000001
The stack is traversed such that the stack pointer reflects the address of the required function.
The symbol table from example2 is loaded for debugging the core file generated by example,
as follows:
(gdb) symbol example2
Reading symbols from example2...done.
(gdb) x/x $sp
0x7f7e68f0:
0x7f7d27c0
The stack pointer value in $sp is changed when the new symbol table is loaded. Hence, you
must keep track of the earlier values of $sp manually.
When a new symbol table is loaded, the values stored in the gdb convenience variables are
changed. Hence you cannot store the value of $sp in the gdb convenience variables.
After the new symbol table is loaded, you can use the gdb features which were not previously
available for the stripped executable.
You can use the print command to print the values of the structure struct st_one , as follows:
(gdb) p *(struct st_one *)(*(0x7f7e67b0-100))
$1 = {one = 17, two = 0x40001140 "NOT!", three = 0x7f7e66ac,
four = 0x7f7e6698, five = 0x40001120 "The meaning"}
(gdb) x/x (0x7f7e67b0-100)
0x7f7e674c:
0x7f7e6698
(gdb) x/x (*(0x7f7e67b0-100))
0x7f7e6698:
0x00000011
Examples Illustrating Core File Debugging 45