Back to home page

EIC code displayed by LXR

 
 

    


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

0001 //===- DWARFDebugRangeList.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_DWARFDEBUGRANGELIST_H
0010 #define LLVM_DEBUGINFO_DWARF_DWARFDEBUGRANGELIST_H
0011 
0012 #include "llvm/DebugInfo/DWARF/DWARFAddressRange.h"
0013 #include <cstdint>
0014 #include <vector>
0015 
0016 namespace llvm {
0017 
0018 class raw_ostream;
0019 class DWARFDataExtractor;
0020 namespace object {
0021 struct SectionedAddress;
0022 }
0023 
0024 class DWARFDebugRangeList {
0025 public:
0026   struct RangeListEntry {
0027     /// A beginning address offset. This address offset has the size of an
0028     /// address and is relative to the applicable base address of the
0029     /// compilation unit referencing this range list. It marks the beginning
0030     /// of an address range.
0031     uint64_t StartAddress;
0032     /// An ending address offset. This address offset again has the size of
0033     /// an address and is relative to the applicable base address of the
0034     /// compilation unit referencing this range list. It marks the first
0035     /// address past the end of the address range. The ending address must
0036     /// be greater than or equal to the beginning address.
0037     uint64_t EndAddress;
0038     /// A section index this range belongs to.
0039     uint64_t SectionIndex;
0040 
0041     /// The end of any given range list is marked by an end of list entry,
0042     /// which consists of a 0 for the beginning address offset
0043     /// and a 0 for the ending address offset.
0044     bool isEndOfListEntry() const {
0045       return (StartAddress == 0) && (EndAddress == 0);
0046     }
0047 
0048     /// A base address selection entry consists of:
0049     /// 1. The value of the largest representable address offset
0050     /// (for example, 0xffffffff when the size of an address is 32 bits).
0051     /// 2. An address, which defines the appropriate base address for
0052     /// use in interpreting the beginning and ending address offsets of
0053     /// subsequent entries of the location list.
0054     bool isBaseAddressSelectionEntry(uint8_t AddressSize) const;
0055   };
0056 
0057 private:
0058   /// Offset in .debug_ranges section.
0059   uint64_t Offset;
0060   uint8_t AddressSize;
0061   std::vector<RangeListEntry> Entries;
0062 
0063 public:
0064   DWARFDebugRangeList() { clear(); }
0065 
0066   void clear();
0067   void dump(raw_ostream &OS) const;
0068   Error extract(const DWARFDataExtractor &data, uint64_t *offset_ptr);
0069   const std::vector<RangeListEntry> &getEntries() { return Entries; }
0070 
0071   /// getAbsoluteRanges - Returns absolute address ranges defined by this range
0072   /// list. Has to be passed base address of the compile unit referencing this
0073   /// range list.
0074   DWARFAddressRangesVector
0075   getAbsoluteRanges(std::optional<object::SectionedAddress> BaseAddr) const;
0076 };
0077 
0078 } // end namespace llvm
0079 
0080 #endif // LLVM_DEBUGINFO_DWARF_DWARFDEBUGRANGELIST_H