Skip to content

Commit c714e2e

Browse files
Add JITLink ELF debugger support (#47037)
1 parent e4633e0 commit c714e2e

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

src/jitlayers.cpp

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
#include <llvm/Analysis/TargetTransformInfo.h>
1313
#include <llvm/ExecutionEngine/Orc/CompileUtils.h>
1414
#include <llvm/ExecutionEngine/Orc/ExecutionUtils.h>
15+
#include <llvm/ExecutionEngine/Orc/DebugObjectManagerPlugin.h>
16+
#include <llvm/ExecutionEngine/Orc/TargetProcess/JITLoaderGDB.h>
1517
#include <llvm/ExecutionEngine/Orc/ExecutorProcessControl.h>
1618
#include <llvm/IR/Verifier.h>
1719
#include <llvm/Support/DynamicLibrary.h>
@@ -1536,13 +1538,15 @@ llvm_orc_registerJITLoaderGDBAllocAction(const char *Data, size_t Size);
15361538

15371539
void JuliaOJIT::enableJITDebuggingSupport()
15381540
{
1539-
// We do not use GDBJITDebugInfoRegistrationPlugin::Create, as the runtime name
1540-
// lookup is unnecessarily involved/fragile for our in-process JIT use case
1541-
// (with the llvm_orc_registerJITLoaderGDBAllocAction symbol being in either
1542-
// libjulia-codegen or yet another shared library for LLVM depending on the build
1543-
// flags, etc.).
1544-
const auto Addr = ExecutorAddr::fromPtr(&llvm_orc_registerJITLoaderGDBAllocAction);
1545-
ObjectLayer.addPlugin(std::make_unique<orc::GDBJITDebugInfoRegistrationPlugin>(Addr));
1541+
orc::SymbolMap GDBFunctions;
1542+
GDBFunctions[mangle("llvm_orc_registerJITLoaderGDBAllocAction")] = JITEvaluatedSymbol::fromPointer(&llvm_orc_registerJITLoaderGDBAllocAction, JITSymbolFlags::Exported | JITSymbolFlags::Callable);
1543+
GDBFunctions[mangle("llvm_orc_registerJITLoaderGDBWrapper")] = JITEvaluatedSymbol::fromPointer(&llvm_orc_registerJITLoaderGDBWrapper, JITSymbolFlags::Exported | JITSymbolFlags::Callable);
1544+
cantFail(JD.define(orc::absoluteSymbols(GDBFunctions)));
1545+
if (TM->getTargetTriple().isOSBinFormatMachO())
1546+
ObjectLayer.addPlugin(cantFail(orc::GDBJITDebugInfoRegistrationPlugin::Create(ES, JD, TM->getTargetTriple())));
1547+
else if (TM->getTargetTriple().isOSBinFormatELF())
1548+
//EPCDebugObjectRegistrar doesn't take a JITDylib, so we have to directly provide the call address
1549+
ObjectLayer.addPlugin(std::make_unique<orc::DebugObjectManagerPlugin>(ES, std::make_unique<orc::EPCDebugObjectRegistrar>(ES, orc::ExecutorAddr::fromPtr(&llvm_orc_registerJITLoaderGDBWrapper))));
15461550
}
15471551
#else
15481552
void JuliaOJIT::enableJITDebuggingSupport()

0 commit comments

Comments
 (0)