LLVM 22.0.0git
ELFDebugObjectPlugin.h
Go to the documentation of this file.
1//===------ ELFDebugObjectPlugin.h - JITLink debug objects ------*- C++ -*-===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8//
9// ObjectLinkingLayer plugin for emitting debug objects.
10//
11//===----------------------------------------------------------------------===//
12
13#ifndef LLVM_EXECUTIONENGINE_ORC_ELFDEBUGOBJECTPLUGIN_H
14#define LLVM_EXECUTIONENGINE_ORC_ELFDEBUGOBJECTPLUGIN_H
15
21#include "llvm/Support/Error.h"
22#include "llvm/Support/Memory.h"
25
26#include <functional>
27#include <map>
28#include <memory>
29#include <mutex>
30
31namespace llvm {
32namespace orc {
33
34class DebugObject;
35
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.
48///
50public:
51 /// Create the plugin to submit DebugObjects for JITLink artifacts. For all
52 /// options the recommended setting is true.
53 ///
54 /// 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.
59 ///
60 /// AutoRegisterCode:
61 /// Notify the debugger for each new debug object. This is a good default
62 /// 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.
65 ///
66 ELFDebugObjectPlugin(ExecutionSession &ES, bool RequireDebugSections,
67 bool AutoRegisterCode, Error &Err);
69
72 MemoryBufferRef InputObject) override;
73
76
78 ResourceKey SrcKey) override;
79
82 jitlink::PassConfiguration &PassConfig) override;
83
84private:
86
87 using OwnedDebugObject = std::unique_ptr<DebugObject>;
88 std::map<MaterializationResponsibility *, OwnedDebugObject> PendingObjs;
89 std::map<ResourceKey, std::vector<OwnedDebugObject>> RegisteredObjs;
90
91 std::mutex PendingObjsLock;
92 std::mutex RegisteredObjsLock;
93
94 ExecutorAddr RegistrationAction;
95 bool RequireDebugSections;
96 bool AutoRegisterCode;
97};
98
99} // namespace orc
100} // namespace llvm
101
102#endif // LLVM_EXECUTIONENGINE_ORC_ELFDEBUGOBJECTPLUGIN_H
#define LLVM_ABI
Definition Compiler.h:213
#define G(x, y, z)
Definition MD5.cpp:55
Lightweight error class with error context and mandatory checking.
Definition Error.h:159
The plugin creates a debug object from when JITLink starts processing the corresponding LinkGraph.
Error notifyFailed(MaterializationResponsibility &MR) override
void notifyTransferringResources(JITDylib &JD, ResourceKey DstKey, ResourceKey SrcKey) override
ELFDebugObjectPlugin(ExecutionSession &ES, bool RequireDebugSections, bool AutoRegisterCode, Error &Err)
Create the plugin to submit DebugObjects for JITLink artifacts.
Error notifyRemovingResources(JITDylib &JD, ResourceKey K) override
void modifyPassConfig(MaterializationResponsibility &MR, jitlink::LinkGraph &LG, jitlink::PassConfiguration &PassConfig) override
void notifyMaterializing(MaterializationResponsibility &MR, jitlink::LinkGraph &G, jitlink::JITLinkContext &Ctx, MemoryBufferRef InputObject) override
An ExecutionSession represents a running JIT program.
Definition Core.h:1342
Represents an address in the executor process.
Represents a JIT'd dynamic library.
Definition Core.h:906
Plugin instances can be added to the ObjectLinkingLayer to receive callbacks when code is loaded or e...
Tracks responsibility for materialization, and mediates interactions between MaterializationUnits and...
Definition Core.h:580
uintptr_t ResourceKey
Definition Core.h:79
This is an optimization pass for GlobalISel generic memory operations.