LLVM 22.0.0git
DebugObjectManagerPlugin.h
Go to the documentation of this file.
1//===---- DebugObjectManagerPlugin.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_DEBUGOBJECTMANAGERPLUGIN_H
14#define LLVM_EXECUTIONENGINE_ORC_DEBUGOBJECTMANAGERPLUGIN_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 // DEPRECATED - Please specify options explicitly
53 std::unique_ptr<DebugObjectRegistrar> Target);
54
55 /// Create the plugin to submit DebugObjects for JITLink artifacts. For all
56 /// options the recommended setting is true.
57 ///
58 /// RequireDebugSections:
59 /// Submit debug objects to the executor only if they contain actual debug
60 /// info. Turning this off may allow minimal debugging based on raw symbol
61 /// names. Note that this may cause significant memory and transport
62 /// overhead for objects built with a release configuration.
63 ///
64 /// AutoRegisterCode:
65 /// Notify the debugger for each new debug object. This is a good default
66 /// mode, but it may cause significant overhead when adding many modules in
67 /// sequence. When turning this off, the user has to issue the call to
68 /// __jit_debug_register_code() on the executor side manually.
69 ///
71 std::unique_ptr<DebugObjectRegistrar> Target,
72 bool RequireDebugSections, bool AutoRegisterCode);
74
77 MemoryBufferRef InputObject) override;
78
82
84 ResourceKey SrcKey) override;
85
88 jitlink::PassConfiguration &PassConfig) override;
89
90private:
92
93 using OwnedDebugObject = std::unique_ptr<DebugObject>;
94 std::map<MaterializationResponsibility *, OwnedDebugObject> PendingObjs;
95 std::map<ResourceKey, std::vector<OwnedDebugObject>> RegisteredObjs;
96
97 std::mutex PendingObjsLock;
98 std::mutex RegisteredObjsLock;
99
100 std::unique_ptr<DebugObjectRegistrar> Target;
101 bool RequireDebugSections;
102 bool AutoRegisterCode;
103};
104
105} // namespace orc
106} // namespace llvm
107
108#endif // LLVM_EXECUTIONENGINE_ORC_DEBUGOBJECTMANAGERPLUGIN_H
#define LLVM_ABI
Definition Compiler.h:213
#define G(x, y, z)
Definition MD5.cpp:56
Lightweight error class with error context and mandatory checking.
Definition Error.h:159
Error notifyRemovingResources(JITDylib &JD, ResourceKey K) override
void notifyTransferringResources(JITDylib &JD, ResourceKey DstKey, ResourceKey SrcKey) override
Error notifyFailed(MaterializationResponsibility &MR) override
Error notifyEmitted(MaterializationResponsibility &MR) override
void notifyMaterializing(MaterializationResponsibility &MR, jitlink::LinkGraph &G, jitlink::JITLinkContext &Ctx, MemoryBufferRef InputObject) override
void modifyPassConfig(MaterializationResponsibility &MR, jitlink::LinkGraph &LG, jitlink::PassConfiguration &PassConfig) override
DebugObjectManagerPlugin(ExecutionSession &ES, std::unique_ptr< DebugObjectRegistrar > Target)
The plugin creates a debug object from when JITLink starts processing the corresponding LinkGraph.
An ExecutionSession represents a running JIT program.
Definition Core.h:1355
Represents a JIT'd dynamic library.
Definition Core.h:902
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:576
uintptr_t ResourceKey
Definition Core.h:75
This is an optimization pass for GlobalISel generic memory operations.