Skip to content

Commit

Permalink
DWARF: Port debug_addr over to DWARFContext
Browse files Browse the repository at this point in the history
llvm-svn: 361232
  • Loading branch information
labath committed May 21, 2019
1 parent ec767b0 commit f33f181
Show file tree
Hide file tree
Showing 9 changed files with 20 additions and 48 deletions.
31 changes: 7 additions & 24 deletions lldb/source/Expression/DWARFExpression.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,10 @@ ReadAddressFromDebugAddrSection(const DWARFUnit *dwarf_cu,
uint32_t index_size = dwarf_cu->GetAddressByteSize();
dw_offset_t addr_base = dwarf_cu->GetAddrBase();
lldb::offset_t offset = addr_base + index * index_size;
return dwarf_cu->GetSymbolFileDWARF()->get_debug_addr_data().GetMaxU64(
&offset, index_size);
return dwarf_cu->GetSymbolFileDWARF()
->GetDWARFContext()
.getOrLoadAddrData()
.GetMaxU64(&offset, index_size);
}

// DWARFExpression constructor
Expand Down Expand Up @@ -2813,12 +2815,7 @@ bool DWARFExpression::Evaluate(
return false;
}
uint64_t index = opcodes.GetULEB128(&offset);
uint32_t index_size = dwarf_cu->GetAddressByteSize();
dw_offset_t addr_base = dwarf_cu->GetAddrBase();
lldb::offset_t offset = addr_base + index * index_size;
uint64_t value =
dwarf_cu->GetSymbolFileDWARF()->get_debug_addr_data().GetMaxU64(
&offset, index_size);
lldb::addr_t value = ReadAddressFromDebugAddrSection(dwarf_cu, index);
stack.push_back(Scalar(value));
stack.back().SetValueType(Value::eValueTypeFileAddress);
} break;
Expand All @@ -2838,22 +2835,8 @@ bool DWARFExpression::Evaluate(
return false;
}
uint64_t index = opcodes.GetULEB128(&offset);
uint32_t index_size = dwarf_cu->GetAddressByteSize();
dw_offset_t addr_base = dwarf_cu->GetAddrBase();
lldb::offset_t offset = addr_base + index * index_size;
const DWARFDataExtractor &debug_addr =
dwarf_cu->GetSymbolFileDWARF()->get_debug_addr_data();
switch (index_size) {
case 4:
stack.push_back(Scalar(debug_addr.GetU32(&offset)));
break;
case 8:
stack.push_back(Scalar(debug_addr.GetU64(&offset)));
break;
default:
assert(false && "Unhandled index size");
return false;
}
lldb::addr_t value = ReadAddressFromDebugAddrSection(dwarf_cu, index);
stack.push_back(Scalar(value));
} break;

default:
Expand Down
5 changes: 5 additions & 0 deletions lldb/source/Plugins/SymbolFile/DWARF/DWARFContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,11 @@ const DWARFDataExtractor &DWARFContext::getOrLoadArangesData() {
m_data_debug_aranges);
}

const DWARFDataExtractor &DWARFContext::getOrLoadAddrData() {
return LoadOrGetSection(m_main_section_list, eSectionTypeDWARFDebugAddr,
m_data_debug_addr);
}

