Skip to content

Commit c3ec9e3

Browse files
authored
[lldb][DWARF] Don't try to compute address range information of forward declarations (llvm#144059)
This fixes the error reported in llvm#144037. When computing the aranges table of a CU, LLDB would currently visit all `DW_TAG_subprogram` DIEs and check their `DW_AT_low_pc`/`DW_AT_high_pc`/`DW_AT_ranges` attributes. If those don't exist it would error out and spam the console. Some subprograms (particularly forward declarations) don't have low/high pc attributes, so it's not really an "error". See DWARFv5 spec section `3.3.3 Subroutine and Entry Point Locations`: ``` A subroutine entry may have either a DW_AT_low_pc and DW_AT_high_pc pair of attributes or a DW_AT_ranges attribute whose values encode the contiguous or non-contiguous address ranges, respectively, of the machine instructions generated for the subroutine (see Section 2.17 on page 51). ... A subroutine entry representing a subroutine declaration that is not also a definition does not have code address or range attributes. ``` We should just ignore those DIEs.
1 parent ea73fc5 commit c3ec9e3

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -611,7 +611,11 @@ void DWARFDebugInfoEntry::BuildFunctionAddressRangeTable(
611611
DWARFUnit *cu, DWARFDebugAranges *debug_aranges) const {
612612
Log *log = GetLog(DWARFLog::DebugInfo);
613613
if (m_tag) {
614-
if (m_tag == DW_TAG_subprogram) {
614+
// Subprogram forward declarations don't have
615+
// DW_AT_ranges/DW_AT_low_pc/DW_AT_high_pc attributes, so don't even try
616+
// getting address range information for them.
617+
if (m_tag == DW_TAG_subprogram &&
618+
!GetAttributeValueAsOptionalUnsigned(cu, DW_AT_declaration)) {
615619
if (llvm::Expected<llvm::DWARFAddressRangesVector> ranges =
616620
GetAttributeAddressRanges(cu, /*check_hi_lo_pc=*/true)) {
617621
for (const auto &r : *ranges)

0 commit comments

Comments
 (0)