Skip to content

Instantly share code, notes, and snippets.

@gz
Last active May 17, 2020 00:06
Show Gist options
  • Save gz/a05757ee4fc93a2b4ba8bb43bb395aac to your computer and use it in GitHub Desktop.
Save gz/a05757ee4fc93a2b4ba8bb43bb395aac to your computer and use it in GitHub Desktop.
GDB debug and performance cheat-sheet

GDB

Attach to PID

rust-gdb binary pid

Take a core-dump of a running process

gcore pid

Change frame in backtrace

  • bt: prints all frames
  • frame <num>: switches to frame
  • info locals: prints variables in frame

Remove a breakpoint

  • info break: list breakpoints
  • del 3: delete breakpoint 3 or:
  • clear filename:linenum

Get backtrace of all threads

Inside GDB: thread apply all bt

Given a core-dump save the backtraces to a file: gdb binary coredump -ex "thread apply all bt" -ex "quit" > backtrace.log

Alternative with logging to file inside gdb:

(gdb) set logging on
(gdb) thread apply all bt
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment