[lldb-dev] Linux process plugin

Stephen Wilson wilsons at start.ca
Tue Sep 28 09:36:40 PDT 2010


<arvid.picciani at nokia.com> writes:

> I think,I need some help getting the linux process plugin
> working. Getting it compiling was easy so far, but it won't work, and
> for me its not easy too see how its supposed to work either.  First of
> all, why does it run the inferior in a pty? I don't see why we would
> need an entire terminal there.

As Greg mentioned, to have a complete environment for the debugged
process.  A good example of how this can make a difference is with some
of the LLVM tools which do not like to emit binary data to stdout when
connected to a PTY.


> Secondly, why is there one thread per fd afterwards?

Not per fd.  The main issue under Linux is that ptrace() can only be
called from the thread which originally fork()'ed or attached to the
inferior process.  In LLDB operations on the inferior (like setting a
breakpoint, say) can originate from an "arbitrary" thread.

The linux plugin handles this by establishing a ProcessMonitor -- a
thread which forks the inferior then "serves" operations on it in a
thread safe fashion.

The heart of this strategy is implemented in
ProcessMonitor::ServeOperation.  This routine waits on a full duplex
pipe and reads pointers to instances of the Operation class.  The
virtual method Operation::Execute implements a particular capability of
the ptrace() syscall -- when the server invokes this method the
corresponding ptrace() is executed in the correct thread context.


> Basicly it does pretty much nothing:
> (lldb) r
> Launching '/tmp/crashd/a.out'  (x86_64)
> (lldb)
> it randomly works after a few times, but only results in a visible effect when the inferior crashes.
> It then tries to send a message to the crashed process, which crashes lldb. There is a FIXME in there,
> but why is this on a seperate thread in the first place?
>

There never was much functionality even before the plugin bitrotted --
we could start an inferior, set and step over breakpoints.  There was no
support for dynamic libraries.


Unfortunately I have been swamped with a work project for the last few
weeks and have not been keeping my builds of LLDB up to date.  I will
try to find some time this weekend to get back up to speed on the state
of the plugin and see what I can do to get it back on its feet.

--
steve



More information about the lldb-dev mailing list