v.g.vassilev created this revision. v.g.vassilev added reviewers: lhames, sgraenitz, junaire. Herald added a subscriber: pengfei. Herald added a project: All. v.g.vassilev requested review of this revision.
This change follows llvm/llvm-project@21b5ebd and makes use of the jitlink infrastructure. In order to use this feature inside lldb one needs to run the lldb command: settings set plugin.jit-loader.gdb.enable on This works currently only on Darwin since jitlink is not a default ELF/x86-64 backend yet. https://reviews.llvm.org/D148481 Files: clang/lib/Interpreter/IncrementalExecutor.cpp Index: clang/lib/Interpreter/IncrementalExecutor.cpp =================================================================== --- clang/lib/Interpreter/IncrementalExecutor.cpp +++ clang/lib/Interpreter/IncrementalExecutor.cpp @@ -21,11 +21,18 @@ #include "llvm/ExecutionEngine/Orc/IRCompileLayer.h" #include "llvm/ExecutionEngine/Orc/LLJIT.h" #include "llvm/ExecutionEngine/Orc/RTDyldObjectLinkingLayer.h" +#include "llvm/ExecutionEngine/Orc/TargetProcess/JITLoaderGDB.h" #include "llvm/ExecutionEngine/SectionMemoryManager.h" #include "llvm/IR/Module.h" #include "llvm/Support/ManagedStatic.h" #include "llvm/Support/TargetSelect.h" +// Force linking some of the runtimes that helps attaching to a debugger. +LLVM_ATTRIBUTE_USED void linkComponents() { + llvm::errs() << (void *)&llvm_orc_registerJITLoaderGDBWrapper + << (void *)&llvm_orc_registerJITLoaderGDBAllocAction; +} + namespace clang { IncrementalExecutor::IncrementalExecutor(llvm::orc::ThreadSafeContext &TSC, @@ -37,7 +44,12 @@ auto JTMB = JITTargetMachineBuilder(TI.getTriple()); JTMB.addFeatures(TI.getTargetOpts().Features); - if (auto JitOrErr = LLJITBuilder().setJITTargetMachineBuilder(JTMB).create()) + LLJITBuilder Builder; + Builder.setJITTargetMachineBuilder(JTMB); + // Enable debugging of JIT'd code (only works on JITLink for ELF and MachO). + Builder.setEnableDebuggerSupport(true); + + if (auto JitOrErr = Builder.create()) Jit = std::move(*JitOrErr); else { Err = JitOrErr.takeError();
Index: clang/lib/Interpreter/IncrementalExecutor.cpp =================================================================== --- clang/lib/Interpreter/IncrementalExecutor.cpp +++ clang/lib/Interpreter/IncrementalExecutor.cpp @@ -21,11 +21,18 @@ #include "llvm/ExecutionEngine/Orc/IRCompileLayer.h" #include "llvm/ExecutionEngine/Orc/LLJIT.h" #include "llvm/ExecutionEngine/Orc/RTDyldObjectLinkingLayer.h" +#include "llvm/ExecutionEngine/Orc/TargetProcess/JITLoaderGDB.h" #include "llvm/ExecutionEngine/SectionMemoryManager.h" #include "llvm/IR/Module.h" #include "llvm/Support/ManagedStatic.h" #include "llvm/Support/TargetSelect.h" +// Force linking some of the runtimes that helps attaching to a debugger. +LLVM_ATTRIBUTE_USED void linkComponents() { + llvm::errs() << (void *)&llvm_orc_registerJITLoaderGDBWrapper + << (void *)&llvm_orc_registerJITLoaderGDBAllocAction; +} + namespace clang { IncrementalExecutor::IncrementalExecutor(llvm::orc::ThreadSafeContext &TSC, @@ -37,7 +44,12 @@ auto JTMB = JITTargetMachineBuilder(TI.getTriple()); JTMB.addFeatures(TI.getTargetOpts().Features); - if (auto JitOrErr = LLJITBuilder().setJITTargetMachineBuilder(JTMB).create()) + LLJITBuilder Builder; + Builder.setJITTargetMachineBuilder(JTMB); + // Enable debugging of JIT'd code (only works on JITLink for ELF and MachO). + Builder.setEnableDebuggerSupport(true); + + if (auto JitOrErr = Builder.create()) Jit = std::move(*JitOrErr); else { Err = JitOrErr.takeError();
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits