每个gdb实例可以有一个线程吗?

时间:2017-06-05 01:58:15

标签: multithreading gdb terminal-emulator

现在我知道gdb使我们能够在执行的线程之间切换。

但是,为了更方便,我想知道是否可以在应用程序中打开与线程一样多的终端仿真器,并在每个仿真器中都有一个gdb实例,每个绑定到一个特定的线程?

1 个答案:

答案 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).