Skip to content

Instantly share code, notes, and snippets.

@mpontillo
Created July 17, 2014 02:21
Show Gist options
  • Save mpontillo/bd30e0ec345be1122a77 to your computer and use it in GitHub Desktop.
Save mpontillo/bd30e0ec345be1122a77 to your computer and use it in GitHub Desktop.
# modified backtrace function (uses core file) courtesy of:
# http://blog.cryptomilk.org/2010/12/23/gdb-backtrace-to-file/
bt()
{
echo 0 | \
gdb -batch-silent \
-ex "core-file core" \
-ex "set logging overwrite on" \
-ex "set logging file gdb.bt" \
-ex "set logging on" \
-ex "set pagination off" \
-ex "handle SIG33 pass nostop noprint" \
-ex "echo backtrace:\n" \
-ex "backtrace full" \
-ex "echo \n\nregisters:\n" \
-ex "info registers" \
-ex "echo \n\ncurrent instructions:\n" \
-ex "x/16i \$pc" \
-ex "echo \n\nthreads backtrace:\n" \
-ex "thread apply all backtrace" \
-ex "set logging off" \
-ex "quit" "$@"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment