[PATCH] D73932: [mlir] Register the GDB listener with ExecutionEngine to enable debugging JIT'd code
River Riddle via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Feb 5 17:44:00 PST 2020
This revision was automatically updated to reflect the committed changes.
Closed by commit rGc3f0ed7bccaf: [mlir] Register the GDB listener with ExecutionEngine to enable debugging JIT'd… (authored by rriddle).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D73932/new/
https://reviews.llvm.org/D73932
Files:
mlir/include/mlir/ExecutionEngine/ExecutionEngine.h
mlir/lib/ExecutionEngine/ExecutionEngine.cpp
Index: mlir/lib/ExecutionEngine/ExecutionEngine.cpp
===================================================================
--- mlir/lib/ExecutionEngine/ExecutionEngine.cpp
+++ mlir/lib/ExecutionEngine/ExecutionEngine.cpp
@@ -18,6 +18,7 @@
#include "llvm/Bitcode/BitcodeReader.h"
#include "llvm/Bitcode/BitcodeWriter.h"
+#include "llvm/ExecutionEngine/JITEventListener.h"
#include "llvm/ExecutionEngine/ObjectCache.h"
#include "llvm/ExecutionEngine/Orc/CompileUtils.h"
#include "llvm/ExecutionEngine/Orc/ExecutionUtils.h"
@@ -182,7 +183,8 @@
}
ExecutionEngine::ExecutionEngine(bool enableObjectCache)
- : cache(enableObjectCache ? nullptr : new SimpleObjectCache()) {}
+ : cache(enableObjectCache ? nullptr : new SimpleObjectCache()),
+ gdbListener(llvm::JITEventListener::createGDBRegistrationListener()) {}
Expected<std::unique_ptr<ExecutionEngine>> ExecutionEngine::create(
ModuleOp m, std::function<Error(llvm::Module *)> transformer,
@@ -221,6 +223,14 @@
const Triple &TT) {
auto objectLayer = std::make_unique<RTDyldObjectLinkingLayer>(
session, []() { return std::make_unique<SectionMemoryManager>(); });
+ objectLayer->setNotifyLoaded(
+ [engine = engine.get()](
+ llvm::orc::VModuleKey, const llvm::object::ObjectFile &object,
+ const llvm::RuntimeDyld::LoadedObjectInfo &objectInfo) {
+ uint64_t key = static_cast<uint64_t>(
+ reinterpret_cast<uintptr_t>(object.getData().data()));
+ engine->gdbListener->notifyObjectLoaded(key, object, objectInfo);
+ });
auto dataLayout = deserModule->getDataLayout();
llvm::orc::JITDylib *mainJD = session.getJITDylibByName("<main>");
if (!mainJD)
Index: mlir/include/mlir/ExecutionEngine/ExecutionEngine.h
===================================================================
--- mlir/include/mlir/ExecutionEngine/ExecutionEngine.h
+++ mlir/include/mlir/ExecutionEngine/ExecutionEngine.h
@@ -26,6 +26,7 @@
template <typename T> class Expected;
class Module;
class ExecutionEngine;
+class JITEventListener;
class MemoryBuffer;
} // namespace llvm
@@ -97,15 +98,18 @@
void dumpToObjectFile(StringRef filename);
private:
- // Ordering of llvmContext and jit is important for destruction purposes: the
- // jit must be destroyed before the context.
+ /// Ordering of llvmContext and jit is important for destruction purposes: the
+ /// jit must be destroyed before the context.
llvm::LLVMContext llvmContext;
- // Underlying LLJIT.
+ /// Underlying LLJIT.
std::unique_ptr<llvm::orc::LLJIT> jit;
- // Underlying cache.
+ /// Underlying cache.
std::unique_ptr<SimpleObjectCache> cache;
+
+ /// GDB notification listener.
+ llvm::JITEventListener *gdbListener;
};
template <typename... Args>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D73932.242793.patch
Type: text/x-patch
Size: 2835 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200206/f75bf6bd/attachment.bin>
More information about the llvm-commits
mailing list