Skip to content
This repository was archived by the owner on Jul 3, 2021. It is now read-only.

Commit a4b88a0

Browse files
Implement GDB JIT interface
1 parent 96f4c8e commit a4b88a0

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

JitFromScratch.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,10 @@ using namespace llvm::orc;
1616
JitFromScratch::JitFromScratch(ExitOnError ExitOnErr)
1717
: ES(std::make_unique<ExecutionSession>()),
1818
TM(createTargetMachine(ExitOnErr)),
19+
GDBListener(JITEventListener::createGDBRegistrationListener()),
1920
ObjLinkingLayer(*ES, createMemoryManagerFtor()),
2021
CompileLayer(*ES, ObjLinkingLayer, SimpleCompiler(*TM)) {
22+
ObjLinkingLayer.setNotifyLoaded(createNotifyLoadedFtor());
2123
if (auto R = createHostProcessResolver())
2224
ES->getMainJITDylib().setGenerator(std::move(R));
2325
}
@@ -57,6 +59,13 @@ GetMemoryManagerFunction JitFromScratch::createMemoryManagerFtor() {
5759
};
5860
}
5961

62+
RTDyldObjectLinkingLayer::NotifyLoadedFunction
63+
JitFromScratch::createNotifyLoadedFtor() {
64+
using namespace std::placeholders;
65+
return std::bind(&JITEventListener::notifyObjectLoaded,
66+
GDBListener, _1, _2, _3);
67+
}
68+
6069
std::string JitFromScratch::mangle(StringRef UnmangledName) {
6170
std::string MangledName;
6271
{

JitFromScratch.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#pragma once
22

33
#include <llvm/ADT/StringRef.h>
4+
#include <llvm/ExecutionEngine/JITEventListener.h>
45
#include <llvm/ExecutionEngine/JITSymbol.h>
56
#include <llvm/ExecutionEngine/Orc/Core.h>
67
#include <llvm/ExecutionEngine/Orc/IRCompileLayer.h>
@@ -49,6 +50,7 @@ class JitFromScratch {
4950
private:
5051
std::unique_ptr<llvm::orc::ExecutionSession> ES;
5152
std::unique_ptr<llvm::TargetMachine> TM;
53+
llvm::JITEventListener *GDBListener;
5254

5355
llvm::orc::RTDyldObjectLinkingLayer ObjLinkingLayer;
5456
llvm::orc::IRCompileLayer CompileLayer;
@@ -61,6 +63,9 @@ class JitFromScratch {
6163
llvm::orc::RTDyldObjectLinkingLayer::GetMemoryManagerFunction
6264
createMemoryManagerFtor();
6365

66+
llvm::orc::RTDyldObjectLinkingLayer::NotifyLoadedFunction
67+
createNotifyLoadedFtor();
68+
6469
std::string mangle(llvm::StringRef UnmangledName);
6570
llvm::Error applyDataLayout(llvm::Module &M);
6671

0 commit comments

Comments
 (0)