When a process is attached by gdb, the stat of the process is “T”, like:
root 6507 0.0 0.0 67896 952 ? Ss 12:01 0:00 /mytest
root 6508 0.0 0.0 156472 7120 ? Sl 12:01 0:00 /mytest
root 26994 0.0 0.0 67896 956 ? Ss 19:59 0:00 /mytest
root 26995 0.0 0.0 156460 7116 ? Tl 19:59 0:00 /mytest
root 27833 0.0 0.0 97972 24564 pts/2 S+ 20:00 0:00 gdb /mytest
From the above, 26995 may be debuging. How can I know 26995 is debug or not? Or can I know which process is attached by gdb(27833)
pstree -p 27833 — show gdb(27833)
Another question: How to know a process(stat: T) is attached by which gdb(PID)?
In most siduation, I am not the peoson who is debuging the process.
The
Tinpsoutput stands for “being ptrace()d”. So that process (26995) is being traced by something. That something is most often eitherGDB, orstrace.So yes, if you know that you are only running
GDBand notstrace, and if you see a single process inTstate, then you know that you are debugging that process.You could also ask
GDBwhich process(es) it is debugging:Update
As Matthew Slattery correctly noted,
Tjust means the process is stopped, and not that it is beingptrace()d.So a better solution is to do this:
From above output you can tell that process 7657 is being traced by process 31069. This answers both “which process is being debugger” and “which debugger is debugging what”.