1 //===-- DWARFDebugAranges.h -------------------------------------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 #ifndef LLVM_DEBUGINFO_DWARFDEBUGARANGES_H
11 #define LLVM_DEBUGINFO_DWARFDEBUGARANGES_H
13 #include "DWARFDebugArangeSet.h"
20 class DWARFDebugAranges {
23 explicit Range(uint64_t lo = -1ULL, uint64_t hi = -1ULL,
25 : LoPC(lo), Length(hi-lo), Offset(off) {}
33 void setHiPC(uint64_t HiPC) {
34 if (HiPC == -1ULL || HiPC <= LoPC)
39 uint64_t HiPC() const {
44 bool isValidRange() const { return Length > 0; }
46 static bool SortedOverlapCheck(const Range &curr_range,
47 const Range &next_range, uint32_t n) {
48 if (curr_range.Offset != next_range.Offset)
50 return curr_range.HiPC() + n >= next_range.LoPC;
53 bool contains(const Range &range) const {
54 return LoPC <= range.LoPC && range.HiPC() <= HiPC();
57 void dump(raw_ostream &OS) const;
58 uint64_t LoPC; // Start of address range
59 uint32_t Length; // End of address range (not including this address)
60 uint32_t Offset; // Offset of the compile unit or die
63 void clear() { Aranges.clear(); }
64 bool allRangesAreContiguous(uint64_t& LoPC, uint64_t& HiPC) const;
65 bool getMaxRange(uint64_t& LoPC, uint64_t& HiPC) const;
66 bool extract(DataExtractor debug_aranges_data);
68 // Use append range multiple times and then call sort
69 void appendRange(uint32_t cu_offset, uint64_t low_pc, uint64_t high_pc);
70 void sort(bool minimize, uint32_t n);
72 const Range *rangeAtIndex(uint32_t idx) const {
73 if (idx < Aranges.size())
77 void dump(raw_ostream &OS) const;
78 uint32_t findAddress(uint64_t address) const;
79 bool isEmpty() const { return Aranges.empty(); }
80 uint32_t getNumRanges() const { return Aranges.size(); }
82 uint32_t offsetAtIndex(uint32_t idx) const {
83 if (idx < Aranges.size())
84 return Aranges[idx].Offset;
88 typedef std::vector<Range> RangeColl;
89 typedef RangeColl::const_iterator RangeCollIterator;