Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to pipe gdb's full stack trace to a file?

I'm trying to get a stack trace as my service got into a deadlock. I'm using

gdb <binary> core.dump
gdb> set logging on
gdb> thread apply all bt full
... Here now i have to keep pressing ENTER till i get to end of all the thread trace. It takes around 5 mins for me to get all these traces? 

Any trick to get the stack trace of all the threads to pipe to a file in a single command?

like image 381
user1159517 Avatar asked Nov 07 '14 16:11

user1159517


People also ask

How do I save a GDB output?

Logging GDB's output to a file This is done by first issuing the command set logging file my-gdb-log , followed by the command set logging on . Later on, you can issue the set logging off command to stop sending GDB output to the log file.

How do you analyze a stack trace?

Analyze external stack tracesFrom the main menu, select Code | Analyze Stack Trace or Thread Dump. In the Analyze Stack Trace dialog that opens, paste the external stack trace or thread dump into the Put a stacktrace here: text area. Click OK. The stack trace is displayed in the Run tool window.

What is full stack trace?

A full stack trace allows you to see the chain of files from when your custom tag reached your set breakpoint. If you click on any of the pages in the caller chain then FusionDebug will show you that page and will highlight the line at which the next page in the chain was called.


1 Answers

You should turn off pagination for long outputs like this:

$ gdb <binary> core.dump
(gdb) set logging on
(gdb) set pagination off
(gdb) thread apply all bt full

See gdb FAQ and documentation:

  • https://sourceware.org/gdb/wiki/FAQ#How_do_I_disable_the_.22Type_.3Creturn.3E_to_continue.2C_or_q_.3Creturn.3E_to_quit.22_pagination_prompt_in_GDB.3F
  • https://sourceware.org/gdb/onlinedocs/gdb/Screen-Size.html
like image 147
ks1322 Avatar answered Sep 21 '22 00:09

ks1322