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

David Blaikie via llvm-commits llvm-commits at lists.llvm.org
Wed Aug 2 13:17:36 PDT 2017


Thanks for the quick fix.

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.

On Mon, Jul 31, 2017 at 8:33 AM Benjamin Kramer via llvm-commits <
llvm-commits at lists.llvm.org> wrote:

> 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
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170802/564a8b5f/attachment.html>


More information about the llvm-commits mailing list