[PATCH] D96827: [DWARF] Check for AddrOffsetSectionBase to work with DWO Units.

Alexander Yermolovich via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Mar 11 17:40:00 PST 2021


ayermolo updated this revision to Diff 330115.
ayermolo retitled this revision from "[DWARF][WIP] Check for AddrOffsetSectionBase to work with DWO Units." to "[DWARF] Check for AddrOffsetSectionBase to work with DWO Units.".
ayermolo edited the summary of this revision.
ayermolo added a reviewer: dblaikie.

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D96827/new/

https://reviews.llvm.org/D96827

Files:
  llvm/lib/DebugInfo/DWARF/DWARFUnit.cpp
  llvm/test/DebugInfo/Inputs/splitdwarf-single-issue
  llvm/test/DebugInfo/Inputs/splitdwarf-single-issue.cpp
  llvm/test/DebugInfo/Inputs/splitdwarf-single-issue.o
  llvm/test/DebugInfo/symbolize-debug-fission-single.test


Index: llvm/test/DebugInfo/symbolize-debug-fission-single.test
===================================================================
--- /dev/null
+++ llvm/test/DebugInfo/symbolize-debug-fission-single.test
@@ -0,0 +1,19 @@
+Binary and .o was generated by:
+1) clang++ -g -gsplit-dwarf=single splitdwarf-single-issue.cpp -O3 -o splitdwarf-single-issue.o -s
+2) Edit CompileDir to current directory
+3) clang++ -g -gsplit-dwarf=single splitdwarf-single-issue.s -O3 -o splitdwarf-single-issue.o -c
+4) clang++ -g -gsplit-dwarf=single splitdwarf-single-issue.o -O3 -o splitdwarf-single-issue
+
+Copy the .o and then cd into the output directory, so that the symbolizer would
+find the .o if it attempted to.
+RUN: rm -rf %t && mkdir -p %t
+RUN: cd %t
+RUN: cp %p/Inputs/splitdwarf-single-issue.o %t
+RUN: llvm-symbolizer  0x0000000000400611 -a --obj=%p/Inputs/splitdwarf-single-issue \
+RUN:   | FileCheck %s
+
+CHECK:      0x400611
+CHECK-NEXT: f2() 
+CHECK-NEXT: ././test.cpp:7:3
+CHECK-NEXT: main
+CHECK-NEXT: ././test.cpp:13:3
Index: llvm/test/DebugInfo/Inputs/splitdwarf-single-issue.cpp
===================================================================
--- /dev/null
+++ llvm/test/DebugInfo/Inputs/splitdwarf-single-issue.cpp
@@ -0,0 +1,12 @@
+__attribute__((nodebug)) __attribute__((optnone)) void f1() {
+}
+
+__attribute__((always_inline)) inline void f2() {
+
+  f1();
+}
+
+int main() {
+
+  f2();
+}
Index: llvm/lib/DebugInfo/DWARF/DWARFUnit.cpp
===================================================================
--- llvm/lib/DebugInfo/DWARF/DWARFUnit.cpp
+++ llvm/lib/DebugInfo/DWARF/DWARFUnit.cpp
@@ -192,17 +192,18 @@
 
 Optional<object::SectionedAddress>
 DWARFUnit::getAddrOffsetSectionItem(uint32_t Index) const {
-  if (IsDWO) {
+  if (!AddrOffsetSectionBase) {
     auto R = Context.info_section_units();
     // Surprising if a DWO file has more than one skeleton unit in it - this
     // probably shouldn't be valid, but if a use case is found, here's where to
     // support it (probably have to linearly search for the matching skeleton CU
     // here)
-    if (hasSingleElement(R))
+    if (IsDWO && hasSingleElement(R)) {
       return (*R.begin())->getAddrOffsetSectionItem(Index);
-  }
-  if (!AddrOffsetSectionBase)
+    }
     return None;
+  }
+
   uint64_t Offset = *AddrOffsetSectionBase + Index * getAddressByteSize();
   if (AddrOffsetSection->Data.size() < Offset + getAddressByteSize())
     return None;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D96827.330115.patch
Type: text/x-patch
Size: 2443 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210312/90eceaf3/attachment.bin>


More information about the llvm-commits mailing list