User:Gberh/Generating A Useful Backtrace
Generating a useful backtrace
Installing needed debug symbols
debuginfo and debugsource packages for packages in official openSUSE releases and Factory are available from separate repositories which disabled by default. Check whether they are enabled first:
$ zypper lr # | Alias | Name | Enabled | Refresh ---+---------------------------+------------------------------------+---------+-------- 1 | repo-debug | openSUSE-12.2-Debug | No | Yes 2 | repo-debug-update | openSUSE-12.2-Update-Debug | No | Yes 3 | repo-debug-update-non-oss | openSUSE-12.2-Update-Debug-Non-Oss | No | Yes 4 | repo-non-oss | openSUSE-12.2-Non-Oss | Yes | Yes 5 | repo-oss | openSUSE-12.2-Oss | Yes | Yes 6 | repo-source | openSUSE-12.2-Source | No | Yes 7 | repo-update | openSUSE-12.2-Update | Yes | Yes 8 | repo-update-non-oss | openSUSE-12.2-Update-Non-Oss | Yes | Yes
If the debug repos are disabled, enable them as follows:
# zypper mr --enable repo-debug repo-debug-update repo-debug-update-non-oss […]
Next find out which debuginfo packages will be need to be installed by running the program in gdb:
$ gdb --ex run --args /usr/bin/hello
Quit the program and look in the gdb out put for line starting with Missing separate debuginfos, use: zypper install …. Enter quit
on the gdb prompt to quit gdb and copy and paste each of theses suggested commands into a root shell in order to install all needed debuginfo packages.
Generating a backtrace
If the process is not already running, run it in gdb as follows:
$ gdb --ex 'set logging file /tmp/gdb.txt' --ex 'set logging on' --ex run --args /usr/bin/hello …
In order to attach to an already running process, the pid needs to be determined, e.g. by looking through the output of ps -A -o pid -o comm -o args
or using pidof <name of the program>
. Then attach to the running process with the following command:
$ gdb --ex 'set logging file /tmp/gdb.txt' --ex 'set logging on' --ex continue '' <pid of the running process>
Next, make the program crash, return to the gdb prompt and enter the following commands:
(gdb) thread apply all backtrace full […] (gdb) quit
The logged backtrace will be in a file named /tmp/gdb.txt.