Skip to content

Commit c32cd57

Browse files
authored
Symbolize line zero as if no source info is available (#124846)
Since line zero means "no line information", when symbolizing a location (an address or an inline frame associated with the address) that has a line zero location, we shouldn't include other irrelevant data (like filename) in the result.
1 parent 337604e commit c32cd57

File tree

4 files changed

+7
-7
lines changed

4 files changed

+7
-7
lines changed

llvm/lib/DebugInfo/DWARF/DWARFContext.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1869,7 +1869,7 @@ DWARFContext::getInliningInfoForAddress(object::SectionedAddress Address,
18691869
LineTable->getFileLineInfoForAddress(
18701870
{Address.Address, Address.SectionIndex}, Spec.ApproximateLine,
18711871
CU->getCompilationDir(), Spec.FLIKind, Frame);
1872-
} else {
1872+
} else if (CallLine != 0) {
18731873
// Otherwise, use call file, call line and call column from
18741874
// previous DIE in inlined chain.
18751875
if (LineTable)

llvm/lib/DebugInfo/DWARF/DWARFDebugLine.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1508,7 +1508,8 @@ bool DWARFDebugLine::LineTable::getFileLineInfoForAddress(
15081508
return false;
15091509
// Take file number and line/column from the row.
15101510
const auto &Row = Rows[RowIndex];
1511-
if (!getFileNameByIndex(Row.File, CompDir, Kind, Result.FileName))
1511+
if (Row.Line == 0 ||
1512+
!getFileNameByIndex(Row.File, CompDir, Kind, Result.FileName))
15121513
return false;
15131514
Result.Line = Row.Line;
15141515
Result.Column = Row.Column;

llvm/test/tools/llvm-symbolizer/skip-line-zero.s

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,13 @@
2020
## Check that without '--skip-line-zero', line zero is displayed for a line-table entry which has no source correspondence.
2121
# RUN: llvm-symbolizer --obj=%t.o -f=none 0x16d4 | FileCheck --strict-whitespace --match-full-lines --check-prefix=DISABLE %s
2222

23-
# DISABLE:main.c:0:0
23+
# DISABLE:??:0:0
2424

2525
## Check that the '--skip-line-zero' does not cross sequence boundaries.
2626
## If it fails to find in the current sequence then line zero is returned for the queried address.
2727
# RUN: llvm-symbolizer --obj=%t.o -f=none --skip-line-zero 0x16c0 | FileCheck --strict-whitespace --match-full-lines --check-prefix=FAIL-ACROSS-SEQ %s
2828

29-
# FAIL-ACROSS-SEQ:main.c:0:0
29+
# FAIL-ACROSS-SEQ:??:0:0
3030

3131
## Check that with '--skip-line-zero', the last non-zero line in the current sequence is displayed.
3232
# RUN: llvm-symbolizer --obj=%t.o -f=none --skip-line-zero 0x1717 | FileCheck --strict-whitespace --match-full-lines --check-prefix=WITHIN-SEQ %s

llvm/test/tools/llvm-symbolizer/sym-verbose.test

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,13 +50,12 @@ CHECK-NEXT: Column: 0
5050

5151
CHECK: 0x4005ad
5252
CHECK-NEXT: foo
53-
CHECK-NEXT: Filename: /tmp{{[\\/]}}discrim.c
53+
CHECK-NEXT: Filename: ??
5454
CHECK-NEXT: Function start filename: /tmp{{[\\/]}}discrim.c
5555
CHECK-NEXT: Function start line: 4
5656
CHECK-NEXT: Function start address: 0x400590
5757
CHECK-NEXT: Line: 0
58-
CHECK-NEXT: Column: 30
59-
CHECK-NEXT: Discriminator: 4
58+
CHECK-NEXT: Column: 0
6059
CHECK-NEXT: main
6160
CHECK-NEXT: Filename: /tmp{{[\\/]}}discrim.c
6261
CHECK-NEXT: Function start filename: /tmp{{[\\/]}}discrim.c

0 commit comments

Comments
 (0)