Reputation: 2788
I set a breakpoint in a multi-threaded inferior. Any of the threads could hit the breakpoint. When the breakpoint is hit, I would like to have gdb switch to the thread that hit it.
Currently, I'm notified that bp is hit. Then I have to look at the top stack frame of every thread to know which one it was, like so:
(gdb) info threads
(gdb) thread apply all bt 1 full
(gdb) thread 2
I'd like this switching to be automatic.
Upvotes: 0
Views: 2131
Reputation: 35708
I'd like this switching to be automatic.
GDB should already do this automatically, see documentation:
Whenever GDB stops your program, due to a breakpoint or a signal, it automatically selects the thread where that breakpoint or signal happened. GDB alerts you to the context switch with a message such as ‘[Switching to Thread n]’ to identify the thread.
Apart from notifying that the breakpoint was hit you should also be notified about switching to another thread.
Upvotes: 3