是否有一个命令去到gdb的前一个线程而不记住线程号?



gdb在适当的断点触发时切换线程。
我需要记住线程号来返回thread n
是否有一个特殊的命令返回到执行分步执行的线程?

(gdb) n
57          m_app = create_app();
(gdb) n
[Switching to Thread 0x7fffdfffd700 (LWP 32059)]
Thread 9 "foo" hit Breakpoint 1, 0x0000000000421ef0 in App::App()@plt ()
(gdb) # command to return to the interrupted thread

您可以设置自定义GDB提示符,以显示当前线程数与set extended-prompt:

(gdb) set extended-prompt <t> 

每次使用任何GDB命令时,当前线程号将在GDB提示符中打印出来,例如:

<1> thread 
[Current thread is 1 (Thread 0x7ffff7dcd740 (LWP 148411))]
<1> info threads 
Id   Target Id                                  Frame 
* 1    Thread 0x7ffff7dcd740 (LWP 148411) "a.out" main () at /home/ks/t.c:7
<1> 

使用GDB提示符中的信息,您可以使用以下命令返回中断线程:

thread <id_taken_from_prompt_before_interrupt>

最新更新