<div dir="ltr"><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Jun 12, 2014 at 1:01 PM, David Blaikie <span dir="ltr"><<a href="mailto:dblaikie@gmail.com" target="_blank">dblaikie@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="HOEnZb"><div class="h5">On Thu, Jun 12, 2014 at 11:52 AM, Alexey Samsonov <<a href="mailto:vonosmas@gmail.com">vonosmas@gmail.com</a>> wrote:<br>

> Author: samsonov<br>
> Date: Thu Jun 12 13:52:35 2014<br>
> New Revision: 210809<br>
><br>
> URL: <a href="http://llvm.org/viewvc/llvm-project?rev=210809&view=rev" target="_blank">http://llvm.org/viewvc/llvm-project?rev=210809&view=rev</a><br>
> Log:<br>
> [llvm-symbolizer] Fix parsing DW_AT_ranges in Fission skeleton compile unit DIEs.<br>
><br>
> Turns out that DW_AT_ranges_base attribute sets the offset for<br>
> DW_AT_ranges values specified in the .dwo file, but not for DW_AT_ranges specified<br>
> in the skeleton compile unit DIE in the main executable. This is extremely confusing,<br>
> and would hopefully be fixed in DWARF-5 when it's finalized. For now this<br>
> behavior makes sense, as otherwise Fission would break DWARF consumers who<br>
> doesn't know anything about DW_AT_ranges_base.<br>
><br>
><br>
> Added:<br>
>     llvm/trunk/test/DebugInfo/Inputs/fission-ranges.cc<br>
>     llvm/trunk/test/DebugInfo/Inputs/fission-ranges.elf-x86_64   (with props)<br>
> Modified:<br>
>     llvm/trunk/lib/DebugInfo/DWARFUnit.cpp<br>
>     llvm/trunk/test/DebugInfo/llvm-symbolizer.test<br>
><br>
> Modified: llvm/trunk/lib/DebugInfo/DWARFUnit.cpp<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/DWARFUnit.cpp?rev=210809&r1=210808&r2=210809&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/DWARFUnit.cpp?rev=210809&r1=210808&r2=210809&view=diff</a><br>

> ==============================================================================<br>
> --- llvm/trunk/lib/DebugInfo/DWARFUnit.cpp (original)<br>
> +++ llvm/trunk/lib/DebugInfo/DWARFUnit.cpp Thu Jun 12 13:52:35 2014<br>
> @@ -225,8 +225,12 @@ size_t DWARFUnit::extractDIEsIfNeeded(bo<br>
>      setBaseAddress(BaseAddr);<br>
>      AddrOffsetSectionBase = DieArray[0].getAttributeValueAsSectionOffset(<br>
>          this, DW_AT_GNU_addr_base, 0);<br>
> -    RangeSectionBase = DieArray[0].getAttributeValueAsSectionOffset(<br>
> -        this, DW_AT_GNU_ranges_base, 0);<br>
> +    // Users of old DWARF may not know about DW_AT_ranges_base, so it is ignored<br>
> +    // for skeleton CU DIE (e.g. DW_AT_ranges are *not* relative to it).<br>
> +    if (Version > 4) {<br>
> +      RangeSectionBase = DieArray[0].getAttributeValueAsSectionOffset(<br>
> +          this, DW_AT_GNU_ranges_base, 0);<br>
<br>
</div></div>In theory (I say in theory, because we haven't implemented this yet)<br>
you shouldn't need to conditionalize by version, but just by attribute<br>
name. DW_AT_GNU_ranges_base would be relative for only the things in<br>
the dwo, and DW_AT_ranges_base will be relative for all the things in<br>
the dwo and .o.<br></blockquote><div><br></div><div>Sounds reasonable, submitted r210945 to remove version conditionalizing (and a fallback from DW_AT_ranges_base to DW_AT_GNU_ranges_base).</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

<div class="HOEnZb"><div class="h5"><br>
> +    }<br>
>    }<br>
><br>
>    setDIERelations();<br>
> @@ -272,7 +276,9 @@ bool DWARFUnit::parseDWO() {<br>
>    }<br>
>    // Share .debug_addr and .debug_ranges section with compile unit in .dwo<br>
>    DWOCU->setAddrOffsetSection(AddrOffsetSection, AddrOffsetSectionBase);<br>
> -  DWOCU->setRangesSection(RangeSection, RangeSectionBase);<br>
> +  uint32_t DWORangesBase = DieArray[0].getAttributeValueAsSectionOffset(<br>
> +      this, DW_AT_GNU_ranges_base, 0);<br>
> +  DWOCU->setRangesSection(RangeSection, DWORangesBase);<br>
>    return true;<br>
>  }<br>
><br>
><br>
> Added: llvm/trunk/test/DebugInfo/Inputs/fission-ranges.cc<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/Inputs/fission-ranges.cc?rev=210809&view=auto" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/Inputs/fission-ranges.cc?rev=210809&view=auto</a><br>

> ==============================================================================<br>
> --- llvm/trunk/test/DebugInfo/Inputs/fission-ranges.cc (added)<br>
> +++ llvm/trunk/test/DebugInfo/Inputs/fission-ranges.cc Thu Jun 12 13:52:35 2014<br>
> @@ -0,0 +1,17 @@<br>
> +static inline int inlined_f() {<br>
> +  volatile int x = 2;<br>
> +  return x;<br>
> +}<br>
> +<br>
> +int main() {<br>
> +  return inlined_f();<br>
> +}<br>
> +<br>
> +// Build instructions:<br>
> +// $ mkdir /tmp/dbginfo<br>
> +// $ cp fission-ranges.cc /tmp/dbginfo/<br>
> +// $ cd /tmp/dbginfo<br>
> +// $ gcc -gsplit-dwarf -O2 -fPIC fission-ranges.cc -c -o obj2.o<br>
> +// $ clang -gsplit-dwarf -O2 -fsanitize=address -fPIC -Dmain=foo fission-ranges.cc -c -o obj1.o<br>
> +// $ gcc obj1.o obj2.o -shared -o <output><br>
> +// $ objcopy --remove-section=.debug_aranges <output><br>
><br>
> Added: llvm/trunk/test/DebugInfo/Inputs/fission-ranges.elf-x86_64<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/Inputs/fission-ranges.elf-x86_64?rev=210809&view=auto" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/Inputs/fission-ranges.elf-x86_64?rev=210809&view=auto</a><br>

> ==============================================================================<br>
> Binary file - no diff available.<br>
><br>
> Propchange: llvm/trunk/test/DebugInfo/Inputs/fission-ranges.elf-x86_64<br>
> ------------------------------------------------------------------------------<br>
>     svn:executable = *<br>
><br>
> Propchange: llvm/trunk/test/DebugInfo/Inputs/fission-ranges.elf-x86_64<br>
> ------------------------------------------------------------------------------<br>
>     svn:mime-type = application/octet-stream<br>
><br>
> Modified: llvm/trunk/test/DebugInfo/llvm-symbolizer.test<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/llvm-symbolizer.test?rev=210809&r1=210808&r2=210809&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/llvm-symbolizer.test?rev=210809&r1=210808&r2=210809&view=diff</a><br>

> ==============================================================================<br>
> --- llvm/trunk/test/DebugInfo/llvm-symbolizer.test (original)<br>
> +++ llvm/trunk/test/DebugInfo/llvm-symbolizer.test Thu Jun 12 13:52:35 2014<br>
> @@ -17,6 +17,7 @@ RUN: echo "%p/Inputs/macho-universal 0x1<br>
>  RUN: echo "%p/Inputs/macho-universal:i386 0x1f67" >> %t.input<br>
>  RUN: echo "%p/Inputs/macho-universal:x86_64 0x100000f05" >> %t.input<br>
>  RUN: echo "%p/Inputs/llvm-symbolizer-dwo-test 0x400514" >> %t.input<br>
> +RUN: echo "%p/Inputs/fission-ranges.elf-x86_64 0x720" >> %t.input<br>
><br>
>  RUN: llvm-symbolizer --functions=linkage --inlining --demangle=false \<br>
>  RUN:    --default-arch=i386 < %t.input | FileCheck %s<br>
> @@ -90,6 +91,9 @@ CHECK:      _Z3inci<br>
>  CHECK: main<br>
>  CHECK-NEXT: llvm-symbolizer-dwo-test.cc:11<br>
><br>
> +CHECK: main<br>
> +CHECK-NEXT: {{.*}}fission-ranges.cc:6<br>
> +<br>
>  RUN: echo "unexisting-file 0x1234" > %t.input2<br>
>  RUN: llvm-symbolizer < %t.input2<br>
><br>
><br>
><br>
> _______________________________________________<br>
> llvm-commits mailing list<br>
> <a href="mailto:llvm-commits@cs.uiuc.edu">llvm-commits@cs.uiuc.edu</a><br>
> <a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits</a><br>
</div></div></blockquote></div><br><br clear="all"><div><br></div>-- <br><div dir="ltr">Alexey Samsonov<br><a href="mailto:vonosmas@gmail.com" target="_blank">vonosmas@gmail.com</a></div>
</div></div>