[lldb-dev] Resuming traced process on Linux and SIGSTOP

Andrew MacPherson andrew.macp at gmail.com
Sat Mar 22 03:05:57 PDT 2014


I'm attaching a patch here that resolves the issue of a signal being
delivered to the inferior on detach, let me know if I should start a new
thread for this but since it's related to what we were discussing I'm
attaching it here. To reproduce the issue just launch a process, then in a
new terminal:

sudo lldb -p <pid>
c
q

When quitting the inferior receives a SIGSTOP because the process is
already running when the PTRACE_DETACH is sent. I can't find a clear answer
on what's supposed to happen here (PTRACE_DETACH sent to running thread)
but this is the behaviour I'm seeing. The docs do indicate that
PRACE_DETACH is like PTRACE_CONT and should only be sent to a stopped
thread.

I also tried to add a unit test for this and the previous patch, however I
hit http://llvm.org/pr16172. The tests these two patches require are
similar to the one mentioned in that case and I get the same errors in my
sample test as when running that one:

attach -p <pid> (ok)
c (ok)
detach (error: Detach failed: No such process)

And:

attach -p <pid> (ok)
c (ok)
process interrupt (ok)
c (error: Failed to resume process: Resume request failed - process still
running..)


On Fri, Mar 21, 2014 at 8:37 PM, Ed Maste <emaste at freebsd.org> wrote:

> On 21 March 2014 15:14,  <jingham at apple.com> wrote:
> > I'm pretty sure we have some test cases that test attach.  If we don't,
> then it would be great to add one.  If we do, then it would be interesting
> to see why they didn't fail.  For instance, maybe they just didn't bother
> to try "continue" after the attach.  Just adding that would be good too.
>
> We definitely have some, because they used to fail early on in the
> FreeBSD porting effort.  I suspect that your suggestion is correct and
> they just don't do anything but attach and then quit.
>
> On a related note, I'm pretty sure we don't have tests for detach.
> I'll see about extending tests to include that at some point.
>
> -Ed
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/lldb-dev/attachments/20140322/e8a1e85e/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Linux.detach.patch
Type: text/x-diff
Size: 561 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-dev/attachments/20140322/e8a1e85e/attachment.patch>


More information about the lldb-dev mailing list