Backtrace

Differences between revisions 22 and 23
Revision 22 as of 2007-05-24 08:49:39
Size: 2636
Editor: 138
Comment: backtrace full
Revision 23 as of 2007-10-19 19:36:11
Size: 2851
Editor: 563477b3
Comment: added a question and comment
Deletions are marked like this. Additions are marked like this.
Line 68: Line 68:
= Comments =
I can't see any directions here for starting an application which needs root priveleges to run, for example gparted. Perhaps someone who understands this could add those instructions. DuncanLithgow

A backtrace shows a listing of which program functions are still active. Since functions are nested when they are called, the program must record where it left one function, to jump into an inner one. It does this on the stack, which we dump for the backtrace.

By getting a backtrace at the point of a bug, a developer may be able to isolate where that bug is, because it will narrow down to the function, or even the line, that caused the erroneous behaviour.

When using KDE the KDE Crash Handler will intercept debugging information. However, it is possible to disable the KDE Crash Handler when you are launching an application by passing the --nocrashhandler argument to the application. For example, 'kget --nocrashhandler' instead of 'kget'.

Generation

Please ensure you have packages with debug symbols installed. You can do this by following the instructions at DebuggingProgramCrash.

  1. Make sure the GNU Debugger is installed.

    sudo apt-get install gdb
  2. Start the program under control of gdb:

    gdb <program> 2>&1 | tee gdb-<program>.txt
    (gdb) handle SIG33 pass nostop noprint
    (gdb) set pagination 0
    (gdb) run <arguments, if any>
  3. The program will start. Perform any actions necessary to reproduce the crash
  4. Retrieve a backtrace of the crash:

    (gdb) backtrace full
    (gdb) info registers
    (gdb) thread apply all backtrace
    (gdb) quit
  5. Attach the complete output from GDB, contained in gdb-<program>.txt, in your bug report.

Already running programs

You can ask GDB to attach to a program that's already running. This is useful for debugging things that start up, but crash when you perform a particular task.

  1. Make sure the GNU Debugger is installed.

    sudo apt-get install gdb
  2. Find the process ID of <program>:

    pidof <program>
  3. Start gdb:

    gdb 2>&1 | tee gdb-<program>.txt
    (gdb) handle SIG33 pass nostop noprint
    (gdb) set pagination 0
    (gdb) attach <PID>
  4. Continue the <program>:

    (gdb) continue
  5. The program will continue running. Perform any actions necessary to reproduce the crash
  6. Retrieve a backtrace of the crash:

    (gdb) backtrace full
    (gdb) info registers
    (gdb) thread apply all backtrace
    (gdb) quit
  7. Attach the complete output from GDB, contained in gdb-<program>.txt, in your bug report.

Note that you can also set logging to a file like this:

(gdb) set logging file gdb-<program>.txt
(gdb) set logging on

Comments

I can't see any directions here for starting an application which needs root priveleges to run, for example gparted. Perhaps someone who understands this could add those instructions. DuncanLithgow

Other resources


CategoryBugSquad

Backtrace (last edited 2022-12-20 22:15:16 by sergiodj)