How to switch between threads in GDB
The GNU debugger (GDB) provides greater flexibility in debugging multi-threaded applications. Following are some of the facilities that can be used.
List information about all threads
(gdb) info threads
Set break point specific to a thread.
You can mention thread ID after the break point.
(gdb) break Myfunction thread 1
Switch GDB control to a given thread
Following command swicthes GDB control to thread ID 3. The thread ID is derived from the output of “info threads” command.
(gdb) thread 3
Listing Backtrace of all threads at once
(gdb) thread apply all bt

