Back to home page

EIC code displayed by LXR

 
 

    


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

0001 //===- DWARFDebugAranges.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_DWARFDEBUGARANGES_H
0010 #define LLVM_DEBUGINFO_DWARF_DWARFDEBUGARANGES_H
0011 
0012 #include "llvm/ADT/DenseSet.h"
0013 #include "llvm/ADT/STLFunctionalExtras.h"
0014 #include <cstdint>
0015 #include <vector>
0016 
0017 namespace llvm {
0018 class DWARFDataExtractor;
0019 class Error;
0020 
0021 class DWARFContext;
0022 
0023 class DWARFDebugAranges {
0024 public:
0025   void generate(DWARFContext *CTX);
0026   uint64_t findAddress(uint64_t Address) const;
0027 
0028 private:
0029   void clear();
0030   void extract(DWARFDataExtractor DebugArangesData,
0031                function_ref<void(Error)> RecoverableErrorHandler,
0032                function_ref<void(Error)> WarningHandler);
0033 
0034   /// Call appendRange multiple times and then call construct.
0035   void appendRange(uint64_t CUOffset, uint64_t LowPC, uint64_t HighPC);
0036   void construct();
0037 
0038   struct Range {
0039     explicit Range(uint64_t LowPC, uint64_t HighPC, uint64_t CUOffset)
0040       : LowPC(LowPC), Length(HighPC - LowPC), CUOffset(CUOffset) {}
0041 
0042     void setHighPC(uint64_t HighPC) {
0043       if (HighPC == -1ULL || HighPC <= LowPC)
0044         Length = 0;
0045       else
0046         Length = HighPC - LowPC;
0047     }
0048 
0049     uint64_t HighPC() const {
0050       if (Length)
0051         return LowPC + Length;
0052       return -1ULL;
0053     }
0054 
0055     bool operator<(const Range &other) const {
0056       return LowPC < other.LowPC;
0057     }
0058 
0059     uint64_t LowPC; /// Start of address range.
0060     uint64_t Length; /// End of address range (not including this address).
0061     uint64_t CUOffset; /// Offset of the compile unit or die.
0062   };
0063 
0064   struct RangeEndpoint {
0065     uint64_t Address;
0066     uint64_t CUOffset;
0067     bool IsRangeStart;
0068 
0069     RangeEndpoint(uint64_t Address, uint64_t CUOffset, bool IsRangeStart)
0070         : Address(Address), CUOffset(CUOffset), IsRangeStart(IsRangeStart) {}
0071 
0072     bool operator<(const RangeEndpoint &Other) const {
0073       return Address < Other.Address;
0074     }
0075   };
0076 
0077   using RangeColl = std::vector<Range>;
0078   using RangeCollIterator = RangeColl::const_iterator;
0079 
0080   std::vector<RangeEndpoint> Endpoints;
0081   RangeColl Aranges;
0082   DenseSet<uint64_t> ParsedCUOffsets;
0083 };
0084 
0085 } // end namespace llvm
0086 
0087 #endif // LLVM_DEBUGINFO_DWARF_DWARFDEBUGARANGES_H