How to create a stack trace with the GNU debugger
The GNU debugger is the debugger usually used for debugging C and C++ programs on linux.
Check if gdb is installed
$ gdb GNU gdb (GDB) 7.1-ubuntu Copyright (C) 2010 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html> This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. Type "show copying" and "show warranty" for details. This GDB was configured as "i486-linux-gnu". For bug reporting instructions, please see: <http://www.gnu.org/software/gdb/bugs/>. (gdb)
If you don't have a similar output, you have to install gdb.
To exit gdb type "quit"
(gdb) quit $
Identify how to run your programm in gdb
If your program requieres no command line arguments you can start gdb in the following way:
$ gdb [path to executable]
If your programm requires command line arguments you can specify them in the gdb console or directly at the command line:
$ gdb --args [path to executable] [arguments]
So you can simply prefix the programm that crashed with a "gdb --args" to run it in gdb.
Run your programm
To run your programm in gdb you have to start it with "run" or "r"
(gdb) r Starting program: ws4d_gsoap/build/bin/iop_device -i 127.0.0.1 iop_device: Set host to "127.0.0.1" iop_device: ready to serve... (Ctrl-C for shut down) iop_device: waiting for request iop_device: waiting for request
Create a stack trace
When your programm crashes, gdb will return to the gdb console (a line starting with "(gdb)" and waiting for input),
To create a stack trace you have to type "backtrace" or "bt" in the gdb console.
(gdb) bt #0 0xb7e782c8 in strcmp () from /lib/libc.so.6 #1 0x08065313 in wait_for_hello (dpws=0x835cfe0, tc=0x835e008, uuid=0x0, tries=55, wait=2) at ws4d-gsoap-0.8.src/src/samples/ms-iop/discovery_client.c:54 #2 0x08062cac in tc_1_1 (argc=0, argv=0x0) at ws4d-gsoap-0.8.src/src/samples/ms-iop/iop_test_driver.c:130 #3 0x08064b8d in next_tc (argc=0, argv=0x0) at ws4d-gsoap-0.8.src/src/samples/ms-iop/iop_test_driver.c:1183 #4 0x08064d7b in process_command (cmdline=0xb7c80fc4 "") at ws4d-gsoap-0.8.src/src/samples/ms-iop/iop_test_driver.c:1243 #5 0x08064e40 in command_loop (ptr=0x0) at ws4d-gsoap-0.8.src/src/samples/ms-iop/iop_test_driver.c:1282 #6 0xb7fb71b5 in start_thread () from /lib/libpthread.so.0 #7 0xb7ed662e in clone () from /lib/libc.so.6 (gdb)