Skip to content

Instantly share code, notes, and snippets.

@zz-jason
Created November 23, 2023 05:41
Show Gist options
  • Save zz-jason/59e82f28ca2beefb4f4b5a65a240d9f9 to your computer and use it in GitHub Desktop.
Save zz-jason/59e82f28ca2beefb4f4b5a65a240d9f9 to your computer and use it in GitHub Desktop.
Dump stack trace with pstack or gdb

Dump stack trace for all threads with GDB

For running process:

gdb attach -p ${PID} -ex "thread apply all bt" -ex "detach" -ex "quit" > stacktrace-${PID}.log

For coredump:

gdb ${binary} ${coredump} -ex "thread apply all bt" -ex "detach" -ex "quit" > stacktrace-${binary}.log
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment