[PATCH] D93306: [llvm-symbolizer][Windows] Add start line when searching in line table sections.
Amy Huang via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Dec 15 08:29:02 PST 2020
akhuang created this revision.
akhuang added reviewers: rnk, amccarth.
Herald added subscribers: rupprecht, hiraditya.
Herald added a reviewer: jhenderson.
akhuang requested review of this revision.
Herald added subscribers: llvm-commits, MaskRay.
Herald added a project: LLVM.
Fixes issue where if a line section doesn't start with a line number
then the addresses at the beginning of the section don't have line numbers.
For example, for a line section like this
0001:00000010-00000014, line/column/addr entries = 1
7 00000013 !
a line number wouldn't be found for addresses from 10 to 12.
This matches behavior when using the DIA SDK.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D93306
Files:
llvm/lib/DebugInfo/PDB/Native/SymbolCache.cpp
llvm/test/tools/llvm-symbolizer/pdb/Inputs/test-line-numbers.cpp
llvm/test/tools/llvm-symbolizer/pdb/Inputs/test-line-numbers.exe
llvm/test/tools/llvm-symbolizer/pdb/pdb-line-numbers.test
Index: llvm/test/tools/llvm-symbolizer/pdb/pdb-line-numbers.test
===================================================================
--- /dev/null
+++ llvm/test/tools/llvm-symbolizer/pdb/pdb-line-numbers.test
@@ -0,0 +1,16 @@
+RUN: llvm-symbolizer --obj="%p/Inputs/test-line-numbers.exe" \
+RUN: --relative-address 0x1000 0x1003 0x1010 0x1013 | FileCheck %s
+
+CHECK: f1(int)
+CHECK-NEXT: t.cpp:2:13
+
+CHECK: f1(int)
+CHECK-NEXT: t.cpp:3:3
+
+CHECK: f1
+CHECK-NEXT: t.cpp:2:0
+CHECK-NEXT: f2(int)
+CHECK-NEXT: t.cpp:7:3
+
+CHECK: f2(int)
+CHECK: t.cpp:7:3
Index: llvm/test/tools/llvm-symbolizer/pdb/Inputs/test-line-numbers.cpp
===================================================================
--- /dev/null
+++ llvm/test/tools/llvm-symbolizer/pdb/Inputs/test-line-numbers.cpp
@@ -0,0 +1,16 @@
+// To generate the corresponding EXE/PDB, run:
+// clang -cc1 -triple x86_64-windows-msvc -gcodeview -debug-info-kind=limited -O2 -emit-obj t.cpp
+// lld-link -entry:main -debug t.obj
+
+int f1(int x) {
+ int y = x + 1;
+ return y;
+}
+
+int f2(int n) {
+ return f1(n);
+}
+
+int main() {
+ return f2(100);
+}
Index: llvm/lib/DebugInfo/PDB/Native/SymbolCache.cpp
===================================================================
--- llvm/lib/DebugInfo/PDB/Native/SymbolCache.cpp
+++ llvm/lib/DebugInfo/PDB/Native/SymbolCache.cpp
@@ -481,11 +481,19 @@
auto ColIt = Group.Columns.begin();
auto ColsEnd = Group.Columns.end();
+ // Add a line to mark the beginning of this section.
+ uint64_t StartAddr =
+ Session.getVAFromSectOffset(RelocSegment, RelocOffset);
+ LineInfo FirstLine(Group.LineNumbers.front().Flags);
+ uint32_t ColNum =
+ (Lines.hasColumnInfo()) ? Group.Columns.front().StartColumn : 0;
+ Entries.push_back({StartAddr, FirstLine, ColNum, Group.NameIndex, false});
+
for (const LineNumberEntry &LN : Group.LineNumbers) {
uint64_t VA =
Session.getVAFromSectOffset(RelocSegment, RelocOffset + LN.Offset);
LineInfo Line(LN.Flags);
- uint32_t ColNum = 0;
+ ColNum = 0;
if (Lines.hasColumnInfo() && ColIt != ColsEnd) {
ColNum = ColIt->StartColumn;
@@ -495,12 +503,10 @@
}
// Add a terminal entry line to mark the end of this subsection.
- uint64_t VA = Session.getVAFromSectOffset(
- RelocSegment, RelocOffset + Lines.header()->CodeSize);
+ uint64_t EndAddr = StartAddr + Lines.header()->CodeSize;
LineInfo LastLine(Group.LineNumbers.back().Flags);
- uint32_t ColNum =
- (Lines.hasColumnInfo()) ? Group.Columns.back().StartColumn : 0;
- Entries.push_back({VA, LastLine, ColNum, Group.NameIndex, true});
+ ColNum = (Lines.hasColumnInfo()) ? Group.Columns.back().StartColumn : 0;
+ Entries.push_back({EndAddr, LastLine, ColNum, Group.NameIndex, true});
EntryList.push_back(Entries);
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D93306.311920.patch
Type: text/x-patch
Size: 2940 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20201215/6890cf6f/attachment.bin>
More information about the llvm-commits
mailing list