Skip to content

Commit 23aca2f

Browse files
committed
Revert "Symbolize line zero as if no source info is available (#124846)"
This commit creates an inconsistency on `__sanitizer_symbolize_pc` API. Before this change, this API always uses the filename from debug info when the line number is 0. After this change, the filename becomes invalid when line number is 0. The sanitizer might fall back to use base filename from symbol table. So, this API may return either `??:0` or `{filename from symbol table}:0` depending on if the symbol table has the filename for it. Make sure this inconsistency is resolved before relanding the commit.
1 parent 53c08df commit 23aca2f

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 if (CallLine != 0) {
1872+
} else {
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: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1539,8 +1539,7 @@ bool DWARFDebugLine::LineTable::getFileLineInfoForAddress(
15391539
return false;
15401540
// Take file number and line/column from the row.
15411541
const auto &Row = Rows[RowIndex];
1542-
if (Row.Line == 0 ||
1543-
!getFileNameByIndex(Row.File, CompDir, Kind, Result.FileName))
1542+
if (!getFileNameByIndex(Row.File, CompDir, Kind, Result.FileName))
15441543
return false;
15451544
Result.Line = Row.Line;
15461545
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:??:0:0
23+
# DISABLE:main.c: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:??:0:0
29+
# FAIL-ACROSS-SEQ:main.c: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: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,12 +50,13 @@ CHECK-NEXT: Column: 0
5050

5151
CHECK: 0x4005ad
5252
CHECK-NEXT: foo
53-
CHECK-NEXT: Filename: ??
53+
CHECK-NEXT: Filename: /tmp{{[\\/]}}discrim.c
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: 0
58+
CHECK-NEXT: Column: 30
59+
CHECK-NEXT: Discriminator: 4
5960
CHECK-NEXT: main
6061
CHECK-NEXT: Filename: /tmp{{[\\/]}}discrim.c
6162
CHECK-NEXT: Function start filename: /tmp{{[\\/]}}discrim.c

0 commit comments

Comments
 (0)