[lld] [llvm] [Symbolizer] Support for Missing Line Numbers. (PR #82240)

David Blaikie via llvm-commits llvm-commits at lists.llvm.org
Tue May 7 12:33:16 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:

I think it might be clearer to have the early return, rather than having the non-approximate case come out through this for loop?

```
if (RowIndex != UnknownRowIndex || !ReportApproximateLine)
  return RowIndex;
for (...) {
  if (Rows[ApproxRowIndex].Line) {
    *IsApproximateLine = true;
    return ApproxRowIndex;
  }
}
return RowIndex;
```

Also, this will ensure that `(approximate)` isn't printed if the approximation doesn't find a non-zero line number (might be worth adding a test for that to demonstrate the fix/change in behavior here).
  

https://github.com/llvm/llvm-project/pull/82240


More information about the llvm-commits mailing list