[llvm-dev] ORC JIT Weekly #44 -- MachO debugging support enabled

Lang Hames via llvm-dev llvm-dev at lists.llvm.org
Sun Nov 14 23:25:53 PST 2021


Hi All,

OrcRTBridge cleanup has been set aside briefly. Instead of working on that
> I'm going to take a shot at getting MachO debugging support working in time
> for the dev meeting.


Success! MachO debugging support has landed in [1] (with an obligatory
round of revert/reapply for bot failures). This support ended up being
easier to implement than I had hoped, largely thanks to all the
infrastructure put in place by Stefan Granitz's earlier work on ELF
debugging, as well as some help from Fred Riss and Jim Ingham. Thanks
everyone!

The new support has been enabled in the llvm-jitlink tool (we should be
able to add it to lli soon too). If you want to test it out on Darwin you
can run:

% clang -O0 -g -c -o my-program.o my-program.c

% lldb llvm-jitlink
(lldb) settings set plugin.jit-loader.gdb.enable on
(lldb) b <location in my-program.c>
(lldb) run my-program.o

If you set a breakpoint on main beware that you'll hit it twice: First
llvm-jitlink's own main, and then then my-program.o's. Either way, once you
hit your breakpoint you should then be able to step through JIT'd code.

This is brand new, so please let me know if you run into any issues with
it. Bug reports are very welcome.

Enabling the support in your own JIT should be relatively straightforward.
You just need to include llvm/ExecutionEngine/Orc/DebuggerSupportPlugin.h,
then install the GDBJITDebugInfoRegistrationPlugin in your object linking
layer. You can see llvm-jitlink's code for this at [2]:

 ObjLayer.addPlugin(ExitOnErr(
        GDBJITDebugInfoRegistrationPlugin::Create(this->ES, *MainJD, TT)));

In the future we'll try to merge the ELF DebugObjectManagerPlugin and the
new GDBJITDebugInfoRegistrationPlugin so that you only have to enable the
one plugin regardless of platform.

-- Lang.

[1]
https://github.com/llvm/llvm-project/commit/e1933a0488a50eb939210808fc895d374570d891
[2]
https://github.com/llvm/llvm-project/blob/0d1d058544446b5fc74e70827a021a017facc56a/llvm/tools/llvm-jitlink/llvm-jitlink.cpp#L1000
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20211114/20417eec/attachment.html>


More information about the llvm-dev mailing list