Skip to content

Commit f33f181

Browse files
committed
DWARF: Port debug_addr over to DWARFContext
llvm-svn: 361232
1 parent ec767b0 commit f33f181

9 files changed

+20
-48
lines changed

lldb/source/Expression/DWARFExpression.cpp

+7-24
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,10 @@ ReadAddressFromDebugAddrSection(const DWARFUnit *dwarf_cu,
4646
uint32_t index_size = dwarf_cu->GetAddressByteSize();
4747
dw_offset_t addr_base = dwarf_cu->GetAddrBase();
4848
lldb::offset_t offset = addr_base + index * index_size;
49-
return dwarf_cu->GetSymbolFileDWARF()->get_debug_addr_data().GetMaxU64(
50-
&offset, index_size);
49+
return dwarf_cu->GetSymbolFileDWARF()
50+
->GetDWARFContext()
51+
.getOrLoadAddrData()
52+
.GetMaxU64(&offset, index_size);
5153
}
5254

5355
// DWARFExpression constructor
@@ -2813,12 +2815,7 @@ bool DWARFExpression::Evaluate(
28132815
return false;
28142816
}
28152817
uint64_t index = opcodes.GetULEB128(&offset);
2816-
uint32_t index_size = dwarf_cu->GetAddressByteSize();
2817-
dw_offset_t addr_base = dwarf_cu->GetAddrBase();
2818-
lldb::offset_t offset = addr_base + index * index_size;
2819-
uint64_t value =
2820-
dwarf_cu->GetSymbolFileDWARF()->get_debug_addr_data().GetMaxU64(
2821-
&offset, index_size);
2818+
lldb::addr_t value = ReadAddressFromDebugAddrSection(dwarf_cu, index);
28222819
stack.push_back(Scalar(value));
28232820
stack.back().SetValueType(Value::eValueTypeFileAddress);
28242821
} break;
@@ -2838,22 +2835,8 @@ bool DWARFExpression::Evaluate(
28382835
return false;
28392836
}
28402837
uint64_t index = opcodes.GetULEB128(&offset);
2841-
uint32_t index_size = dwarf_cu->GetAddressByteSize();
2842-
dw_offset_t addr_base = dwarf_cu->GetAddrBase();
2843-
lldb::offset_t offset = addr_base + index * index_size;
2844-
const DWARFDataExtractor &debug_addr =
2845-
dwarf_cu->GetSymbolFileDWARF()->get_debug_addr_data();
2846-
switch (index_size) {
2847-
case 4:
2848-
stack.push_back(Scalar(debug_addr.GetU32(&offset)));
2849-
break;
2850-
case 8:
2851-
stack.push_back(Scalar(debug_addr.GetU64(&offset)));
2852-
break;
2853-
default:
2854-
assert(false && "Unhandled index size");
2855-
return false;
2856-
}
2838+
lldb::addr_t value = ReadAddressFromDebugAddrSection(dwarf_cu, index);
2839+
stack.push_back(Scalar(value));
28572840
} break;
28582841

28592842
default:

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

+5
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,11 @@ const DWARFDataExtractor &DWARFContext::getOrLoadArangesData() {
4848
m_data_debug_aranges);
4949
}
5050

