[lldb-dev] lldb -- architecture level question -- linux v. darwin

Jim Ingham jingham at apple.com
Wed Mar 16 11:36:36 PDT 2011


An "in process" debugger in lldb would have to be a separate "Process" plugin from the one that we would normally use on Mac OS X or Linux to get around some bootstrapping problems, like for instance you can't ptrace yourself so the standard method of taking control of a process wouldn't work.  Another example is that a breakpoint hit would be a real SIGTRAP signal in your program, so you'd have to handle the SIGTRAP in a signal handler and then generate a debugger event for it, rather than just getting the SIGTRAP through ptrace or a mach exception or whatever.  And if I sat longer I bet I could come up with a bunch of other tricky bits you'd have to handle.  So it's clear that if you wanted to do an "in process" debugger in LLDB you would have to do it as a separate type of process plugin.  That said, I can't think of any reasons off the top of my head why this wouldn't work...

Another problem is that, at present, lldb assumes that when the program is being examined in the debugger, it is stopped altogether.  You obviously can't do that if you're in process.  We plan to implement a "no stop" mode where you would stop the thread that hit a breakpoint, say, but not the other threads.  But that's a ways off yet.  You could probably fudge this by having your "in process" process plugin know that stopping & restarting actually means suspending & resuming some subset of the program's threads, however.

In sum, I don't think that "in process" debugging as you are suggesting is impossible, but it would not fall out directly from the low level bits that do "other process" debugging.  It would require some separate effort.

OTOH, I'm not quite clear why having the debugger in-process is essential to your stated goals?  What do you gain by having the process control parts of the development environment be in the same process as the newly injected code?  The article you quoted is about injecting debug information along with newly injected code.  Having the debugger in process is not going to remove that requirement, and conversely once it is there, the debugger should be able to find it whether in process or not.

Jim



On Mar 16, 2011, at 11:00 AM, Jason E. Aten wrote:

> To this end, I'm actually most interested in exploring the very un-remote direction, where the debugger and the debuggee are as close as poosible, even in the same process space (as would probably be necessary). The aim is to get minimum re-compile times to support JIT-based everything, for an incremental style development with JIT-support, and simultaneous access to debugger level ability to step through the just JIT-ed code. The goal would be to obtain something akin to the rapid LISP development environment with hot-swappable functions, but rather than interpreted, have it be llvm JIT-based.
> 
> But perhaps my thoughts on adding this kind of feature to LLDB are not realistic.  If LLDB always needs its target process to be a separate process (how baked in is that assumption, by the way, I guess that is really a key and important question!?), then I may not be able to implement the description above, inspired by Reid Kleckners post below.




More information about the lldb-dev mailing list