I was just reading this answer on StackOverflow, "How can you debug a process using gdb without pausing it?"
The Linux kernel provides some support for this via
PTRACE_SEIZE
, but gdb doesn't use this yet. There's a bug in bugzilla you can track, "Bug 15250 - usePTRACE_SEIZE
andPTRACE_INTERRUPT
"
I was able to find PTRACE_SEIZE
documented in man ptrace
,
PTRACE_SEIZE
(since Linux 3.4): Attach to the process specified in pid, making it a tracee of the calling process. UnlikePTRACE_ATTACH
,PTRACE_SEIZE
does not stop the process. Group- stops are reported asPTRACE_EVENT_STOP
andWSTOPSIG(status)
returns the stop signal. Automatically attached children stop withPTRACE_EVENT_STOP
andWSTOPSIG(status)
returnsSIGTRAP
instead of havingSIGSTOP
signal delivered to them.execve(2)
does not deliver an extraSIGTRAP
. Only aPTRACE_SEIZE
d process can acceptPTRACE_INTERRUPT
andPTRACE_LISTEN
commands. The "seized" behavior just described is inherited by children that are automatically at‐ tached usingPTRACE_O_TRACEFORK
,PTRACE_O_TRACEVFORK
, andPTRACE_O_TRACECLONE
. addr must be zero. data contains a bit mask of ptrace options to activate immediately. Permission to perform aPTRACE_SEIZE
is governed by a ptrace access modePTRACE_MODE_ATTACH_REALCREDS
check; see below.
That raises the question if PTRACE_SEIZE
isn't supported by gdb, what tooling (if any) does support this functionality on Linux?