[Bug 23574] New: lldb is unable to pass SIGSTOP to the inferior correctly

Bug ID 23574
Summary lldb is unable to pass SIGSTOP to the inferior correctly
Product lldb
Version unspecified
Hardware PC
OS Linux
Status NEW
Severity normal
Priority P
Component All Bugs
Assignee lldb-dev@cs.uiuc.edu
Reporter labath@google.com
Classification Unclassified

Outside debugger SIGSTOP, SIGSTP, SIGTTIN or SIGTTOU suspend the process until
it receives a SIGCONT. Simulating this behaviour in the debugger is tricky.
>From ptrace manpage:
As  of Linux 2.6.38, after the tracer sees the tracee ptrace-stop and until it
restarts or kills it, the tracee will not run, and will not send notifications 
(except  SIGKILL death) to the tracer, even if the tracer enters into another
waitpid(2) call.

The kernel behavior described in the previous paragraph causes a problem with
transparent handling of stopping signals.  If the tracer restarts the tracee
after  group-stop, the  stopping signal is effectively ignored—the tracee
doesn't remain stopped, it runs.  If the tracer doesn't restart the tracee
before  entering  into  the  next  waitpid(2), future SIGCONT signals will not
be reported to the tracer; this would cause the SIGCONT signals to have no
effect on the tracee.

The manpage suggests this can be implemented by restarting the process with
PTRACE_LISTEN. However, this requires attaching with PTRACE_SIEZE, which is
pretty big change for such a minute feature.