简体   繁体   中英

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.

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?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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