How To Get a Meaningful Backtrace
This page will attempt to explain how to get a meaningful debugging backtrace from a reproducible program crash. For this example, we will rebuild & install the "hello" package so that we keep debugging information.
For reference, a "#" at the beginning of a line means that what follows is a command that has to be executed as root. A "$" at the beginning means that what follows is a command that should be executed as your normal user. A "(gdb)" at the beginning means that you should be typing the rest of the command line at the gdb (GNU Debugger) prompt.
Install the basic development packages and the build-dependencies for the package we want to rebuild. Note that you can skip the rebuilding part and go straight to running gdb, but it is unlikely that you will get a useful backtrace.
# apt-get install build-essential fakeroot gdb # apt-get build-dep hello
Download & rebuild our package from source, keeping debugging symbols
$ DEB_BUILD_OPTIONS=nostrip fakeroot apt-get -b source hello
Install our newly built package(s). There may be multiple .deb packages generated, make sure to install the ones you want. In this example, the .deb generated was called hello_2.1.1-4_i386.deb.
# dpkg -i hello_2.1.1-4_i386.deb
Now run your program as follows, replacing "[--args]" with any arguments you want to run the program with:
$ gdb hello ... gdb loads ... (gdb) run [--args] ... hello loads...
Then try to reproduce your crash. If you're lucky, a crash will occur and you'll be dropped back to the gdb prompt. At that point, you can run:
(gdb) bt
You'll then get a lot of output, which you can then copy & paste to a bug followup e-mail or other bug reporting tool. When you're done with gdb, you can just run:
(gdb) quit
If the problem seems to be in a major library such as libc6, xlibs, or libgtk2.0-0, you'll want to install the appropriate -dbg package (e.g. libc6-dbg in the case of libc6), and run your program under gdb like this (note the LD_LIBRARY_PATH):
$ LD_LIBRARY_PATH=/usr/lib/debug