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 <[email protected]> wrote:

> On 21 March 2014 15:14,  <[email protected]> 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
>
diff --git a/source/Plugins/Process/Linux/ProcessLinux.h b/source/Plugins/Process/Linux/ProcessLinux.h
index 8ccd125..9f39ccc 100644
--- a/source/Plugins/Process/Linux/ProcessLinux.h
+++ b/source/Plugins/Process/Linux/ProcessLinux.h
@@ -58,6 +58,9 @@ public:
     DoDetach(bool keep_stopped);
 
     virtual bool
+    DetachRequiresHalt() { return true; }
+
+    virtual bool
     UpdateThreadList(lldb_private::ThreadList &old_thread_list, lldb_private::ThreadList &new_thread_list);
 
     //------------------------------------------------------------------
_______________________________________________
lldb-dev mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/lldb-dev

Reply via email to