Back to home page

EIC code displayed by LXR

 
 

    


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

0001 //===- DWARFDebugArangeSet.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_DEBUGINFO_DWARF_DWARFDEBUGARANGESET_H
0010 #define LLVM_DEBUGINFO_DWARF_DWARFDEBUGARANGESET_H
0011 
0012 #include "llvm/ADT/iterator_range.h"
0013 #include "llvm/BinaryFormat/Dwarf.h"
0014 #include "llvm/Support/Error.h"
0015 #include <cstdint>
0016 #include <vector>
0017 
0018 namespace llvm {
0019 
0020 class raw_ostream;
0021 class DWARFDataExtractor;
0022 
0023 class DWARFDebugArangeSet {
0024 public:
0025   struct Header {
0026     /// The total length of the entries for that set, not including the length
0027     /// field itself.
0028     uint64_t Length;
0029     /// The DWARF format of the set.
0030     dwarf::DwarfFormat Format;
0031     /// The offset from the beginning of the .debug_info section of the
0032     /// compilation unit entry referenced by the table.
0033     uint64_t CuOffset;
0034     /// The DWARF version number.
0035     uint16_t Version;
0036     /// The size in bytes of an address on the target architecture. For segmented
0037     /// addressing, this is the size of the offset portion of the address.
0038     uint8_t AddrSize;
0039     /// The size in bytes of a segment descriptor on the target architecture.
0040     /// If the target system uses a flat address space, this value is 0.
0041     uint8_t SegSize;
0042   };
0043 
0044   struct Descriptor {
0045     uint64_t Address;
0046     uint64_t Length;
0047 
0048     uint64_t getEndAddress() const { return Address + Length; }
0049     void dump(raw_ostream &OS, uint32_t AddressSize) const;
0050   };
0051 
0052 private:
0053   using DescriptorColl = std::vector<Descriptor>;
0054   using desc_iterator_range = iterator_range<DescriptorColl::const_iterator>;
0055 
0056   uint64_t Offset;
0057   Header HeaderData;
0058   DescriptorColl ArangeDescriptors;
0059 
0060 public:
0061   DWARFDebugArangeSet() { clear(); }
0062 
0063   void clear();
0064   Error extract(DWARFDataExtractor data, uint64_t *offset_ptr,
0065                 function_ref<void(Error)> WarningHandler = nullptr);
0066   void dump(raw_ostream &OS) const;
0067 
0068   uint64_t getCompileUnitDIEOffset() const { return HeaderData.CuOffset; }
0069 
0070   const Header &getHeader() const { return HeaderData; }
0071 
0072   desc_iterator_range descriptors() const {
0073     return desc_iterator_range(ArangeDescriptors.begin(),
0074                                ArangeDescriptors.end());
0075   }
0076 };
0077 
0078 } // end namespace llvm
0079 
0080 #endif // LLVM_DEBUGINFO_DWARF_DWARFDEBUGARANGESET_H