Gdb

From ConShell
Jump to navigation Jump to search

GNU Project Debugger

GDB, the GNU Project debugger, allows you to see what is going on `inside' another program while it executes -- or what another program was doing at the moment it crashed. Visit the homepage.

How do I generate a backtrace using the GNU debugger (gdb)?

This example shows how to do that against a core file from a crash of php. This might tell us which module is crashing php. Thanks to Jeremy Chadwick for the example.

$ gdb /usr/local/bin/php /path/to/php.core
...
(gdb) bt

Here is another example, performing a backtrace against a core file generated from a failed vm boot under vmware-server.

gdb /usr/lib/vmware/bin/vmware-vmx core.31458
...
Core was generated by `/usr/lib/vmware/bin/vmware-vmx -C /var/vm/lu13a/LU100/LU100.vmx -@ ""'.
Program terminated with signal 6, Aborted.
Reading symbols from /lib/tls/libm.so.6...(no debugging symbols found)...done.
...
Reading symbols from /usr/lib/vmware/lib/libssl.so.0.9.7/libssl.so.0.9.7...(no debugging symbols found)...done.
Loaded symbols for /usr/lib/vmware/lib/libssl.so.0.9.7/libssl.so.0.9.7
#0  0x001487a2 in _dl_sysinfo_int80 () from /lib/ld-linux.so.2

(gdb) bt
#0  0x001487a2 in _dl_sysinfo_int80 () from /lib/ld-linux.so.2
#1  0x00188c46 in kill () from /lib/tls/libc.so.6
#2  0x080f3969 in ?? ()
#3  0x00007ae2 in ?? ()
#4  0x00000006 in ?? ()
#5  0xbfffc0c0 in ?? ()
#6  0xbfffc070 in ?? ()
#7  0x001dded2 in __tz_convert () from /lib/tls/libc.so.6
#8  0x080f4148 in ?? ()
#9  0x00000006 in ?? ()
#10 0x0832f71f in _IO_stdin_used ()
#11 0xffffffff in ?? ()
#12 0x00000000 in ?? ()

Alternative, if debugging was turned on, use this form instead.

gdb /usr/lib/vmware/bin-debug/vmware-vmx core.31502

Another option which will yield more information...(credit: Brian Rectanus)

(gdb) thread apply all bt full

See Also