Skip to content

[lldb] Remove DWARFDebugInfo DIERef footguns #92894

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 3 additions & 8 deletions lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -222,10 +222,6 @@ DWARFUnit *DWARFDebugInfo::GetUnitAtOffset(DIERef::Section section,
return result;
}

DWARFUnit *DWARFDebugInfo::GetUnit(const DIERef &die_ref) {
return GetUnitContainingDIEOffset(die_ref.section(), die_ref.die_offset());
}

DWARFUnit *
DWARFDebugInfo::GetUnitContainingDIEOffset(DIERef::Section section,
dw_offset_t die_offset) {
Expand Down Expand Up @@ -253,9 +249,8 @@ bool DWARFDebugInfo::ContainsTypeUnits() {
//
// Get the DIE (Debug Information Entry) with the specified offset.
DWARFDIE
DWARFDebugInfo::GetDIE(const DIERef &die_ref) {
DWARFUnit *cu = GetUnit(die_ref);
if (cu)
return cu->GetNonSkeletonUnit().GetDIE(die_ref.die_offset());
DWARFDebugInfo::GetDIE(DIERef::Section section, dw_offset_t die_offset) {
if (DWARFUnit *cu = GetUnitContainingDIEOffset(section, die_offset))
return cu->GetNonSkeletonUnit().GetDIE(die_offset);
return DWARFDIE(); // Not found
}
3 changes: 1 addition & 2 deletions lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,10 @@ class DWARFDebugInfo {
uint32_t *idx_ptr = nullptr);
DWARFUnit *GetUnitContainingDIEOffset(DIERef::Section section,
dw_offset_t die_offset);
DWARFUnit *GetUnit(const DIERef &die_ref);
DWARFUnit *GetSkeletonUnit(DWARFUnit *dwo_unit);
DWARFTypeUnit *GetTypeUnitForHash(uint64_t hash);
bool ContainsTypeUnits();
DWARFDIE GetDIE(const DIERef &die_ref);
DWARFDIE GetDIE(DIERef::Section section, dw_offset_t die_offset);

enum {
eDumpFlag_Verbose = (1 << 0), // Verbose dumping
Expand Down
7 changes: 4 additions & 3 deletions lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1761,7 +1761,8 @@ SymbolFileDWARF::GetDIE(const DIERef &die_ref) {
if (SymbolFileDWARFDebugMap *debug_map = GetDebugMapSymfile()) {
symbol_file = debug_map->GetSymbolFileByOSOIndex(*file_index); // OSO case
if (symbol_file)
return symbol_file->DebugInfo().GetDIE(die_ref);
return symbol_file->DebugInfo().GetDIE(die_ref.section(),
die_ref.die_offset());
return DWARFDIE();
}

Expand All @@ -1778,7 +1779,7 @@ SymbolFileDWARF::GetDIE(const DIERef &die_ref) {
if (symbol_file)
return symbol_file->GetDIE(die_ref);

return DebugInfo().GetDIE(die_ref);
return DebugInfo().GetDIE(die_ref.section(), die_ref.die_offset());
}

/// Return the DW_AT_(GNU_)dwo_id.
Expand Down Expand Up @@ -3786,7 +3787,7 @@ SymbolFileDWARF::FindBlockContainingSpecification(
// Give the concrete function die specified by "func_die_offset", find the
// concrete block whose DW_AT_specification or DW_AT_abstract_origin points
// to "spec_block_die_offset"
return FindBlockContainingSpecification(DebugInfo().GetDIE(func_die_ref),
return FindBlockContainingSpecification(GetDIE(func_die_ref),
spec_block_die_offset);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ SymbolFileDWARFDwo::GetTypeSystemForLanguage(LanguageType language) {
DWARFDIE
SymbolFileDWARFDwo::GetDIE(const DIERef &die_ref) {
if (die_ref.file_index() == GetFileIndex())
return DebugInfo().GetDIE(die_ref);
return DebugInfo().GetDIE(die_ref.section(), die_ref.die_offset());
return GetBaseSymbolFile().GetDIE(die_ref);
}

Expand Down
Loading