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"
14 #include "llvm/ADT/DenseSet.h"
21 class DWARFDebugAranges {
24 explicit Range(uint64_t lo = -1ULL, uint64_t hi = -1ULL,
26 : LoPC(lo), Length(hi-lo), Offset(off) {}
34 void setHiPC(uint64_t HiPC) {
35 if (HiPC == -1ULL || HiPC <= LoPC)
40 uint64_t HiPC() const {
45 bool isValidRange() const { return Length > 0; }
47 static bool SortedOverlapCheck(const Range &curr_range,
48 const Range &next_range, uint32_t n) {
49 if (curr_range.Offset != next_range.Offset)
51 return curr_range.HiPC() + n >= next_range.LoPC;
54 bool contains(const Range &range) const {
55 return LoPC <= range.LoPC && range.HiPC() <= HiPC();
58 void dump(raw_ostream &OS) const;
59 uint64_t LoPC; // Start of address range
60 uint32_t Length; // End of address range (not including this address)
61 uint32_t Offset; // Offset of the compile unit or die
66 ParsedCUOffsets.clear();
68 bool allRangesAreContiguous(uint64_t& LoPC, uint64_t& HiPC) const;
69 bool getMaxRange(uint64_t& LoPC, uint64_t& HiPC) const;
70 bool extract(DataExtractor debug_aranges_data);
71 bool generate(DWARFContext *ctx);
73 // Use append range multiple times and then call sort
74 void appendRange(uint32_t cu_offset, uint64_t low_pc, uint64_t high_pc);
75 void sort(bool minimize, uint32_t n);
77 const Range *rangeAtIndex(uint32_t idx) const {
78 if (idx < Aranges.size())
82 void dump(raw_ostream &OS) const;
83 uint32_t findAddress(uint64_t address) const;
84 bool isEmpty() const { return Aranges.empty(); }
85 uint32_t getNumRanges() const { return Aranges.size(); }
87 uint32_t offsetAtIndex(uint32_t idx) const {
88 if (idx < Aranges.size())
89 return Aranges[idx].Offset;
93 typedef std::vector<Range> RangeColl;
94 typedef RangeColl::const_iterator RangeCollIterator;
95 typedef DenseSet<uint32_t> ParsedCUOffsetColl;
99 ParsedCUOffsetColl ParsedCUOffsets;