Skip to content

Commit 3326940

Browse files
committed
[lldb/DWARF] Remove "range lower than function low_pc" check
The check is not correct for discontinuous functions, as one of the blocks could very well begin before the function entry point. To catch dead-stripped ranges, I check whether the functions is after the first known code address. I don't print any error in this case as that is a common/expected situation. If the block ranges is not a subrange of the enclosing block then this will range will currently be added to the outer block as well (i.e., we get the same behavior that's currently possible for non-subrange blocks larger than function_low_pc). However, this code path is buggy and I'd like to change that (#117725).
1 parent 387f3e8 commit 3326940

File tree

3 files changed

+20
-347
lines changed

3 files changed

+20
-347
lines changed

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

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1346,19 +1346,9 @@ size_t SymbolFileDWARF::ParseBlocksRecursive(CompileUnit &comp_unit,
13461346
decl_line, decl_column, call_file, call_line,
13471347
call_column, nullptr)) {
13481348
for (const llvm::DWARFAddressRange &range : ranges) {
1349-
if (!range.valid())
1350-
continue;
1351-
if (range.LowPC >= subprogram_low_pc)
1349+
if (range.valid() && range.LowPC >= m_first_code_address)
13521350
block->AddRange(Block::Range(range.LowPC - subprogram_low_pc,
13531351
range.HighPC - range.LowPC));
1354-
else {
1355-
GetObjectFile()->GetModule()->ReportError(
1356-
"{0:x8}: adding range [{1:x16}-{2:x16}) which has a base "
1357-
"that is less than the function's low PC {3:x16}. Please file "
1358-
"a bug and attach the file at the "
1359-
"start of this error message",
1360-
block->GetID(), range.LowPC, range.HighPC, subprogram_low_pc);
1361-
}
13621352
}
13631353
block->FinalizeRanges();
13641354

lldb/test/Shell/SymbolFile/DWARF/range-lower-then-low-pc.s

Lines changed: 0 additions & 317 deletions
This file was deleted.

lldb/test/Shell/SymbolFile/DWARF/x86/discontinuous-inline-function.s

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -6,28 +6,13 @@
66
# RUN: %lldb %t -o "image lookup -v -n look_me_up" -o exit | FileCheck %s
77

88
# CHECK: 1 match found in {{.*}}
9-
# CHECK: Summary: {{.*}}`foo + 6 [inlined] foo_inl + 1
10-
# CHECK-NEXT: {{.*}}`foo + 5
11-
# CHECK: Blocks: id = {{.*}}, ranges = [0x00000000-0x00000003)[0x00000004-0x00000008)
12-
# CHECK-NEXT: id = {{.*}}, ranges = [0x00000001-0x00000002)[0x00000005-0x00000007), name = "foo_inl"
9+
# CHECK: Summary: {{.*}}`foo - 3 [inlined] foo_inl + 1
10+
# CHECK-NEXT: {{.*}}`foo - 4
11+
# CHECK: Blocks: id = {{.*}}, ranges = [0x00000000-0x00000004)[0x00000005-0x00000008)
12+
# CHECK-NEXT: id = {{.*}}, ranges = [0x00000001-0x00000003)[0x00000006-0x00000007), name = "foo_inl"
1313

1414
.text
1515

16-
.type foo,@function
17-
foo:
18-
nop
19-
.Lfoo_inl:
20-
nop
21-
.Lfoo_inl_end:
22-
nop
23-
.Lfoo_end:
24-
.size foo, .Lfoo_end-foo
25-
26-
bar:
27-
nop
28-
.Lbar_end:
29-
.size bar, .Lbar_end-bar
30-
3116
.section .text.__part1,"ax",@progbits
3217
foo.__part.1:
3318
nop
@@ -42,6 +27,21 @@ look_me_up:
4227
.size foo.__part.1, .Lfoo.__part.1_end-foo.__part.1
4328

4429

30+
bar:
31+
nop
32+
.Lbar_end:
33+
.size bar, .Lbar_end-bar
34+
35+
.type foo,@function
36+
foo:
37+
nop
38+
.Lfoo_inl:
39+
nop
40+
.Lfoo_inl_end:
41+
nop
42+
.Lfoo_end:
43+
.size foo, .Lfoo_end-foo
44+
4545
.section .debug_abbrev,"",@progbits
4646
.byte 1 # Abbreviation Code
4747
.byte 17 # DW_TAG_compile_unit

0 commit comments

Comments
 (0)