现在我知道gdb使我们能够在执行的线程之间切换。
但是,为了更方便,我想知道是否可以在应用程序中打开与线程一样多的终端仿真器,并在每个仿真器中都有一个gdb实例,每个绑定到一个特定的线程?
答案 0 :(得分:0)
并在每个仿真器中都有一个gdb实例,每个仿真器绑定到一个 特别的线程
您无法将多个gdb实例附加到同一进程。这是gdb使用的ptrace
系统调用的限制。来自man ptrace:
EPERM The specified process cannot be traced. This could be because
the tracer has insufficient privileges (the required
capability is CAP_SYS_PTRACE); unprivileged processes cannot
trace processes that they cannot send signals to or those
running set-user-ID/set-group-ID programs, for obvious
reasons. Alternatively, the process may already be being
traced, or (on kernels before 2.6.26) be init(1) (PID 1).