llvm / llvm-project

The LLVM Project is a collection of modular and reusable compiler and toolchain technologies.
http://llvm.org
Other
29.13k stars 12.02k forks source link

Debugging support in OrcV2 / JITLink #44553

Open lhames opened 4 years ago

lhames commented 4 years ago
Bugzilla Link 45208
Version trunk
OS All
CC @AlexDenisov,@dwblaikie,@weliveindetail

Extended Description

We should build an ObjectLinkingLayer plugin to enable debugging of JIT'd code.

MCJIT / RuntimeDyld already has GDBRegistrationListener for this purpose. We may want to look at whether we can re-use the GDB registration protocol for this. See: llvm/llvm-project#1501 , llvm/llvm-project#18002 , and https://sourceware.org/gdb/current/onlinedocs/gdb/JIT-Interface.html.

If we go this route then ideally the plugin will synthesize a new object with the necessary section/segment load commands, nlist entries, and dwarf sections, but without the dead weight of all the actual code and data.

lhames commented 2 years ago

Initial MachO debugging support added in e1933a0488a. You'll need to explicitly enable the plugin in lldb to use it:

(lldb) set set plugin.jit-loader.gdb.enable on

Once the plugin has been enabled you should be able to debug MachO JIT'd code within that session.