1、GDB会每个线程分配一个ID,前面有*的表示当前正在调试的线程。
(gdb) info threads Id Target Id Frame * 2 Thread 0x7ffff77ff700 (LWP 2481) "thread" thread_func (args=0x0) at thread.c:11 1 Thread 0x7ffff7fe7700 (LWP 2478) "thread" main () at thread.c:24
2、切换到指定ID的线程。
(gdb)thread 2
3、使用set scheduler-locking命令可以控制线程的执行,on时锁定当前线程,而不执行其它线程。
(gdb)set scheduler-locking off|on