1 //===--- DebugerSupportPlugin.h -- Utils for debugger support ---*- 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 // Generates debug objects and registers them using the jit-loader-gdb protocol. 10 // 11 //===----------------------------------------------------------------------===// 12 13 #ifndef LLVM_EXECUTIONENGINE_ORC_DEBUGGERSUPPORTPLUGIN_H 14 #define LLVM_EXECUTIONENGINE_ORC_DEBUGGERSUPPORTPLUGIN_H 15 16 #include "llvm/ExecutionEngine/Orc/Core.h" 17 #include "llvm/ExecutionEngine/Orc/EPCDebugObjectRegistrar.h" 18 #include "llvm/ExecutionEngine/Orc/ObjectLinkingLayer.h" 19 #include "llvm/Support/Compiler.h" 20 21 namespace llvm { 22 namespace orc { 23 24 /// For each object containing debug info, installs JITLink passes to synthesize 25 /// a debug object and then register it via the GDB JIT-registration interface. 26 /// 27 /// Currently MachO only. For ELF use DebugObjectManagerPlugin. These two 28 /// plugins will be merged in the near future. 29 class LLVM_ABI GDBJITDebugInfoRegistrationPlugin 30 : public ObjectLinkingLayer::Plugin { 31 public: 32 class DebugSectionSynthesizer { 33 public: 34 virtual ~DebugSectionSynthesizer() = default; 35 virtual Error startSynthesis() = 0; 36 virtual Error completeSynthesisAndRegister() = 0; 37 }; 38 39 static Expected<std::unique_ptr<GDBJITDebugInfoRegistrationPlugin>> 40 Create(ExecutionSession &ES, JITDylib &ProcessJD, const Triple &TT); 41 GDBJITDebugInfoRegistrationPlugin(ExecutorAddr RegisterActionAddr)42 GDBJITDebugInfoRegistrationPlugin(ExecutorAddr RegisterActionAddr) 43 : RegisterActionAddr(RegisterActionAddr) {} 44 45 Error notifyFailed(MaterializationResponsibility &MR) override; 46 Error notifyRemovingResources(JITDylib &JD, ResourceKey K) override; 47 48 void notifyTransferringResources(JITDylib &JD, ResourceKey DstKey, 49 ResourceKey SrcKey) override; 50 51 void modifyPassConfig(MaterializationResponsibility &MR, 52 jitlink::LinkGraph &LG, 53 jitlink::PassConfiguration &PassConfig) override; 54 55 private: 56 void modifyPassConfigForMachO(MaterializationResponsibility &MR, 57 jitlink::LinkGraph &LG, 58 jitlink::PassConfiguration &PassConfig); 59 60 ExecutorAddr RegisterActionAddr; 61 }; 62 63 } // namespace orc 64 } // namespace llvm 65 66 #endif // LLVM_EXECUTIONENGINE_ORC_DEBUGGERSUPPORTPLUGIN_H 67