Back to home page

EIC code displayed by LXR

 
 

    


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

0001 //===- DWARFFile.h ----------------------------------------------*- 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 #ifndef LLVM_DWARFLINKER_DWARFFILE_H
0010 #define LLVM_DWARFLINKER_DWARFFILE_H
0011 
0012 #include "AddressesMap.h"
0013 #include "llvm/ADT/StringRef.h"
0014 #include "llvm/DebugInfo/DWARF/DWARFContext.h"
0015 #include <functional>
0016 #include <memory>
0017 
0018 namespace llvm {
0019 namespace dwarf_linker {
0020 
0021 /// This class represents DWARF information for source file
0022 /// and it's address map.
0023 ///
0024 /// May be used asynchroniously for reading.
0025 class DWARFFile {
0026 public:
0027   using UnloadCallbackTy = std::function<void(StringRef FileName)>;
0028 
0029   DWARFFile(StringRef Name, std::unique_ptr<DWARFContext> Dwarf,
0030             std::unique_ptr<AddressesMap> Addresses,
0031             UnloadCallbackTy UnloadFunc = nullptr)
0032       : FileName(Name), Dwarf(std::move(Dwarf)),
0033         Addresses(std::move(Addresses)), UnloadFunc(UnloadFunc) {}
0034 
0035   /// Object file name.
0036   StringRef FileName;
0037 
0038   /// Source DWARF information.
0039   std::unique_ptr<DWARFContext> Dwarf;
0040 
0041   /// Helpful address information(list of valid address ranges, relocations).
0042   std::unique_ptr<AddressesMap> Addresses;
0043 
0044   /// Callback to the module keeping object file to unload.
0045   UnloadCallbackTy UnloadFunc;
0046 
0047   /// Unloads object file and corresponding AddressesMap and Dwarf Context.
0048   void unload() {
0049     Addresses.reset();
0050     Dwarf.reset();
0051 
0052     if (UnloadFunc)
0053       UnloadFunc(FileName);
0054   }
0055 };
0056 
0057 } // namespace dwarf_linker
0058 } // end namespace llvm
0059 
0060 #endif // LLVM_DWARFLINKER_DWARFFILE_H