GDB supports debugging MT apps; almost all the usual commands work normally, just a few commands tend to be thread-specific. Here are the key ones to be aware of:
- See all visible threads:
(gdb) info threads Id Target Id Frame<thr#> Thread <addr> (LWP ...) in <function> [at <srcfile>]
- Switch context to a particular thread by using the thread <thread#> command.
- Apply a given command to all threads of the process: (gdb) thread apply all <cmd>
- Show the stack (GDB's backtrace or bt command) of all threads (the following example output is from our earlier MT app, mt_iobuf_rfct_dbg; first, we show the threads via the thread find . command):
(gdb) thread find .Thread 1 has target name ...