const DWARFDataExtractor &DWARFContext::getOrLoadDebugInfoData() {
if (isDwo())
return LoadOrGetSection(m_dwo_section_list, eSectionTypeDWARFDebugInfoDwo,
Expand Down
2 changes: 2 additions & 0 deletions lldb/source/Plugins/SymbolFile/DWARF/DWARFContext.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ class DWARFContext {
SectionList *m_dwo_section_list;

llvm::Optional<DWARFDataExtractor> m_data_debug_abbrev;
llvm::Optional<DWARFDataExtractor> m_data_debug_addr;
llvm::Optional<DWARFDataExtractor> m_data_debug_aranges;
llvm::Optional<DWARFDataExtractor> m_data_debug_info;
llvm::Optional<DWARFDataExtractor> m_data_debug_line;
Expand All @@ -38,6 +39,7 @@ class DWARFContext {
m_dwo_section_list(dwo_section_list) {}

const DWARFDataExtractor &getOrLoadAbbrevData();
const DWARFDataExtractor &getOrLoadAddrData();
const DWARFDataExtractor &getOrLoadArangesData();
const DWARFDataExtractor &getOrLoadDebugInfoData();
const DWARFDataExtractor &getOrLoadLineData();
Expand Down
6 changes: 4 additions & 2 deletions lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugRanges.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -204,8 +204,10 @@ static uint64_t ReadAddressFromDebugAddrSection(const DWARFUnit *cu,
uint32_t index_size = cu->GetAddressByteSize();
dw_offset_t addr_base = cu->GetAddrBase();
lldb::offset_t offset = addr_base + index * index_size;
return cu->GetSymbolFileDWARF()->get_debug_addr_data().GetMaxU64(&offset,
index_size);
return cu->GetSymbolFileDWARF()
->GetDWARFContext()
.getOrLoadAddrData()
.GetMaxU64(&offset, index_size);
}

bool DWARFDebugRngLists::FindRanges(const DWARFUnit *cu,
Expand Down
3 changes: 2 additions & 1 deletion lldb/source/Plugins/SymbolFile/DWARF/DWARFFormValue.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -549,7 +549,8 @@ dw_addr_t DWARFFormValue::Address() const {
uint32_t index_size = m_unit->GetAddressByteSize();
dw_offset_t addr_base = m_unit->GetAddrBase();
lldb::offset_t offset = addr_base + m_value.value.uval * index_size;
return symbol_file->get_debug_addr_data().GetMaxU64(&offset, index_size);
return symbol_file->GetDWARFContext().getOrLoadAddrData().GetMaxU64(
&offset, index_size);
}

DWARFDIE DWARFFormValue::Reference() const {
Expand Down
4 changes: 0 additions & 4 deletions lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -549,10 +549,6 @@ void SymbolFileDWARF::LoadSectionData(lldb::SectionType sect_type,
m_obj_file->ReadSectionData(section_sp.get(), data);
}

const DWARFDataExtractor &SymbolFileDWARF::get_debug_addr_data() {
return GetCachedSectionData(eSectionTypeDWARFDebugAddr, m_data_debug_addr);
}

const DWARFDataExtractor &SymbolFileDWARF::DebugLocData() {
const DWARFDataExtractor &debugLocData = get_debug_loc_data();
if (debugLocData.GetByteSize() > 0)
Expand Down
2 changes: 0 additions & 2 deletions lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,6 @@ class SymbolFileDWARF : public lldb_private::SymbolFile,

uint32_t GetPluginVersion() override;

virtual const lldb_private::DWARFDataExtractor &get_debug_addr_data();
const lldb_private::DWARFDataExtractor &get_debug_loc_data();
const lldb_private::DWARFDataExtractor &get_debug_loclists_data();
const lldb_private::DWARFDataExtractor &get_debug_ranges_data();
Expand Down Expand Up @@ -451,7 +450,6 @@ class SymbolFileDWARF : public lldb_private::SymbolFile,

lldb_private::DWARFContext m_context;

DWARFDataSegment m_data_debug_addr;
DWARFDataSegment m_data_debug_loc;
DWARFDataSegment m_data_debug_loclists;
DWARFDataSegment m_data_debug_ranges;
Expand Down
13 changes: 0 additions & 13 deletions lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -112,19 +112,6 @@ DWARFUnit *SymbolFileDWARFDwo::GetBaseCompileUnit() {
return m_base_dwarf_cu;
}

const DWARFDataExtractor &SymbolFileDWARFDwo::get_debug_addr_data() {
// For single file split dwarf case (when we have .dwo sections in a .o),
// we do not want to use the .debug_addr section from .o file,
// but want to get one from the final executable.
// For regular split debug case, .dwo file does not contain the
// .debug_addr, so we would always fall back to such lookup anyways.
llvm::call_once(m_data_debug_addr.m_flag, [this] {
SymbolFileDWARF::LoadSectionData(eSectionTypeDWARFDebugAddr,
std::ref(m_data_debug_addr.m_data));
});
return m_data_debug_addr.m_data;
}

SymbolFileDWARF *SymbolFileDWARFDwo::GetBaseSymbolFile() {
return m_base_dwarf_cu->GetSymbolFileDWARF();
}
Expand Down
2 changes: 0 additions & 2 deletions lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,6 @@ class SymbolFileDWARFDwo : public SymbolFileDWARF {

DWARFUnit *GetBaseCompileUnit() override;

const lldb_private::DWARFDataExtractor &get_debug_addr_data() override;

protected:
void LoadSectionData(lldb::SectionType sect_type,
lldb_private::DWARFDataExtractor &data) override;
Expand Down

0 comments on commit f33f181

Please sign in to comment.