I am trying to debug multi-threaded program with one thread that waits input from user. When I put a breakpoint at some function of other thread and run app, it switches into same breakpoint and then immediately at input thread, so app waits input from user and I can't do any command in gdb. I simply need see all stack before invoking same function. I can't make bt command in
2 Answers 2
Does thread apply all bt answer your question?
Comments
You can add commands to a breakpoint, see the manual. Something like this:
(gdb) break some_func
Breakpoint 2 at ...
(gdb) commands 2
Type commands for breakpoint(s) 2, one per line.
End with a line saying just "end".
>thread apply all bt full
>end
(gdb) cont
Continuing.
Breakpoint 2, ...
Thread 1 (Thread 0x....
...
Edit 0:
Oh, I'm guessing you get gdb printing this on you:
---Type <return> to continue, or q <return> to quit---
Just do the following before you do run (you can also stick this into .gdbinit file):
(gdb) set pagination off
4 Comments
cont to the list of commands before end, and it will continue automatically.cont to the list of breakpoint commands. That way you'll get full stack traces of all thread at that breakpoint and continue execution automatically. You can also save gdb output into a file, see the manual.