xref: /openbsd-src/gnu/llvm/llvm/include/llvm/ExecutionEngine/Orc/DebuggerSupportPlugin.h (revision d415bd752c734aee168c4ee86ff32e8cc249eb16)
1*d415bd75Srobert //===--- DebugerSupportPlugin.h -- Utils for debugger support ---*- C++ -*-===//
2*d415bd75Srobert //
3*d415bd75Srobert // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4*d415bd75Srobert // See https://llvm.org/LICENSE.txt for license information.
5*d415bd75Srobert // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6*d415bd75Srobert //
7*d415bd75Srobert //===----------------------------------------------------------------------===//
8*d415bd75Srobert //
9*d415bd75Srobert // Generates debug objects and registers them using the jit-loader-gdb protocol.
10*d415bd75Srobert //
11*d415bd75Srobert //===----------------------------------------------------------------------===//
12*d415bd75Srobert 
13*d415bd75Srobert #ifndef LLVM_EXECUTIONENGINE_ORC_DEBUGGERSUPPORTPLUGIN_H
14*d415bd75Srobert #define LLVM_EXECUTIONENGINE_ORC_DEBUGGERSUPPORTPLUGIN_H
15*d415bd75Srobert 
16*d415bd75Srobert #include "llvm/ExecutionEngine/Orc/Core.h"
17*d415bd75Srobert #include "llvm/ExecutionEngine/Orc/EPCDebugObjectRegistrar.h"
18*d415bd75Srobert #include "llvm/ExecutionEngine/Orc/ObjectLinkingLayer.h"
19*d415bd75Srobert 
20*d415bd75Srobert namespace llvm {
21*d415bd75Srobert namespace orc {
22*d415bd75Srobert 
23*d415bd75Srobert /// For each object containing debug info, installs JITLink passes to synthesize
24*d415bd75Srobert /// a debug object and then register it via the GDB JIT-registration interface.
25*d415bd75Srobert ///
26*d415bd75Srobert /// Currently MachO only. For ELF use DebugObjectManagerPlugin. These two
27*d415bd75Srobert /// plugins will be merged in the near future.
28*d415bd75Srobert class GDBJITDebugInfoRegistrationPlugin : public ObjectLinkingLayer::Plugin {
29*d415bd75Srobert public:
30*d415bd75Srobert   class DebugSectionSynthesizer {
31*d415bd75Srobert   public:
32*d415bd75Srobert     virtual ~DebugSectionSynthesizer() = default;
33*d415bd75Srobert     virtual Error startSynthesis() = 0;
34*d415bd75Srobert     virtual Error completeSynthesisAndRegister() = 0;
35*d415bd75Srobert   };
36*d415bd75Srobert 
37*d415bd75Srobert   static Expected<std::unique_ptr<GDBJITDebugInfoRegistrationPlugin>>
38*d415bd75Srobert   Create(ExecutionSession &ES, JITDylib &ProcessJD, const Triple &TT);
39*d415bd75Srobert 
GDBJITDebugInfoRegistrationPlugin(ExecutorAddr RegisterActionAddr)40*d415bd75Srobert   GDBJITDebugInfoRegistrationPlugin(ExecutorAddr RegisterActionAddr)
41*d415bd75Srobert       : RegisterActionAddr(RegisterActionAddr) {}
42*d415bd75Srobert 
43*d415bd75Srobert   Error notifyFailed(MaterializationResponsibility &MR) override;
44*d415bd75Srobert   Error notifyRemovingResources(JITDylib &JD, ResourceKey K) override;
45*d415bd75Srobert 
46*d415bd75Srobert   void notifyTransferringResources(JITDylib &JD, ResourceKey DstKey,
47*d415bd75Srobert                                    ResourceKey SrcKey) override;
48*d415bd75Srobert 
49*d415bd75Srobert   void modifyPassConfig(MaterializationResponsibility &MR,
50*d415bd75Srobert                         jitlink::LinkGraph &LG,
51*d415bd75Srobert                         jitlink::PassConfiguration &PassConfig) override;
52*d415bd75Srobert 
53*d415bd75Srobert private:
54*d415bd75Srobert   void modifyPassConfigForMachO(MaterializationResponsibility &MR,
55*d415bd75Srobert                                 jitlink::LinkGraph &LG,
56*d415bd75Srobert                                 jitlink::PassConfiguration &PassConfig);
57*d415bd75Srobert 
58*d415bd75Srobert   ExecutorAddr RegisterActionAddr;
59*d415bd75Srobert };
60*d415bd75Srobert 
61*d415bd75Srobert } // namespace orc
62*d415bd75Srobert } // namespace llvm
63*d415bd75Srobert 
64*d415bd75Srobert #endif // LLVM_EXECUTIONENGINE_ORC_DEBUGGERSUPPORTPLUGIN_H
65