Skip to content

Commit 4206c37

Browse files
authored
[lldb][DWARF] Replace lldb's DWARFDebugArangeSet with llvm's (#110058)
They are close enough to swap lldb's `DWARFDebugArangeSet` with the llvm one. The difference is that llvm's `DWARFDebugArangeSet` add empty ranges when extracting. To accommodate this, `DWARFDebugAranges` in lldb filters out empty ranges when extracting.
1 parent 47e3d8d commit 4206c37

File tree

7 files changed

+63
-326
lines changed

7 files changed

+63
-326
lines changed

lldb/source/Plugins/SymbolFile/DWARF/CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ add_lldb_library(lldbPluginSymbolFileDWARF PLUGIN
1818
DWARFContext.cpp
1919
DWARFDataExtractor.cpp
2020
DWARFDebugAranges.cpp
21-
DWARFDebugArangeSet.cpp
2221
DWARFDebugInfo.cpp
2322
DWARFDebugInfoEntry.cpp
2423
DWARFDebugMacro.cpp

lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugArangeSet.cpp

Lines changed: 0 additions & 176 deletions
This file was deleted.

lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugArangeSet.h

Lines changed: 0 additions & 70 deletions
This file was deleted.

lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugAranges.cpp

Lines changed: 13 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -7,65 +7,44 @@
77
//===----------------------------------------------------------------------===//
88

99
#include "DWARFDebugAranges.h"
10-
#include "DWARFDebugArangeSet.h"
1110
#include "DWARFUnit.h"
1211
#include "LogChannelDWARF.h"
1312
#include "lldb/Utility/Log.h"
1413
#include "lldb/Utility/Timer.h"
14+
#include "llvm/DebugInfo/DWARF/DWARFDebugArangeSet.h"
1515

1616
using namespace lldb;
1717
using namespace lldb_private;
1818
using namespace lldb_private::plugin::dwarf;
19+
using llvm::DWARFDebugArangeSet;
1920

2021
// Constructor
2122
DWARFDebugAranges::DWARFDebugAranges() : m_aranges() {}
2223

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-
3524
// Extract
3625
void DWARFDebugAranges::extract(const DWARFDataExtractor &debug_aranges_data) {
26+
llvm::DWARFDataExtractor dwarf_data = debug_aranges_data.GetAsLLVMDWARF();
3727
lldb::offset_t offset = 0;
3828

3929
DWARFDebugArangeSet set;
4030
Range range;
41-
while (debug_aranges_data.ValidOffset(offset)) {
31+
while (dwarf_data.isValidOffset(offset)) {
4232
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)) {
4434
Log *log = GetLog(DWARFLog::DebugInfo);
4535
LLDB_LOG_ERROR(log, std::move(error),
4636
"DWARFDebugAranges::extract failed to extract "
4737
".debug_aranges set at offset {1:x}: {0}",
4838
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));
6147
}
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();
6948
}
7049
}
7150

0 commit comments

Comments
 (0)