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

via llvm-commits llvm-commits at lists.llvm.org
Wed May 15 01:14:29 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;
----------------
ampandey-1995 wrote:

I have added a new file ```approximate-line-handcrafted.s``` assembly to cover this functionality.

The ```approximate-line-handcrafted.s``` is generated from clang, however I have manually edited the line entries(.loc) at some position in the assembly file to cover that if approximation loop fails then it should return the original rowindex.

I also created two sequences to achieve this. It is hard to create sequences manually in assembly.  Also, the output object file  generated from the assembly still have one sequence always no matter whatever I did.  To overcome this I had switched to usage of custom sections. Custom sections enforce sequence boundaries in the object file.  Hence the approximate-line-handcrafted.s covers two sequences 

One sequence  is for main.c file
Another sequence is for definitions.h file


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


More information about the llvm-commits mailing list