简体   繁体   English

GDB:同时调试同一应用程序的两个实例

[英]GDB: Debug two instances of the same application simultaneous

I am trying to debug two instances of the same application.我正在尝试调试同一应用程序的两个实例。 Therefore I setup as followed:因此我设置如下:

(gdb) set target-async on
(gdb) set non-stop on
(gdb) attach pid1
(gdb) set scheduler-locking off
(gdb) add-inferior
(gdb) inferior 2
(gdb) attach pid2
(gdb) set scheduler-locking off
(gdb) b hello-world.cpp:8
Breakpoint 1 at 0x557a557761fd: ../hello-world.cpp:8. (2 locations)
(gdb) continue

The Problem I have is that only the currently selected inferior is continued.我遇到的问题是只有当前选择的劣质继续。 Is there a way to let all inferiors continue with one command?有没有办法让所有低级人员继续执行一个命令?

Solution:解决方案:

It works if the following sequnce is used:如果使用以下序列,它将起作用:

(gdb) attach pid1
(gdb) add-inferior
(gdb) inferior 2
(gdb) attach pid2
(gdb) set schedule-multiple on
(gdb) b hello-world.cpp:8
Breakpoint 1 at 0x557a557761fd: ../hello-world.cpp:8. (2 locations)
(gdb) continue

Thanks to Klaus!感谢克劳斯!

To continue all attached processes you have to set the scheduler mode in gdb.要继续所有附加的进程,您必须在 gdb 中设置调度程序模式。

set scheduler-locking off设置调度程序锁定关闭

A continue now let all threads continue.现在继续让所有线程继续。

For a detailed description of scheduler mode take a look here有关调度程序模式的详细说明,请查看此处

The best way to do that is to use a second terminal.最好的方法是使用第二个终端。 Why do you have this limitation of using only one?为什么你有这个只能使用一个的限制?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM