Linux下GDB调试多线程

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

猜你喜欢

转载自blog.csdn.net/i792439187/article/details/61913077