[lldb/DWARF] Remove one more auto-dwo method

Summary:
Our DWARFUnit was automatically forwarding the requests to the split
unit when looking for a DIE by offset. llvm::DWARFUnit does not do that,
and is not likely to start doing it any time soon.

This patch deletes the this logic and updates the callers to request the
correct unit instead. While doing that, I've found a bit of duplicated
code for lookup up a function and block by address, so I've extracted
that into a helper function.

Reviewers: JDevlieghere, aprantl, clayborg, jdoerfert

Subscribers: lldb-commits

Tags: #lldb

Differential Revision: https://reviews.llvm.org/D73112
This commit is contained in:
Pavel Labath 2020-01-21 17:04:39 +01:00
parent c42fe24754
commit 3d7177acd7
4 changed files with 45 additions and 55 deletions

View File

@ -191,7 +191,7 @@ DWARFDIE
DWARFDebugInfo::GetDIE(const DIERef &die_ref) {
DWARFUnit *cu = GetUnit(die_ref);
if (cu)
return cu->GetDIE(die_ref.die_offset());
return cu->GetNonSkeletonUnit().GetDIE(die_ref.die_offset());
return DWARFDIE(); // Not found
}

View File

@ -534,9 +534,6 @@ static bool CompareDIEOffset(const DWARFDebugInfoEntry &die,
DWARFDIE
DWARFUnit::GetDIE(dw_offset_t die_offset) {
if (die_offset != DW_INVALID_OFFSET) {
if (GetDwoSymbolFile())
return GetDwoSymbolFile()->GetCompileUnit()->GetDIE(die_offset);
if (ContainsDIEOffset(die_offset)) {
ExtractDIEsIfNeeded();
DWARFDebugInfoEntry::const_iterator end = m_die_array.cend();

View File

@ -1771,6 +1771,32 @@ SymbolFileDWARF::GlobalVariableMap &SymbolFileDWARF::GetGlobalAranges() {
return *m_global_aranges_up;
}
void SymbolFileDWARF::ResolveFunctionAndBlock(lldb::addr_t file_vm_addr,
bool lookup_block,
SymbolContext &sc) {
assert(sc.comp_unit);
DWARFUnit &cu = GetDWARFCompileUnit(sc.comp_unit)->GetNonSkeletonUnit();
DWARFDIE function_die = cu.LookupAddress(file_vm_addr);
DWARFDIE block_die;
if (function_die) {
sc.function = sc.comp_unit->FindFunctionByUID(function_die.GetID()).get();
if (sc.function == nullptr)
sc.function = ParseFunction(*sc.comp_unit, function_die);
if (sc.function && lookup_block)
block_die = function_die.LookupDeepestBlock(file_vm_addr);
}
if (!sc.function || ! lookup_block)
return;
Block &block = sc.function->GetBlock(true);
if (block_die)
sc.block = block.FindBlockByID(block_die.GetID());
else
sc.block = block.FindBlockByID(function_die.GetID());
}
uint32_t SymbolFileDWARF::ResolveSymbolContext(const Address &so_addr,
SymbolContextItem resolve_scope,
SymbolContext &sc) {
@ -1834,17 +1860,11 @@ uint32_t SymbolFileDWARF::ResolveSymbolContext(const Address &so_addr,
bool force_check_line_table = false;
if (resolve_scope &
(eSymbolContextFunction | eSymbolContextBlock)) {
DWARFDIE function_die = dwarf_cu->LookupAddress(file_vm_addr);
DWARFDIE block_die;
if (function_die) {
sc.function =
sc.comp_unit->FindFunctionByUID(function_die.GetID()).get();
if (sc.function == nullptr)
sc.function = ParseFunction(*sc.comp_unit, function_die);
if (sc.function && (resolve_scope & eSymbolContextBlock))
block_die = function_die.LookupDeepestBlock(file_vm_addr);
} else {
ResolveFunctionAndBlock(file_vm_addr,
resolve_scope & eSymbolContextBlock, sc);
if (sc.function)
resolved |= eSymbolContextFunction;
else {
// We might have had a compile unit that had discontiguous
// address ranges where the gaps are symbols that don't have
// any debug info. Discontiguous compile unit address ranges
@ -1853,21 +1873,8 @@ uint32_t SymbolFileDWARF::ResolveSymbolContext(const Address &so_addr,
// of the aranges down.
force_check_line_table = true;
}
if (sc.function != nullptr) {
resolved |= eSymbolContextFunction;
if (resolve_scope & eSymbolContextBlock) {
Block &block = sc.function->GetBlock(true);
if (block_die)
sc.block = block.FindBlockByID(block_die.GetID());
else
sc.block = block.FindBlockByID(function_die.GetID());
if (sc.block)
resolved |= eSymbolContextBlock;
}
}
if (sc.block)
resolved |= eSymbolContextBlock;
}
if ((resolve_scope & eSymbolContextLineEntry) ||
@ -1967,30 +1974,8 @@ uint32_t SymbolFileDWARF::ResolveSymbolContext(const FileSpec &file_spec,
const lldb::addr_t file_vm_addr =
sc.line_entry.range.GetBaseAddress().GetFileAddress();
if (file_vm_addr != LLDB_INVALID_ADDRESS) {
DWARFDIE function_die =
GetDWARFCompileUnit(dc_cu)->LookupAddress(file_vm_addr);
DWARFDIE block_die;
if (function_die) {
sc.function =
sc.comp_unit->FindFunctionByUID(function_die.GetID())
.get();
if (sc.function == nullptr)
sc.function =
ParseFunction(*sc.comp_unit, function_die);
if (sc.function && (resolve_scope & eSymbolContextBlock))
block_die =
function_die.LookupDeepestBlock(file_vm_addr);
}
if (sc.function != nullptr) {
Block &block = sc.function->GetBlock(true);
if (block_die)
sc.block = block.FindBlockByID(block_die.GetID());
else if (function_die)
sc.block = block.FindBlockByID(function_die.GetID());
}
ResolveFunctionAndBlock(
file_vm_addr, resolve_scope & eSymbolContextBlock, sc);
}
}
@ -3122,7 +3107,8 @@ size_t SymbolFileDWARF::ParseBlocksRecursive(Function &func) {
size_t functions_added = 0;
const dw_offset_t function_die_offset = func.GetID();
DWARFDIE function_die = dwarf_cu->GetDIE(function_die_offset);
DWARFDIE function_die =
dwarf_cu->GetNonSkeletonUnit().GetDIE(function_die_offset);
if (function_die) {
ParseBlocksRecursive(*comp_unit, &func.GetBlock(false), function_die,
LLDB_INVALID_ADDRESS, 0);

View File

@ -381,6 +381,13 @@ protected:
bool ResolveFunction(const DWARFDIE &die, bool include_inlines,
lldb_private::SymbolContextList &sc_list);
/// Resolve functions and (possibly) blocks for the given file address and a
/// compile unit. The compile unit comes from the sc argument and it must be
/// set. The results of the lookup (if any) are written back to the symbol
/// context.
void ResolveFunctionAndBlock(lldb::addr_t file_vm_addr, bool lookup_block,
lldb_private::SymbolContext &sc);
virtual lldb::TypeSP
FindDefinitionTypeForDWARFDeclContext(const DWARFDeclContext &die_decl_ctx);