|
7 | 7 | //===----------------------------------------------------------------------===// |
8 | 8 |
|
9 | 9 | #include "DWARFDebugAranges.h" |
10 | | -#include "DWARFDebugArangeSet.h" |
11 | 10 | #include "DWARFUnit.h" |
12 | 11 | #include "LogChannelDWARF.h" |
13 | 12 | #include "lldb/Utility/Log.h" |
14 | 13 | #include "lldb/Utility/Timer.h" |
| 14 | +#include "llvm/DebugInfo/DWARF/DWARFDebugArangeSet.h" |
15 | 15 |
|
16 | 16 | using namespace lldb; |
17 | 17 | using namespace lldb_private; |
18 | 18 | using namespace lldb_private::plugin::dwarf; |
| 19 | +using llvm::DWARFDebugArangeSet; |
19 | 20 |
|
20 | 21 | // Constructor |
21 | 22 | DWARFDebugAranges::DWARFDebugAranges() : m_aranges() {} |
22 | 23 |
|
23 | | -// CountArangeDescriptors |
24 | | -class CountArangeDescriptors { |
25 | | -public: |
26 | | - CountArangeDescriptors(uint32_t &count_ref) : count(count_ref) { |
27 | | - // printf("constructor CountArangeDescriptors()\n"); |
28 | | - } |
29 | | - void operator()(const DWARFDebugArangeSet &set) { |
30 | | - count += set.NumDescriptors(); |
31 | | - } |
32 | | - uint32_t &count; |
33 | | -}; |
34 | | - |
35 | 24 | // Extract |
36 | 25 | void DWARFDebugAranges::extract(const DWARFDataExtractor &debug_aranges_data) { |
| 26 | + llvm::DWARFDataExtractor dwarf_data = debug_aranges_data.GetAsLLVMDWARF(); |
37 | 27 | lldb::offset_t offset = 0; |
38 | 28 |
|
39 | 29 | DWARFDebugArangeSet set; |
40 | 30 | Range range; |
41 | | - while (debug_aranges_data.ValidOffset(offset)) { |
| 31 | + while (dwarf_data.isValidOffset(offset)) { |
42 | 32 | const lldb::offset_t set_offset = offset; |
43 | | - if (llvm::Error error = set.extract(debug_aranges_data, &offset)) { |
| 33 | + if (llvm::Error error = set.extract(dwarf_data, &offset)) { |
44 | 34 | Log *log = GetLog(DWARFLog::DebugInfo); |
45 | 35 | LLDB_LOG_ERROR(log, std::move(error), |
46 | 36 | "DWARFDebugAranges::extract failed to extract " |
47 | 37 | ".debug_aranges set at offset {1:x}: {0}", |
48 | 38 | set_offset); |
49 | | - } else { |
50 | | - const uint32_t num_descriptors = set.NumDescriptors(); |
51 | | - if (num_descriptors > 0) { |
52 | | - const dw_offset_t cu_offset = set.GetHeader().cu_offset; |
53 | | - |
54 | | - for (uint32_t i = 0; i < num_descriptors; ++i) { |
55 | | - const DWARFDebugArangeSet::Descriptor &descriptor = |
56 | | - set.GetDescriptorRef(i); |
57 | | - m_aranges.Append(RangeToDIE::Entry(descriptor.address, |
58 | | - descriptor.length, cu_offset)); |
59 | | - } |
60 | | - } |
| 39 | + set.clear(); |
| 40 | + return; |
| 41 | + } |
| 42 | + const uint64_t cu_offset = set.getCompileUnitDIEOffset(); |
| 43 | + for (const auto &desc : set.descriptors()) { |
| 44 | + if (desc.Length != 0) |
| 45 | + m_aranges.Append( |
| 46 | + RangeToDIE::Entry(desc.Address, desc.Length, cu_offset)); |
61 | 47 | } |
62 | | - // Always use the previous DWARFDebugArangeSet's information to calculate |
63 | | - // the offset of the next DWARFDebugArangeSet in case we entouncter an |
64 | | - // error in the current DWARFDebugArangeSet and our offset position is |
65 | | - // still in the middle of the data. If we do this, we can parse all valid |
66 | | - // DWARFDebugArangeSet objects without returning invalid errors. |
67 | | - offset = set.GetNextOffset(); |
68 | | - set.Clear(); |
69 | 48 | } |
70 | 49 | } |
71 | 50 |
|
|
0 commit comments