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 <map>
27#include <memory>
28#include <mutex>
29
30namespace llvm {
31namespace orc {
32
33class DebugObject;
34
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.
38///
40public:
41 /// Create the plugin for the given session and set additional options
42 ///
43 /// RequireDebugSections:
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.
47 ///
48 /// AutoRegisterCode:
49 /// Notify the debugger for each new debug object. This is a good default
50 /// mode, but it may cause significant overhead when adding many modules in
51 /// sequence. Otherwise the user must call __jit_debug_register_code() in
52 /// the debug session manually.
53 ///
54 ELFDebugObjectPlugin(ExecutionSession &ES, bool RequireDebugSections,
55 bool AutoRegisterCode, Error &Err);
57
60 MemoryBufferRef InputObj) override;
61
64
66 ResourceKey SrcKey) override;
67
70 jitlink::PassConfiguration &PassConfig) override;
71
72private:
74
75 using OwnedDebugObject = std::unique_ptr<DebugObject>;
76 std::map<MaterializationResponsibility *, OwnedDebugObject> PendingObjs;
77 std::map<ResourceKey, std::vector<OwnedDebugObject>> RegisteredObjs;
78
79 std::mutex PendingObjsLock;
80 std::mutex RegisteredObjsLock;
81
82 ExecutorAddr RegistrationAction;
83 bool RequireDebugSections;
84 bool AutoRegisterCode;
85
86 DebugObject *getPendingDebugObj(MaterializationResponsibility &MR);
87};
88
89} // namespace orc
90} // namespace llvm
91
92#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
Error notifyFailed(MaterializationResponsibility &MR) override
void notifyTransferringResources(JITDylib &JD, ResourceKey DstKey, ResourceKey SrcKey) override
void notifyMaterializing(MaterializationResponsibility &MR, jitlink::LinkGraph &G, jitlink::JITLinkContext &Ctx, MemoryBufferRef InputObj) override
ELFDebugObjectPlugin(ExecutionSession &ES, bool RequireDebugSections, bool AutoRegisterCode, Error &Err)
Create the plugin for the given session and set additional options.
Error notifyRemovingResources(JITDylib &JD, ResourceKey K) override
void modifyPassConfig(MaterializationResponsibility &MR, jitlink::LinkGraph &LG, jitlink::PassConfiguration &PassConfig) 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.