LLVM  14.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 
16 #include "llvm/ADT/Triple.h"
21 #include "llvm/Support/Error.h"
22 #include "llvm/Support/Memory.h"
24 
25 #include <functional>
26 #include <map>
27 #include <memory>
28 #include <mutex>
29 
30 namespace llvm {
31 namespace orc {
32 
33 class DebugObject;
34 
35 /// Creates and manages DebugObjects for JITLink artifacts.
36 ///
37 /// DebugObjects are created when linking for a MaterializationResponsibility
38 /// starts. They are pending as long as materialization is in progress.
39 ///
40 /// There can only be one pending DebugObject per MaterializationResponsibility.
41 /// If materialization fails, pending DebugObjects are discarded.
42 ///
43 /// Once executable code for the MaterializationResponsibility is emitted, the
44 /// corresponding DebugObject is finalized to target memory and the provided
45 /// DebugObjectRegistrar is notified. Ownership of DebugObjects remains with the
46 /// plugin.
47 ///
49 public:
51  std::unique_ptr<DebugObjectRegistrar> Target);
53 
56  MemoryBufferRef InputObject) override;
57 
61 
63  ResourceKey SrcKey) override;
64 
67  jitlink::PassConfiguration &PassConfig) override;
68 
69 private:
70  ExecutionSession &ES;
71 
72  using OwnedDebugObject = std::unique_ptr<DebugObject>;
73  std::map<MaterializationResponsibility *, OwnedDebugObject> PendingObjs;
74  std::map<ResourceKey, std::vector<OwnedDebugObject>> RegisteredObjs;
75 
76  std::mutex PendingObjsLock;
77  std::mutex RegisteredObjsLock;
78 
79  std::unique_ptr<DebugObjectRegistrar> Target;
80 };
81 
82 } // namespace orc
83 } // namespace llvm
84 
85 #endif // LLVM_EXECUTIONENGINE_ORC_DEBUGOBJECTMANAGERPLUGIN_H
llvm::orc::ResourceKey
uintptr_t ResourceKey
Definition: Core.h:50
llvm::orc::MaterializationResponsibility
Tracks responsibility for materialization, and mediates interactions between MaterializationUnits and...
Definition: Core.h:520
llvm
This file implements support for optimizing divisions by a constant.
Definition: AllocatorList.h:23
llvm::orc::DebugObjectManagerPlugin::~DebugObjectManagerPlugin
~DebugObjectManagerPlugin()
llvm::Target
Target - Wrapper for Target specific information.
Definition: TargetRegistry.h:137
Error.h
MemoryBufferRef.h
llvm::orc::DebugObjectManagerPlugin::notifyFailed
Error notifyFailed(MaterializationResponsibility &MR) override
Definition: DebugObjectManagerPlugin.cpp:483
llvm::MemoryBufferRef
Definition: MemoryBufferRef.h:22
EPCDebugObjectRegistrar.h
G
const DataFlowGraph & G
Definition: RDFGraph.cpp:202
llvm::orc::DebugObjectManagerPlugin::notifyEmitted
Error notifyEmitted(MaterializationResponsibility &MR) override
Definition: DebugObjectManagerPlugin.cpp:444
llvm::orc::DebugObjectManagerPlugin::DebugObjectManagerPlugin
DebugObjectManagerPlugin(ExecutionSession &ES, std::unique_ptr< DebugObjectRegistrar > Target)
Definition: DebugObjectManagerPlugin.cpp:400
llvm::orc::DebugObjectManagerPlugin
Creates and manages DebugObjects for JITLink artifacts.
Definition: DebugObjectManagerPlugin.h:48
llvm::orc::DebugObjectManagerPlugin::notifyRemovingResources
Error notifyRemovingResources(ResourceKey K) override
Definition: DebugObjectManagerPlugin.cpp:505
Triple.h
Memory.h
llvm::orc::DebugObjectManagerPlugin::notifyMaterializing
void notifyMaterializing(MaterializationResponsibility &MR, jitlink::LinkGraph &G, jitlink::JITLinkContext &Ctx, MemoryBufferRef InputObject) override
Definition: DebugObjectManagerPlugin.cpp:406
llvm::Error
Lightweight error class with error context and mandatory checking.
Definition: Error.h:157
llvm::orc::ExecutionSession
An ExecutionSession represents a running JIT program.
Definition: Core.h:1275
llvm::orc::DebugObjectManagerPlugin::notifyTransferringResources
void notifyTransferringResources(ResourceKey DstKey, ResourceKey SrcKey) override
Definition: DebugObjectManagerPlugin.cpp:490
llvm::orc::DebugObjectManagerPlugin::modifyPassConfig
void modifyPassConfig(MaterializationResponsibility &MR, jitlink::LinkGraph &LG, jitlink::PassConfiguration &PassConfig) override
Definition: DebugObjectManagerPlugin.cpp:423
Core.h
llvm::orc::ObjectLinkingLayer::Plugin
Plugin instances can be added to the ObjectLinkingLayer to receive callbacks when code is loaded or e...
Definition: ObjectLinkingLayer.h:64
ObjectLinkingLayer.h