[llvm] r309570 - [DebugInfo] Don't overwrite DWARFUnit fields if the CU DIE doesn't have them.

Benjamin Kramer via llvm-commits llvm-commits at lists.llvm.org
Mon Jul 31 08:32:39 PDT 2017


Author: d0k
Date: Mon Jul 31 08:32:39 2017
New Revision: 309570

URL: http://llvm.org/viewvc/llvm-project?rev=309570&view=rev
Log:
[DebugInfo] Don't overwrite DWARFUnit fields if the CU DIE doesn't have them.

DIEs are lazily deserialized so it's possible that the DWO CU is created
before the DIE is parsed. DWO shares .debug_addr and .debug_ranges with the
object file so overwriting the offset with 0 will make the CU unusable.

No test case because I couldn't get clang to emit a non-zero range base.

Modified:
    llvm/trunk/lib/DebugInfo/DWARF/DWARFUnit.cpp

Modified: llvm/trunk/lib/DebugInfo/DWARF/DWARFUnit.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/DWARF/DWARFUnit.cpp?rev=309570&r1=309569&r2=309570&view=diff
==============================================================================
--- llvm/trunk/lib/DebugInfo/DWARF/DWARFUnit.cpp (original)
+++ llvm/trunk/lib/DebugInfo/DWARF/DWARFUnit.cpp Mon Jul 31 08:32:39 2017
@@ -245,8 +245,12 @@ size_t DWARFUnit::extractDIEsIfNeeded(bo
     auto BaseAddr = toAddress(UnitDie.find({DW_AT_low_pc, DW_AT_entry_pc}));
     if (BaseAddr)
       setBaseAddress(*BaseAddr);
-    AddrOffsetSectionBase = toSectionOffset(UnitDie.find(DW_AT_GNU_addr_base), 0);
-    RangeSectionBase = toSectionOffset(UnitDie.find(DW_AT_rnglists_base), 0);
+    Optional<DWARFFormValue> AddrBase = UnitDie.find(DW_AT_GNU_addr_base);
+    if (AddrBase)
+      AddrOffsetSectionBase = *toSectionOffset(AddrBase);
+    Optional<DWARFFormValue> RngListsBase = UnitDie.find(DW_AT_rnglists_base);
+    if (RngListsBase)
+      RangeSectionBase = *toSectionOffset(RngListsBase);
 
     // In general, we derive the offset of the unit's contibution to the
     // debug_str_offsets{.dwo} section from the unit DIE's




More information about the llvm-commits mailing list