51+
const DWARFDataExtractor &DWARFContext::getOrLoadAddrData() {
52+
return LoadOrGetSection(m_main_section_list, eSectionTypeDWARFDebugAddr,
53+
m_data_debug_addr);
54+
}
55+
5156
const DWARFDataExtractor &DWARFContext::getOrLoadDebugInfoData() {
5257
if (isDwo())
5358
return LoadOrGetSection(m_dwo_section_list, eSectionTypeDWARFDebugInfoDwo,

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

+2
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ class DWARFContext {
2121
SectionList *m_dwo_section_list;
2222

2323
llvm::Optional<DWARFDataExtractor> m_data_debug_abbrev;
24+
llvm::Optional<DWARFDataExtractor> m_data_debug_addr;
2425
llvm::Optional<DWARFDataExtractor> m_data_debug_aranges;
2526
llvm::Optional<DWARFDataExtractor> m_data_debug_info;
2627
llvm::Optional<DWARFDataExtractor> m_data_debug_line;
@@ -38,6 +39,7 @@ class DWARFContext {
3839
m_dwo_section_list(dwo_section_list) {}
3940

4041
const DWARFDataExtractor &getOrLoadAbbrevData();
42+
const DWARFDataExtractor &getOrLoadAddrData();
4143
const DWARFDataExtractor &getOrLoadArangesData();
4244
const DWARFDataExtractor &getOrLoadDebugInfoData();
4345
const DWARFDataExtractor &getOrLoadLineData();

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

+4-2
Original file line numberDiff line numberDiff line change
@@ -204,8 +204,10 @@ static uint64_t ReadAddressFromDebugAddrSection(const DWARFUnit *cu,
204204
uint32_t index_size = cu->GetAddressByteSize();
205205
dw_offset_t addr_base = cu->GetAddrBase();
206206
lldb::offset_t offset = addr_base + index * index_size;
207-
return cu->GetSymbolFileDWARF()->get_debug_addr_data().GetMaxU64(&offset,
208-
index_size);
207+
return cu->GetSymbolFileDWARF()
208+
->GetDWARFContext()
209+
.getOrLoadAddrData()
210+
.GetMaxU64(&offset, index_size);
209211
}
210212

211213
bool DWARFDebugRngLists::FindRanges(const DWARFUnit *cu,

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

+2-1
Original file line numberDiff line numberDiff line change
@@ -549,7 +549,8 @@ dw_addr_t DWARFFormValue::Address() const {
549549
uint32_t index_size = m_unit->GetAddressByteSize();
550550
dw_offset_t addr_base = m_unit->GetAddrBase();
551551
lldb::offset_t offset = addr_base + m_value.value.uval * index_size;
552-
return symbol_file->get_debug_addr_data().GetMaxU64(&offset, index_size);
552+
return symbol_file->GetDWARFContext().getOrLoadAddrData().GetMaxU64(
553+
&offset, index_size);
553554
}
554555

555556
DWARFDIE DWARFFormValue::Reference() const {

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

-4
Original file line numberDiff line numberDiff line change
@@ -549,10 +549,6 @@ void SymbolFileDWARF::LoadSectionData(lldb::SectionType sect_type,
549549
m_obj_file->ReadSectionData(section_sp.get(), data);
550550
}
551551

552-
const DWARFDataExtractor &SymbolFileDWARF::get_debug_addr_data() {
553-
return GetCachedSectionData(eSectionTypeDWARFDebugAddr, m_data_debug_addr);
554-
}
555-
556552
const DWARFDataExtractor &SymbolFileDWARF::DebugLocData() {
557553
const DWARFDataExtractor &debugLocData = get_debug_loc_data();
558554
if (debugLocData.GetByteSize() > 0)

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

-2
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,6 @@ class SymbolFileDWARF : public lldb_private::SymbolFile,
212212

213213
uint32_t GetPluginVersion() override;
214214

215-
virtual const lldb_private::DWARFDataExtractor &get_debug_addr_data();
216215
const lldb_private::DWARFDataExtractor &get_debug_loc_data();
217216
const lldb_private::DWARFDataExtractor &get_debug_loclists_data();
218217
const lldb_private::DWARFDataExtractor &get_debug_ranges_data();
@@ -451,7 +450,6 @@ class SymbolFileDWARF : public lldb_private::SymbolFile,
451450

452451
lldb_private::DWARFContext m_context;
453452

454-
DWARFDataSegment m_data_debug_addr;
455453
DWARFDataSegment m_data_debug_loc;
456454
DWARFDataSegment m_data_debug_loclists;
457455
DWARFDataSegment m_data_debug_ranges;

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

-13
Original file line numberDiff line numberDiff line change
@@ -112,19 +112,6 @@ DWARFUnit *SymbolFileDWARFDwo::GetBaseCompileUnit() {
112112
return m_base_dwarf_cu;
113113
}
114114

115-
const DWARFDataExtractor &SymbolFileDWARFDwo::get_debug_addr_data() {
116-
// For single file split dwarf case (when we have .dwo sections in a .o),
117-
// we do not want to use the .debug_addr section from .o file,
118-
// but want to get one from the final executable.
119-
// For regular split debug case, .dwo file does not contain the
120-
// .debug_addr, so we would always fall back to such lookup anyways.
121-
llvm::call_once(m_data_debug_addr.m_flag, [this] {
122-
SymbolFileDWARF::LoadSectionData(eSectionTypeDWARFDebugAddr,
123-
std::ref(m_data_debug_addr.m_data));
124-
});
125-
return m_data_debug_addr.m_data;
126-
}
127-
128115
SymbolFileDWARF *SymbolFileDWARFDwo::GetBaseSymbolFile() {
129116
return m_base_dwarf_cu->GetSymbolFileDWARF();
130117
}

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

-2
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,6 @@ class SymbolFileDWARFDwo : public SymbolFileDWARF {
4545

4646
DWARFUnit *GetBaseCompileUnit() override;
4747

48-
const lldb_private::DWARFDataExtractor &get_debug_addr_data() override;
49-
5048
protected:
5149
void LoadSectionData(lldb::SectionType sect_type,
5250
lldb_private::DWARFDataExtractor &data) override;

0 commit comments

Comments
 (0)