Skip to content

Commit

Permalink
Revert "Symbolize line zero as if no source info is available (#124846)"
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
ZequanWu committed Feb 24, 2025
1 parent 53c08df commit 23aca2f
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion llvm/lib/DebugInfo/DWARF/DWARFContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1869,7 +1869,7 @@ DWARFContext::getInliningInfoForAddress(object::SectionedAddress Address,
LineTable->getFileLineInfoForAddress(
{Address.Address, Address.SectionIndex}, Spec.ApproximateLine,
CU->getCompilationDir(), Spec.FLIKind, Frame);
} else if (CallLine != 0) {
} else {
// Otherwise, use call file, call line and call column from
// previous DIE in inlined chain.
if (LineTable)
Expand Down
3 changes: 1 addition & 2 deletions llvm/lib/DebugInfo/DWARF/DWARFDebugLine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1539,8 +1539,7 @@ bool DWARFDebugLine::LineTable::getFileLineInfoForAddress(
return false;
// Take file number and line/column from the row.
const auto &Row = Rows[RowIndex];
if (Row.Line == 0 ||
!getFileNameByIndex(Row.File, CompDir, Kind, Result.FileName))
if (!getFileNameByIndex(Row.File, CompDir, Kind, Result.FileName))
return false;
Result.Line = Row.Line;
Result.Column = Row.Column;
Expand Down
4 changes: 2 additions & 2 deletions llvm/test/tools/llvm-symbolizer/skip-line-zero.s
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@
## Check that without '--skip-line-zero', line zero is displayed for a line-table entry which has no source correspondence.
# RUN: llvm-symbolizer --obj=%t.o -f=none 0x16d4 | FileCheck --strict-whitespace --match-full-lines --check-prefix=DISABLE %s

# DISABLE:??:0:0
# DISABLE:main.c:0:0

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

# FAIL-ACROSS-SEQ:??:0:0
# FAIL-ACROSS-SEQ:main.c:0:0

## Check that with '--skip-line-zero', the last non-zero line in the current sequence is displayed.
# RUN: llvm-symbolizer --obj=%t.o -f=none --skip-line-zero 0x1717 | FileCheck --strict-whitespace --match-full-lines --check-prefix=WITHIN-SEQ %s
Expand Down
5 changes: 3 additions & 2 deletions llvm/test/tools/llvm-symbolizer/sym-verbose.test
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,13 @@ CHECK-NEXT: Column: 0

CHECK: 0x4005ad
CHECK-NEXT: foo
CHECK-NEXT: Filename: ??
CHECK-NEXT: Filename: /tmp{{[\\/]}}discrim.c
CHECK-NEXT: Function start filename: /tmp{{[\\/]}}discrim.c
CHECK-NEXT: Function start line: 4
CHECK-NEXT: Function start address: 0x400590
CHECK-NEXT: Line: 0
CHECK-NEXT: Column: 0
CHECK-NEXT: Column: 30
CHECK-NEXT: Discriminator: 4
CHECK-NEXT: main
CHECK-NEXT: Filename: /tmp{{[\\/]}}discrim.c
CHECK-NEXT: Function start filename: /tmp{{[\\/]}}discrim.c
Expand Down

0 comments on commit 23aca2f

Please sign in to comment.