Skip to content

Commit cdb3a8b

Browse files
committed
[lldb][DWARF] Don't try to compute address range information of forward declarations
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`. 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". We should just ignore those DIEs.
1 parent db8d34d commit cdb3a8b

File tree

2 files changed

+27
-1
lines changed

2 files changed

+27
-1
lines changed

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -611,7 +611,8 @@ 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+
if (m_tag == DW_TAG_subprogram &&
615+
!GetAttributeValueAsOptionalUnsigned(cu, DW_AT_declaration)) {
615616
if (llvm::Expected<llvm::DWARFAddressRangesVector> ranges =
616617
GetAttributeAddressRanges(cu, /*check_hi_lo_pc=*/true)) {
617618
for (const auto &r : *ranges)
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Test that we don't try to determine address range
2+
# information of forward declaration DIEs which have
3+
# no DW_AT_low_pc/DW_AT_high_pc in DWARF.
4+
5+
# RUN: split-file %s %t
6+
# RUN: %clang_host -c -g -gdwarf %t/main.cpp -o %t.o
7+
# RUN: %lldb -x -b -s %t/commands.input %t.o -o exit 2>&1 \
8+
# RUN: | FileCheck %s
9+
10+
#--- main.cpp
11+
12+
struct Foo {
13+
void func() {}
14+
} foo;
15+
16+
void baz() {
17+
foo.func();
18+
}
19+
20+
#--- commands.input
21+
22+
log enable -v dwarf info
23+
target modules lookup -n func
24+
25+
# CHECK-NOT: DIE has no address range information

0 commit comments

Comments
 (0)