[lldb-dev] SBProcess::Detach kills target

Eugene Birukov via lldb-dev lldb-dev at lists.llvm.org
Tue Mar 29 10:38:24 PDT 2016


I believe this is not SIGHUP on debugger exit. I am using my own C++ program that calls into LLDB API. So, this program is still alive after calling SBProcess::Detach() but the target dies. Also, the target intercepts SIGHUP to do cleanup before exiting. I put printf there, it was not hit.
I tried interactive LLDB, the target is not there:
Process 49145 stopped* thread #1: tid = 49145, ..., stop reason = signal SIGSTOP    frame #0: 0x00007ffff6a5bbed libc.so.6 at syscall-template.S:81(lldb) detachProcess 49145 detached(lldb) qeugene at EUGENEBI-L1:~/tmp$ ps  PID TTY          TIME CMD30714 pts/17   00:00:00 bash49259 pts/17   00:00:00 pseugene at EUGENEBI-L1:~/tmp$
Eugene

> From: labath at google.com
> Date: Tue, 29 Mar 2016 09:43:50 +0100
> Subject: Re: [lldb-dev] SBProcess::Detach kills target
> To: jingham at apple.com; eugenebi at hotmail.com
> CC: lldb-dev at lists.llvm.org
> 
> There is no system restriction which prevents you from doing this.
> (Without any investigation) my guess would be that your inferior is
> dying of SIGHUP, which it receives when we close the master end of its
> pty. Could you check whether the behavior persists if your app blocks


> SIGHUP and/or you launch it with "process launch --no-stdio").
> 
> pl
> 
> On 25 March 2016 at 23:33, Jim Ingham via lldb-dev
> <lldb-dev at lists.llvm.org> wrote:
> > I vaguely remember that not all Unixen support detaching from a process that is a child of the debugger that is attached to it.  If you run the process under gdb & detach, does the process survive?  This may not be an exact test, since gdb may use procfs rather than ptrace, I don't know any more...  But if it doesn't work for gdb, it's probably a system limitation.
> >
> > Anyway, launch then detach works as Greg described on OS X, so all the bits down to the call into the Process plugin's Detach is working correctly.  So either there's a bug in llgs or in the Process plugin for Linux's detach.
> >
> > Jim
> >
> >
> >> On Mar 25, 2016, at 3:57 PM, Greg Clayton via lldb-dev <lldb-dev at lists.llvm.org> wrote:
> >>
> >> Calling SBProcess::Detach() on a process that is currently running should always detach and this seems like a bug. This might be this way because if you launch a process in LLDB and then quit:
> >>
> >> % lldb /bin/ls
> >> (lldb) b malloc
> >> (lldb) run
> >> (lldb) quit
> >>
> >> This should kill the process if it was launched and detach if we attached. But only when we quit without telling it to do something. If we did:
> >>
> >> % lldb /bin/ls
> >> (lldb) b malloc
> >> (lldb) run
> >> (lldb) detach
> >>
> >> Then this should always detach if the user explicitly requests it no matter how it was launched.
> >>
> >>> On Mar 25, 2016, at 3:35 PM, Eugene Birukov via lldb-dev <lldb-dev at lists.llvm.org> wrote:
> >>>
> >>> Hi,
> >>>
> >>> Is this expected behavior or am I doing something wrong?
> >>>
> >>> I am running my C++ program that uses LLDB API on Linux Ubuntu 15.10.
> >>>
> >>> If I attach to already running process then SBProcess::Detach() behaves as expected - my debugger quits and the target keeps running. But if the target was launched by my debugger, then detach just kills it. Is there any way to leave the target running?
> >>>
> >>> Thanks,
> >>> Eugene
> >>> _______________________________________________
> >>> lldb-dev mailing list
> >>> lldb-dev at lists.llvm.org
> >>> http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-dev
> >>
> >> _______________________________________________
> >> lldb-dev mailing list
> >> lldb-dev at lists.llvm.org
> >> http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-dev
> >
> > _______________________________________________
> > lldb-dev mailing list
> > lldb-dev at lists.llvm.org
> > http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-dev
 		 	   		  
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/lldb-dev/attachments/20160329/e868682e/attachment.html>


More information about the lldb-dev mailing list