[lld] [llvm] [Symbolizer] Support for Missing Line Numbers. (PR #82240)
David Blaikie via llvm-commits
llvm-commits at lists.llvm.org
Thu May 9 09:04:55 PDT 2024
================
@@ -1337,7 +1339,17 @@ uint32_t DWARFDebugLine::LineTable::lookupAddressImpl(
DWARFDebugLine::Sequence::orderByHighPC);
if (It == Sequences.end() || It->SectionIndex != Address.SectionIndex)
return UnknownRowIndex;
- return findRowInSeq(*It, Address);
+
+ uint32_t RowIndex = findRowInSeq(*It, Address);
+ if (RowIndex != UnknownRowIndex && DWARFDebugLine::ReportApproximateLine) {
+ for (uint32_t ApproxRowIndex = RowIndex;
+ ApproxRowIndex >= It->FirstRowIndex; --ApproxRowIndex) {
+ if (Rows[ApproxRowIndex].Line)
+ return ApproxRowIndex;
+ *IsApproximateLine = true;
+ }
+ }
+ return RowIndex;
----------------
dwblaikie wrote:
You'd probably need a hand-crafted line table (the .line directives in the assembly - it's probably easier to build something from scratch rather than try to modify the assembly from some real-world code)
A simple .text section, with a line directive, of, say line 0 with file A, then a nop instruction, then another line directive of line 0 with file B.
Symbolize the second address (should be literally symbolizing the value 1) and check that without the code to ensure that we return the original row where the address was found, we'd end up returning the 0 line at the start of the sequence and that would mean the symbolized output would mention file A. But with the code to ensure that, failing to find a non-zero line in the sequence, we prefer the original - we should see file B mentioned, not file A.
(might be worth introducing more than one sequence, to check that we don't walk into another sequence - and probably clearer/simpler testing it with a little hand-crafted assembly like this rather than full blown generated-from-the-frontend assembly)
https://github.com/llvm/llvm-project/pull/82240
More information about the llvm-commits
mailing list