Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-05-10 08:43:51

0001 //===--- DebugInfoSupport.h ---- Utils for debug info support ---*- C++ -*-===//
0002 //
0003 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
0004 // See https://llvm.org/LICENSE.txt for license information.
0005 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
0006 //
0007 //===----------------------------------------------------------------------===//
0008 //
0009 // Utilities to preserve and parse debug info from LinkGraphs.
0010 //
0011 //===----------------------------------------------------------------------===//
0012 
0013 #ifndef LLVM_EXECUTIONENGINE_ORC_DEBUGINFOSUPPORT_H
0014 #define LLVM_EXECUTIONENGINE_ORC_DEBUGINFOSUPPORT_H
0015 
0016 #include "llvm/ExecutionEngine/Orc/Core.h"
0017 #include "llvm/ExecutionEngine/Orc/ObjectLinkingLayer.h"
0018 
0019 #include "llvm/DebugInfo/DWARF/DWARFContext.h"
0020 
0021 namespace llvm {
0022 
0023 namespace orc {
0024 
0025 Error preserveDebugSections(jitlink::LinkGraph &G);
0026 // The backing stringmap is also returned, for memory liftime management.
0027 Expected<std::pair<std::unique_ptr<DWARFContext>,
0028                    StringMap<std::unique_ptr<MemoryBuffer>>>>
0029 createDWARFContext(jitlink::LinkGraph &G);
0030 
0031 // Thin wrapper around preserveDebugSections to be used as a standalone plugin.
0032 class DebugInfoPreservationPlugin : public ObjectLinkingLayer::Plugin {
0033 public:
0034   void modifyPassConfig(MaterializationResponsibility &MR,
0035                         jitlink::LinkGraph &LG,
0036                         jitlink::PassConfiguration &PassConfig) override {
0037     PassConfig.PrePrunePasses.push_back(preserveDebugSections);
0038   }
0039 
0040   Error notifyRemovingResources(JITDylib &JD, ResourceKey K) override {
0041     // Do nothing.
0042     return Error::success();
0043   }
0044   Error notifyFailed(MaterializationResponsibility &MR) override {
0045     // Do nothing.
0046     return Error::success();
0047   }
0048   void notifyTransferringResources(JITDylib &JD, ResourceKey DstKey,
0049                                    ResourceKey SrcKey) override {
0050     // Do nothing.
0051   }
0052 
0053   static Expected<std::unique_ptr<DebugInfoPreservationPlugin>> Create() {
0054     return std::make_unique<DebugInfoPreservationPlugin>();
0055   }
0056 };
0057 
0058 } // namespace orc
0059 
0060 } // namespace llvm
0061 
0062 #endif