[Lldb-commits] [lldb] r128547 - in /lldb/trunk/source/Plugins/Process/Linux: LinuxSignals.cpp LinuxSignals.h LinuxStopInfo.cpp LinuxStopInfo.h LinuxThread.cpp LinuxThread.h ProcessLinux.cpp ProcessLinux.h ProcessMessage.cpp ProcessMessage.h ProcessMonitor.cpp ProcessMonitor.h
wilsons at start.ca
Wed Mar 30 10:32:13 PDT 2011
On Wed, Mar 30, 2011 at 09:51:56AM -0700, Greg Clayton wrote:
> Well done! I am glad to see this works well for Linux.
So far, LLDB has proven to be very easy to "port" onto linux.
> One question: are all of the signals you added actually signals? It
> looked like it from what I can tell. One of the hacks we did in GDB
> for mach exceptions was to make up new fake signal numbers because the
> debugger wanted to deal with signals.
They are all real signals. I have not needed to add anything extra yet,
but see below.
> One thing I just want to make sure happens in LLDB is that we never
> have to make up anything. For mach exceptions, we have a StopInfo
> subclass that is not part of the built in StopInfo stuff:
> StopInfoMachException. This class takes care of doing all of the
> special mach things that no other platform really cares about.
> So if there are things that aren't signals in your recent checkin, you
> might consider making a StopInfoLinux to take care of any special
> things that aren't signal related.
We do have a couple of linux specific stop info's now. For example, we
have a LinuxLimboStopInfo that is generated when a process is just about
to exit (in such a state, you cannot stop the exit from happening, but
you can inspect registers and probe memory -- helpful when you
mistakenly press 'n' one too many times and terminate the process after
a SIGSEGV!). We also have a LinuxCrashStopInfo that contains a
description of the event in question.
Another thing we do in the Linux plugin is propagate information about
state changes using so-called ProcessMessage's. These are *very* similar
to StopInfo objects, but can be tailored easily to the needs of the
plugin. The basic flow is:
- ProcessMonitor gets an event as a result of wait4().
- The event is packaged into a ProcessMessage and sent to a
ProcessLinux instance. The events trigger state changes in the
process as appropriate, and are queued up for delivery to
- When the process state change event has propagated the
corresponding ProcessMessage is delivered to the appropriate
LinuxThread via LinuxThread::Notify.
- The thread converts the message into a StopInfo object to
advertise to the rest of LLDB.
The above seems to work well for the single threaded case -- we will
need to tag ProcessMessages with a "stop ID" when we support
multithreading. Basic mutithreading support is the next big item on my
It is possible that, over time, the ProcessMessage class could be
replaced by StopInfo's completely. However, having a little internal
class like ProcessMessage seems to be a flexible way to keep linux
specific semantics internal to the plugin.
Of course, any feedback on how I am doing this is very much appreciated!
> Greg Clayton
> On Mar 30, 2011, at 8:55 AM, Stephen Wilson wrote:
> > Author: wilsons
> > Date: Wed Mar 30 10:55:52 2011
> > New Revision: 128547
> > URL: http://llvm.org/viewvc/llvm-project?rev=128547&view=rev
> > Log:
> > linux: initial support for 'real' signal handling
> > This patch upgrades the Linux process plugin to handle a larger range of signal
> > events. For example, we can detect when the inferior has "crashed" and why,
> > interrupt a running process, deliver an arbitrary signal, and so on.
> > Added:
> > lldb/trunk/source/Plugins/Process/Linux/LinuxSignals.cpp
> > lldb/trunk/source/Plugins/Process/Linux/LinuxSignals.h
> > lldb/trunk/source/Plugins/Process/Linux/LinuxStopInfo.cpp
> > lldb/trunk/source/Plugins/Process/Linux/LinuxStopInfo.h
> > lldb/trunk/source/Plugins/Process/Linux/ProcessMessage.cpp
> > Modified:
> > lldb/trunk/source/Plugins/Process/Linux/LinuxThread.cpp
> > lldb/trunk/source/Plugins/Process/Linux/LinuxThread.h
> > lldb/trunk/source/Plugins/Process/Linux/ProcessLinux.cpp
> > lldb/trunk/source/Plugins/Process/Linux/ProcessLinux.h
> > lldb/trunk/source/Plugins/Process/Linux/ProcessMessage.h
> > lldb/trunk/source/Plugins/Process/Linux/ProcessMonitor.cpp
> > lldb/trunk/source/Plugins/Process/Linux/ProcessMonitor.h
More information about the lldb-commits