1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-24 19:52:54 +01:00

[lli] Add JITLink in-process debug support

lli aims to provide both, RuntimeDyld and JITLink, as the dynamic linkers/loaders for it's JIT implementations. And they both offer debugging via the GDB JIT interface, which builds on the two well-known symbol names `__jit_debug_descriptor` and `__jit_debug_register_code`. As these symbols must be unique accross the linked executable, we can only define them in one of the libraries and make the other depend on it. OrcTargetProcess is a minimal stub for embedding a JIT client in remote executors. For the moment it seems reasonable to have the definition there and let ExecutionEngine depend on it, until we find a better solution.

This is the second commit for the reviewed patch.

Reviewed By: lhames

Differential Revision: https://reviews.llvm.org/D97339
This commit is contained in:
Stefan Gränitz 2021-02-23 14:54:21 +00:00
parent 44d6e1a3fb
commit 7dea8abe52
3 changed files with 24 additions and 10 deletions

View File

@ -17,6 +17,7 @@ add_llvm_component_library(LLVMExecutionEngine
Core
MC
Object
OrcTargetProcess
RuntimeDyld
Support
Target

View File

@ -47,21 +47,28 @@ extern "C" {
// We put information about the JITed function in this global, which the
// debugger reads. Make sure to specify the version statically, because the
// debugger checks the version before we can set it during runtime.
struct jit_descriptor __jit_debug_descriptor = { 1, 0, nullptr, nullptr };
extern struct jit_descriptor __jit_debug_descriptor;
// Debuggers puts a breakpoint in this function.
LLVM_ATTRIBUTE_NOINLINE void __jit_debug_register_code() {
// The noinline and the asm prevent calls to this function from being
// optimized out.
#if !defined(_MSC_VER)
asm volatile("":::"memory");
#endif
}
extern "C" void __jit_debug_register_code();
}
namespace {
// FIXME: lli aims to provide both, RuntimeDyld and JITLink, as the dynamic
// loaders for it's JIT implementations. And they both offer debugging via the
// GDB JIT interface, which builds on the two well-known symbol names below.
// As these symbols must be unique accross the linked executable, we can only
// define them in one of the libraries and make the other depend on it.
// OrcTargetProcess is a minimal stub for embedding a JIT client in remote
// executors. For the moment it seems reasonable to have the definition there
// and let ExecutionEngine depend on it, until we find a better solution.
//
LLVM_ATTRIBUTE_USED void requiredSymbolDefinitionsFromOrcTargetProcess() {
errs() << (void *)&__jit_debug_register_code
<< (void *)&__jit_debug_descriptor;
}
struct RegisteredObjectInfo {
RegisteredObjectInfo() {}

View File

@ -26,6 +26,7 @@
#include "llvm/ExecutionEngine/JITEventListener.h"
#include "llvm/ExecutionEngine/MCJIT.h"
#include "llvm/ExecutionEngine/ObjectCache.h"
#include "llvm/ExecutionEngine/Orc/DebugObjectManagerPlugin.h"
#include "llvm/ExecutionEngine/Orc/DebugUtils.h"
#include "llvm/ExecutionEngine/Orc/ExecutionUtils.h"
#include "llvm/ExecutionEngine/Orc/JITTargetMachineBuilder.h"
@ -34,7 +35,9 @@
#include "llvm/ExecutionEngine/Orc/OrcRemoteTargetClient.h"
#include "llvm/ExecutionEngine/Orc/RTDyldObjectLinkingLayer.h"
#include "llvm/ExecutionEngine/Orc/SymbolStringPool.h"
#include "llvm/ExecutionEngine/Orc/TPCDebugObjectRegistrar.h"
#include "llvm/ExecutionEngine/Orc/TPCEHFrameRegistrar.h"
#include "llvm/ExecutionEngine/Orc/TargetProcess/JITLoaderGDB.h"
#include "llvm/ExecutionEngine/Orc/TargetProcess/RegisterEHFrames.h"
#include "llvm/ExecutionEngine/Orc/TargetProcess/TargetExecutionUtils.h"
#include "llvm/ExecutionEngine/SectionMemoryManager.h"
@ -277,7 +280,8 @@ namespace {
LLVM_ATTRIBUTE_USED void linkComponents() {
errs() << (void *)&llvm_orc_registerEHFrameSectionWrapper
<< (void *)&llvm_orc_deregisterEHFrameSectionWrapper;
<< (void *)&llvm_orc_deregisterEHFrameSectionWrapper
<< (void *)&llvm_orc_registerJITLoaderGDBWrapper;
}
//===----------------------------------------------------------------------===//
@ -923,6 +927,8 @@ int runOrcLazyJIT(const char *ProgName) {
auto L = std::make_unique<orc::ObjectLinkingLayer>(ES, TPC->getMemMgr());
L->addPlugin(std::make_unique<orc::EHFrameRegistrationPlugin>(
ES, ExitOnErr(orc::TPCEHFrameRegistrar::Create(*TPC))));
L->addPlugin(std::make_unique<orc::DebugObjectManagerPlugin>(
ES, ExitOnErr(orc::createJITLoaderGDBRegistrar(*TPC))));
return L;
});
}