Skip to content

Commit db5eedd

Browse files
[ORC] Tailor ELF debugger support plugin to load-address patching only (#168518)
In 4 years the ELF debugger support plugin wasn't adapted to other object formats or debugging approaches. After the renaming NFC in #168343, this patch tailors the plugin to ELF and section load-address patching. It allows removal of abstractions and consolidate processing steps with the newly enabled AllocActions from #168343. The key change is to process debug sections in one place in a post-allocation pass. Since we can handle the endianness of the ELF file the single `visitSectionLoadAddresses()` visitor function now, we don't need to track debug objects and sections in template classes anymore. We keep using the `DebugObject` class and drop `DebugObjectSection`, `ELFDebugObjectSection<ELFT>` and `ELFDebugObject`. Furthermore, we now use the allocation's working memory for load-address fixups directly. We can drop the `WritableMemoryBuffer` from the debug object and most of the `finalizeWorkingMemory()` step, which saves one copy of the entire debug object buffer. Inlining `finalizeAsync()` into the pre-fixup pass simplifies quite some logic. We still track `RegisteredObjs` here, because we want to free memory once the corresponding code is freed. There will be a follow-up patch that turns it into a dealloc action.
1 parent 6a5231e commit db5eedd

File tree

2 files changed

+227
-405
lines changed

2 files changed

+227
-405
lines changed

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

Lines changed: 12 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
#include "llvm/Support/MemoryBufferRef.h"
2424
#include "llvm/TargetParser/Triple.h"
2525

26-
#include <functional>
2726
#include <map>
2827
#include <memory>
2928
#include <mutex>
@@ -33,43 +32,32 @@ namespace orc {
3332

3433
class DebugObject;
3534

36-
/// Creates and manages DebugObjects for JITLink artifacts.
37-
///
38-
/// DebugObjects are created when linking for a MaterializationResponsibility
39-
/// starts. They are pending as long as materialization is in progress.
40-
///
41-
/// There can only be one pending DebugObject per MaterializationResponsibility.
42-
/// If materialization fails, pending DebugObjects are discarded.
43-
///
44-
/// Once executable code for the MaterializationResponsibility is emitted, the
45-
/// corresponding DebugObject is finalized to target memory and the provided
46-
/// DebugObjectRegistrar is notified. Ownership of DebugObjects remains with the
47-
/// plugin.
35+
/// Debugger support for ELF platforms with the GDB JIT Interface. The plugin
36+
/// emits and manages a separate debug object allocation in addition to the
37+
/// LinkGraph's own allocation and it notifies the debugger when necessary.
4838
///
4939
class LLVM_ABI ELFDebugObjectPlugin : public ObjectLinkingLayer::Plugin {
5040
public:
51-
/// Create the plugin to submit DebugObjects for JITLink artifacts. For all
52-
/// options the recommended setting is true.
41+
/// Create the plugin for the given session and set additional options
5342
///
5443
/// RequireDebugSections:
55-
/// Submit debug objects to the executor only if they contain actual debug
56-
/// info. Turning this off may allow minimal debugging based on raw symbol
57-
/// names. Note that this may cause significant memory and transport
58-
/// overhead for objects built with a release configuration.
44+
/// Emit debug objects only if the LinkGraph contains debug info. Turning
45+
/// this off allows minimal debugging based on raw symbol names, but it
46+
/// comes with significant overhead for release configurations.
5947
///
6048
/// AutoRegisterCode:
6149
/// Notify the debugger for each new debug object. This is a good default
6250
/// mode, but it may cause significant overhead when adding many modules in
63-
/// sequence. When turning this off, the user has to issue the call to
64-
/// __jit_debug_register_code() on the executor side manually.
51+
/// sequence. Otherwise the user must call __jit_debug_register_code() in
52+
/// the debug session manually.
6553
///
6654
ELFDebugObjectPlugin(ExecutionSession &ES, bool RequireDebugSections,
6755
bool AutoRegisterCode, Error &Err);
6856
~ELFDebugObjectPlugin() override;
6957

7058
void notifyMaterializing(MaterializationResponsibility &MR,
7159
jitlink::LinkGraph &G, jitlink::JITLinkContext &Ctx,
72-
MemoryBufferRef InputObject) override;
60+
MemoryBufferRef InputObj) override;
7361

7462
Error notifyFailed(MaterializationResponsibility &MR) override;
7563
Error notifyRemovingResources(JITDylib &JD, ResourceKey K) override;
@@ -94,6 +82,8 @@ class LLVM_ABI ELFDebugObjectPlugin : public ObjectLinkingLayer::Plugin {
9482
ExecutorAddr RegistrationAction;
9583
bool RequireDebugSections;
9684
bool AutoRegisterCode;
85+
86+
DebugObject *getPendingDebugObj(MaterializationResponsibility &MR);
9787
};
9888

9989
} // namespace orc

0 commit comments

Comments
 (0)