<div dir="ltr">Thanks for the quick fix.<br><br>I've beefed up the test coverage to catch this (adding a test case with a non-zero RangeSectionBase) & changed the fix somewhat in r309879.</div><br><div class="gmail_quote"><div dir="ltr">On Mon, Jul 31, 2017 at 8:33 AM Benjamin Kramer via llvm-commits <<a href="mailto:llvm-commits@lists.llvm.org">llvm-commits@lists.llvm.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: d0k<br>
Date: Mon Jul 31 08:32:39 2017<br>
New Revision: 309570<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=309570&view=rev" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project?rev=309570&view=rev</a><br>
Log:<br>
[DebugInfo] Don't overwrite DWARFUnit fields if the CU DIE doesn't have them.<br>
<br>
DIEs are lazily deserialized so it's possible that the DWO CU is created<br>
before the DIE is parsed. DWO shares .debug_addr and .debug_ranges with the<br>
object file so overwriting the offset with 0 will make the CU unusable.<br>
<br>
No test case because I couldn't get clang to emit a non-zero range base.<br>
<br>
Modified:<br>
    llvm/trunk/lib/DebugInfo/DWARF/DWARFUnit.cpp<br>
<br>
Modified: llvm/trunk/lib/DebugInfo/DWARF/DWARFUnit.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/DWARF/DWARFUnit.cpp?rev=309570&r1=309569&r2=309570&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/DWARF/DWARFUnit.cpp?rev=309570&r1=309569&r2=309570&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/lib/DebugInfo/DWARF/DWARFUnit.cpp (original)<br>
+++ llvm/trunk/lib/DebugInfo/DWARF/DWARFUnit.cpp Mon Jul 31 08:32:39 2017<br>
@@ -245,8 +245,12 @@ size_t DWARFUnit::extractDIEsIfNeeded(bo<br>
     auto BaseAddr = toAddress(UnitDie.find({DW_AT_low_pc, DW_AT_entry_pc}));<br>
     if (BaseAddr)<br>
       setBaseAddress(*BaseAddr);<br>
-    AddrOffsetSectionBase = toSectionOffset(UnitDie.find(DW_AT_GNU_addr_base), 0);<br>
-    RangeSectionBase = toSectionOffset(UnitDie.find(DW_AT_rnglists_base), 0);<br>
+    Optional<DWARFFormValue> AddrBase = UnitDie.find(DW_AT_GNU_addr_base);<br>
+    if (AddrBase)<br>
+      AddrOffsetSectionBase = *toSectionOffset(AddrBase);<br>
+    Optional<DWARFFormValue> RngListsBase = UnitDie.find(DW_AT_rnglists_base);<br>
+    if (RngListsBase)<br>
+      RangeSectionBase = *toSectionOffset(RngListsBase);<br>
<br>
     // In general, we derive the offset of the unit's contibution to the<br>
     // debug_str_offsets{.dwo} section from the unit DIE's<br>
<br>
<br>
_______________________________________________<br>
llvm-commits mailing list<br>
<a href="mailto:llvm-commits@lists.llvm.org" target="_blank">llvm-commits@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits</a><br>
</blockquote></div>