Backtrace
1862
Comment:
|
2018
Cleanup attaching to a process
|
Deletions are marked like this. | Additions are marked like this. |
Line 10: | Line 10: |
apt-get install gdb | sudo apt-get install gdb |
Line 25: | Line 25: |
= backtrace of an already running program = | = Already running programs = |
Line 27: | Line 27: |
This applies to debugging i.e. panel applets. | 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. |
Line 33: | Line 33: |
1. Find the PID (process ID) of <program>: {{{ ps ax | grep <program> |
1. Find the process ID of <program>: {{{ pidof <program> |
Line 39: | Line 39: |
(gdb) handle SIG33 pass nostop noprint (gdb) set pagination 0 |
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.
Generation
Please ensure you have packages with debug symbols installed. You can do this by following the instructions at DebuggingProgramCrash.
Make sure the GNU Debugger is installed.
sudo apt-get install gdb
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>
- The program will start. Perform any actions necessary to reproduce the crash
Retrieve a backtrace of the crash:
(gdb) backtrace (gdb) thread apply all backtrace
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.
Make sure the GNU Debugger is installed.
sudo apt-get install gdb
Find the process ID of <program>:
pidof <program>
Start gdb:
gdb | tee gdb-<program>.txt (gdb) handle SIG33 pass nostop noprint (gdb) set pagination 0 (gdb) attach <PID>
Continue the <program>:
(gdb) continue
- The program will continue running. Perform any actions necessary to reproduce the crash
Retrieve a backtrace of the crash:
(gdb) backtrace (gdb) thread apply all backtrace
Attach the complete output from GDB, contained in gdb-<program>.txt, in your bug report.
Backtrace (last edited 2022-12-20 22:15:16 by sergiodj)