llvm.org GIT mirror llvm / 9e189f1
DWARFDebugArangeSet: remove dead code git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@193785 91177308-0d34-0410-b5e6-96231b3b80d8 Alexey Samsonov 5 years ago
2 changed file(s) with 0 addition(s) and 54 deletion(s). Raw diff Collapse all Expand all
1717 Offset = -1U;
1818 std::memset(&HeaderData, 0, sizeof(Header));
1919 ArangeDescriptors.clear();
20 }
21
22 void DWARFDebugArangeSet::compact() {
23 if (ArangeDescriptors.empty())
24 return;
25
26 // Iterate through all arange descriptors and combine any ranges that
27 // overlap or have matching boundaries. The ArangeDescriptors are assumed
28 // to be in ascending order.
29 uint32_t i = 0;
30 while (i + 1 < ArangeDescriptors.size()) {
31 if (ArangeDescriptors[i].getEndAddress() >= ArangeDescriptors[i+1].Address){
32 // The current range ends at or exceeds the start of the next address
33 // range. Compute the max end address between the two and use that to
34 // make the new length.
35 const uint64_t max_end_addr =
36 std::max(ArangeDescriptors[i].getEndAddress(),
37 ArangeDescriptors[i+1].getEndAddress());
38 ArangeDescriptors[i].Length = max_end_addr - ArangeDescriptors[i].Address;
39 // Now remove the next entry as it was just combined with the previous one
40 ArangeDescriptors.erase(ArangeDescriptors.begin()+i+1);
41 } else {
42 // Discontiguous address range, just proceed to the next one.
43 ++i;
44 }
45 }
4620 }
4721
4822 bool
12599 << format(" 0x%*.*" PRIx64 ")\n",
126100 hex_width, hex_width, pos->getEndAddress());
127101 }
128
129
130 namespace {
131 class DescriptorContainsAddress {
132 const uint64_t Address;
133 public:
134 DescriptorContainsAddress(uint64_t address) : Address(address) {}
135 bool operator()(const DWARFDebugArangeSet::Descriptor &desc) const {
136 return Address >= desc.Address && Address < (desc.Address + desc.Length);
137 }
138 };
139 }
140
141 uint32_t DWARFDebugArangeSet::findAddress(uint64_t address) const {
142 DescriptorConstIter end = ArangeDescriptors.end();
143 DescriptorConstIter pos =
144 std::find_if(ArangeDescriptors.begin(), end, // Range
145 DescriptorContainsAddress(address)); // Predicate
146 if (pos != end)
147 return HeaderData.CuOffset;
148
149 return -1U;
150 }
4343
4444 private:
4545 typedef std::vector DescriptorColl;
46 typedef DescriptorColl::iterator DescriptorIter;
4746 typedef DescriptorColl::const_iterator DescriptorConstIter;
4847
4948 uint32_t Offset;
5352 public:
5453 DWARFDebugArangeSet() { clear(); }
5554 void clear();
56 void compact();
5755 bool extract(DataExtractor data, uint32_t *offset_ptr);
5856 void dump(raw_ostream &OS) const;
5957
6058 uint32_t getCompileUnitDIEOffset() const { return HeaderData.CuOffset; }
61 uint32_t getOffsetOfNextEntry() const { return Offset + HeaderData.Length + 4; }
62 uint32_t findAddress(uint64_t address) const;
6359 uint32_t getNumDescriptors() const { return ArangeDescriptors.size(); }
64 const struct Header &getHeader() const { return HeaderData; }
6560 const Descriptor *getDescriptor(uint32_t i) const {
6661 if (i < ArangeDescriptors.size())
6762 return &ArangeDescriptors[i];