Skip to content

Commit 3ce893f

Browse files
[ORC] Move DebugObjectManagerPlugin into Debugging/ELFDebugObjectPlugin (NFC) (#168343)
In 4 years the plugin wasn't adapted to other object formats. This patch makes it specific for ELF, which will allow to remove some abstractions down the line. It also moves the plugin from LLVMOrcJIT into LLVMOrcDebugging, which didn't exist back then.
1 parent 672757b commit 3ce893f

File tree

10 files changed

+34
-38
lines changed

10 files changed

+34
-38
lines changed

clang/lib/Interpreter/IncrementalExecutor.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
#include "llvm/ADT/StringExtras.h"
1919
#include "llvm/ExecutionEngine/ExecutionEngine.h"
2020
#include "llvm/ExecutionEngine/Orc/CompileUtils.h"
21-
#include "llvm/ExecutionEngine/Orc/DebugObjectManagerPlugin.h"
2221
#include "llvm/ExecutionEngine/Orc/Debugging/DebuggerSupport.h"
2322
#include "llvm/ExecutionEngine/Orc/EPCDebugObjectRegistrar.h"
2423
#include "llvm/ExecutionEngine/Orc/EPCDynamicLibrarySearchGenerator.h"

llvm/examples/OrcV2Examples/LLJITWithRemoteDebugging/RemoteJITUtils.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,7 @@
99
#include "RemoteJITUtils.h"
1010

1111
#include "llvm/ADT/StringExtras.h"
12-
#include "llvm/ExecutionEngine/Orc/DebugObjectManagerPlugin.h"
13-
#include "llvm/ExecutionEngine/Orc/EPCDebugObjectRegistrar.h"
12+
#include "llvm/ExecutionEngine/Orc/Debugging/ELFDebugObjectPlugin.h"
1413
#include "llvm/ExecutionEngine/Orc/EPCDynamicLibrarySearchGenerator.h"
1514
#include "llvm/ExecutionEngine/Orc/Shared/SimpleRemoteEPCUtils.h"
1615
#include "llvm/ExecutionEngine/Orc/TargetProcess/JITLoaderGDB.h"

llvm/include/llvm/ExecutionEngine/Orc/Debugging/DebuggerSupportPlugin.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ namespace orc {
2424
/// For each object containing debug info, installs JITLink passes to synthesize
2525
/// a debug object and then register it via the GDB JIT-registration interface.
2626
///
27-
/// Currently MachO only. For ELF use DebugObjectManagerPlugin. These two
27+
/// Currently MachO only. For ELF use ELFDebugObjectPlugin. These two
2828
/// plugins will be merged in the near future.
2929
class LLVM_ABI GDBJITDebugInfoRegistrationPlugin
3030
: public ObjectLinkingLayer::Plugin {

llvm/include/llvm/ExecutionEngine/Orc/DebugObjectManagerPlugin.h renamed to llvm/include/llvm/ExecutionEngine/Orc/Debugging/ELFDebugObjectPlugin.h

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//===---- DebugObjectManagerPlugin.h - JITLink debug objects ---*- C++ -*-===//
1+
//===------ ELFDebugObjectPlugin.h - JITLink debug objects ------*- C++ -*-===//
22
//
33
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
44
// See https://llvm.org/LICENSE.txt for license information.
@@ -10,8 +10,8 @@
1010
//
1111
//===----------------------------------------------------------------------===//
1212

13-
#ifndef LLVM_EXECUTIONENGINE_ORC_DEBUGOBJECTMANAGERPLUGIN_H
14-
#define LLVM_EXECUTIONENGINE_ORC_DEBUGOBJECTMANAGERPLUGIN_H
13+
#ifndef LLVM_EXECUTIONENGINE_ORC_ELFDEBUGOBJECTPLUGIN_H
14+
#define LLVM_EXECUTIONENGINE_ORC_ELFDEBUGOBJECTPLUGIN_H
1515

1616
#include "llvm/ExecutionEngine/JITLink/JITLink.h"
1717
#include "llvm/ExecutionEngine/Orc/Core.h"
@@ -46,7 +46,7 @@ class DebugObject;
4646
/// DebugObjectRegistrar is notified. Ownership of DebugObjects remains with the
4747
/// plugin.
4848
///
49-
class LLVM_ABI DebugObjectManagerPlugin : public ObjectLinkingLayer::Plugin {
49+
class LLVM_ABI ELFDebugObjectPlugin : public ObjectLinkingLayer::Plugin {
5050
public:
5151
/// Create the plugin to submit DebugObjects for JITLink artifacts. For all
5252
/// options the recommended setting is true.
@@ -63,9 +63,9 @@ class LLVM_ABI DebugObjectManagerPlugin : public ObjectLinkingLayer::Plugin {
6363
/// sequence. When turning this off, the user has to issue the call to
6464
/// __jit_debug_register_code() on the executor side manually.
6565
///
66-
DebugObjectManagerPlugin(ExecutionSession &ES, bool RequireDebugSections,
67-
bool AutoRegisterCode, Error &Err);
68-
~DebugObjectManagerPlugin() override;
66+
ELFDebugObjectPlugin(ExecutionSession &ES, bool RequireDebugSections,
67+
bool AutoRegisterCode, Error &Err);
68+
~ELFDebugObjectPlugin() override;
6969

7070
void notifyMaterializing(MaterializationResponsibility &MR,
7171
jitlink::LinkGraph &G, jitlink::JITLinkContext &Ctx,
@@ -99,4 +99,4 @@ class LLVM_ABI DebugObjectManagerPlugin : public ObjectLinkingLayer::Plugin {
9999
} // namespace orc
100100
} // namespace llvm
101101

102-
#endif // LLVM_EXECUTIONENGINE_ORC_DEBUGOBJECTMANAGERPLUGIN_H
102+
#endif // LLVM_EXECUTIONENGINE_ORC_ELFDEBUGOBJECTPLUGIN_H

llvm/lib/ExecutionEngine/Orc/CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ add_llvm_component_library(LLVMOrcJIT
1414
CompileOnDemandLayer.cpp
1515
CompileUtils.cpp
1616
Core.cpp
17-
DebugObjectManagerPlugin.cpp
1817
DebugUtils.cpp
1918
EHFrameRegistrationPlugin.cpp
2019
EPCDynamicLibrarySearchGenerator.cpp

llvm/lib/ExecutionEngine/Orc/Debugging/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ add_llvm_component_library(LLVMOrcDebugging
66
DebugInfoSupport.cpp
77
DebuggerSupport.cpp
88
DebuggerSupportPlugin.cpp
9+
ELFDebugObjectPlugin.cpp
910
LLJITUtilsCBindings.cpp
1011
PerfSupportPlugin.cpp
1112
VTuneSupportPlugin.cpp

llvm/lib/ExecutionEngine/Orc/Debugging/DebuggerSupport.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
//===----------------------------------------------------------------------===//
88

99
#include "llvm/ExecutionEngine/Orc/Debugging/DebuggerSupport.h"
10-
#include "llvm/ExecutionEngine/Orc/DebugObjectManagerPlugin.h"
1110
#include "llvm/ExecutionEngine/Orc/Debugging/DebuggerSupportPlugin.h"
11+
#include "llvm/ExecutionEngine/Orc/Debugging/ELFDebugObjectPlugin.h"
1212
#include "llvm/ExecutionEngine/Orc/LLJIT.h"
1313

1414
#define DEBUG_TYPE "orc"
@@ -36,8 +36,8 @@ Error enableDebuggerSupport(LLJIT &J) {
3636
switch (TT.getObjectFormat()) {
3737
case Triple::ELF: {
3838
Error TargetSymErr = Error::success();
39-
ObjLinkingLayer->addPlugin(std::make_unique<DebugObjectManagerPlugin>(
40-
ES, false, true, TargetSymErr));
39+
ObjLinkingLayer->addPlugin(
40+
std::make_unique<ELFDebugObjectPlugin>(ES, false, true, TargetSymErr));
4141
return TargetSymErr;
4242
}
4343
case Triple::MachO: {

llvm/lib/ExecutionEngine/Orc/DebugObjectManagerPlugin.cpp renamed to llvm/lib/ExecutionEngine/Orc/Debugging/ELFDebugObjectPlugin.cpp

Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//===------- DebugObjectManagerPlugin.cpp - JITLink debug objects ---------===//
1+
//===------- ELFDebugObjectPlugin.cpp - JITLink debug objects ---------===//
22
//
33
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
44
// See https://llvm.org/LICENSE.txt for license information.
@@ -11,7 +11,7 @@
1111
//
1212
//===----------------------------------------------------------------------===//
1313

14-
#include "llvm/ExecutionEngine/Orc/DebugObjectManagerPlugin.h"
14+
#include "llvm/ExecutionEngine/Orc/Debugging/ELFDebugObjectPlugin.h"
1515

1616
#include "llvm/ADT/ArrayRef.h"
1717
#include "llvm/ADT/StringMap.h"
@@ -406,10 +406,9 @@ createDebugObjectFromBuffer(ExecutionSession &ES, LinkGraph &G,
406406
}
407407
}
408408

409-
DebugObjectManagerPlugin::DebugObjectManagerPlugin(ExecutionSession &ES,
410-
bool RequireDebugSections,
411-
bool AutoRegisterCode,
412-
Error &Err)
409+
ELFDebugObjectPlugin::ELFDebugObjectPlugin(ExecutionSession &ES,
410+
bool RequireDebugSections,
411+
bool AutoRegisterCode, Error &Err)
413412
: ES(ES), RequireDebugSections(RequireDebugSections),
414413
AutoRegisterCode(AutoRegisterCode) {
415414
// Pass bootstrap symbol for registration function to enable debugging
@@ -418,9 +417,9 @@ DebugObjectManagerPlugin::DebugObjectManagerPlugin(ExecutionSession &ES,
418417
{{RegistrationAction, rt::RegisterJITLoaderGDBAllocActionName}});
419418
}
420419

421-
DebugObjectManagerPlugin::~DebugObjectManagerPlugin() = default;
420+
ELFDebugObjectPlugin::~ELFDebugObjectPlugin() = default;
422421

423-
void DebugObjectManagerPlugin::notifyMaterializing(
422+
void ELFDebugObjectPlugin::notifyMaterializing(
424423
MaterializationResponsibility &MR, LinkGraph &G, JITLinkContext &Ctx,
425424
MemoryBufferRef ObjBuffer) {
426425
std::lock_guard<std::mutex> Lock(PendingObjsLock);
@@ -443,9 +442,9 @@ void DebugObjectManagerPlugin::notifyMaterializing(
443442
}
444443
}
445444

446-
void DebugObjectManagerPlugin::modifyPassConfig(
447-
MaterializationResponsibility &MR, LinkGraph &G,
448-
PassConfiguration &PassConfig) {
445+
void ELFDebugObjectPlugin::modifyPassConfig(MaterializationResponsibility &MR,
446+
LinkGraph &G,
447+
PassConfiguration &PassConfig) {
449448
// Not all link artifacts have associated debug objects.
450449
std::lock_guard<std::mutex> Lock(PendingObjsLock);
451450
auto It = PendingObjs.find(&MR);
@@ -507,16 +506,15 @@ void DebugObjectManagerPlugin::modifyPassConfig(
507506
}
508507
}
509508

510-
Error DebugObjectManagerPlugin::notifyFailed(
511-
MaterializationResponsibility &MR) {
509+
Error ELFDebugObjectPlugin::notifyFailed(MaterializationResponsibility &MR) {
512510
std::lock_guard<std::mutex> Lock(PendingObjsLock);
513511
PendingObjs.erase(&MR);
514512
return Error::success();
515513
}
516514

517-
void DebugObjectManagerPlugin::notifyTransferringResources(JITDylib &JD,
518-
ResourceKey DstKey,
519-
ResourceKey SrcKey) {
515+
void ELFDebugObjectPlugin::notifyTransferringResources(JITDylib &JD,
516+
ResourceKey DstKey,
517+
ResourceKey SrcKey) {
520518
// Debug objects are stored by ResourceKey only after registration.
521519
// Thus, pending objects don't need to be updated here.
522520
std::lock_guard<std::mutex> Lock(RegisteredObjsLock);
@@ -530,8 +528,8 @@ void DebugObjectManagerPlugin::notifyTransferringResources(JITDylib &JD,
530528
}
531529
}
532530

533-
Error DebugObjectManagerPlugin::notifyRemovingResources(JITDylib &JD,
534-
ResourceKey Key) {
531+
Error ELFDebugObjectPlugin::notifyRemovingResources(JITDylib &JD,
532+
ResourceKey Key) {
535533
// Removing the resource for a pending object fails materialization, so they
536534
// get cleaned up in the notifyFailed() handler.
537535
std::lock_guard<std::mutex> Lock(RegisteredObjsLock);

llvm/tools/llvm-jitlink/llvm-jitlink.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@
1717
#include "llvm/Config/llvm-config.h" // for LLVM_ON_UNIX, LLVM_ENABLE_THREADS
1818
#include "llvm/ExecutionEngine/Orc/AbsoluteSymbols.h"
1919
#include "llvm/ExecutionEngine/Orc/COFFPlatform.h"
20-
#include "llvm/ExecutionEngine/Orc/DebugObjectManagerPlugin.h"
2120
#include "llvm/ExecutionEngine/Orc/Debugging/DebugInfoSupport.h"
2221
#include "llvm/ExecutionEngine/Orc/Debugging/DebuggerSupportPlugin.h"
22+
#include "llvm/ExecutionEngine/Orc/Debugging/ELFDebugObjectPlugin.h"
2323
#include "llvm/ExecutionEngine/Orc/Debugging/PerfSupportPlugin.h"
2424
#include "llvm/ExecutionEngine/Orc/Debugging/VTuneSupportPlugin.h"
2525
#include "llvm/ExecutionEngine/Orc/EHFrameRegistrationPlugin.h"
@@ -1298,8 +1298,8 @@ Session::Session(std::unique_ptr<ExecutorProcessControl> EPC, Error &Err)
12981298
ObjLayer.addPlugin(ExitOnErr(EHFrameRegistrationPlugin::Create(ES)));
12991299
if (DebuggerSupport) {
13001300
Error TargetSymErr = Error::success();
1301-
auto Plugin = std::make_unique<DebugObjectManagerPlugin>(ES, true, true,
1302-
TargetSymErr);
1301+
auto Plugin =
1302+
std::make_unique<ELFDebugObjectPlugin>(ES, true, true, TargetSymErr);
13031303
if (!TargetSymErr)
13041304
ObjLayer.addPlugin(std::move(Plugin));
13051305
else

llvm/utils/gn/secondary/llvm/lib/ExecutionEngine/Orc/BUILD.gn

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ static_library("Orc") {
2222
"CompileOnDemandLayer.cpp",
2323
"CompileUtils.cpp",
2424
"Core.cpp",
25-
"DebugObjectManagerPlugin.cpp",
25+
"ELFDebugObjectPlugin.cpp",
2626
"DebugUtils.cpp",
2727
"EHFrameRegistrationPlugin.cpp",
2828
"ELFNixPlatform.cpp",

0 commit comments

Comments
 (0)