[lldb-dev] Debugging JIT-compiled code with LLVM
Simon Ask Ulsnes
simon at ulsnes.dk
Fri Nov 19 12:59:01 PST 2010
Thank you for your elaborate reply! I have a few small questions:
> A few questions on how this would be debugged (not worrying about the JIT
> yet):
> 1 - When you are debugging this, are you going to want to step through your
> new source code files or generated C/C++ sources?
> 2 - If you want to debug sources that you produce, will this be like
> debugging lex/yacc code where a bunch of #line and #file directives are used
> to map C/C++ code to your proprietary source code?
> If you are going to be debugging standard i386/x86_64 code, then you won't
> need to subclass lldb_private::Process.
1) Both, ideally, but the first step will definitely be to be able to
debug JIT'ed C/C++ code.
2) For my language, there is a "proper" codegen that targets the LLVM
IR directly — no intermediate C/C++. So that's great! In the long run,
I suppose it would be nice to support the other way as well, but
that'll be up to the first person who needs that. ;-)
> In order to support JIT'ed code, we just need a way to communicate between a
> running program and the debugger. Setting a breakpoint, like is done with
> the JIT support in GDB, is quite ok for this as this is how the dynamic
> loader plug-in for macosx currently works. We can probably get away with
> being able to register additional dynamic loader plug-ins with the current
> Process.
(… examples and elaboration omitted for brevity …)
Since I'm not deeply familiar with the architecture of LLDB yet, it's
not clear to me what the exact relationship between the classes
Process, ProcessGDBRemote, and ProcessMacOSX is. Would it be necessary
to implement the JIT support in both ProcessGDBRemote and
ProcessMacOSX to get things working on Darwin? The way the two use the
DynamicLoader plugin is currently almost identical, so I'm unsure
whether that's a temporary thing (ProcessGDBRemote should at some
point become cross-platform, or what?).
Which one is used under normal debugging circumstances on Mac OS X?
The rest makes sense, and I have a pretty clear idea where to go from here.
> Let me know if you need any explanation on anything mentioned above.
> Greg
Again, thank you for being so helpful. :)
Simon
More information about the lldb-dev
mailing list