[llvm] r210809 - [llvm-symbolizer] Fix parsing DW_AT_ranges in Fission skeleton compile unit DIEs.

Alexey Samsonov vonosmas at gmail.com
Fri Jun 13 15:40:08 PDT 2014


On Thu, Jun 12, 2014 at 1:01 PM, David Blaikie <dblaikie at gmail.com> wrote:

> On Thu, Jun 12, 2014 at 11:52 AM, Alexey Samsonov <vonosmas at gmail.com>
> wrote:
> > Author: samsonov
> > Date: Thu Jun 12 13:52:35 2014
> > New Revision: 210809
> >
> > URL: http://llvm.org/viewvc/llvm-project?rev=210809&view=rev
> > Log:
> > [llvm-symbolizer] Fix parsing DW_AT_ranges in Fission skeleton compile
> unit DIEs.
> >
> > Turns out that DW_AT_ranges_base attribute sets the offset for
> > DW_AT_ranges values specified in the .dwo file, but not for DW_AT_ranges
> specified
> > in the skeleton compile unit DIE in the main executable. This is
> extremely confusing,
> > and would hopefully be fixed in DWARF-5 when it's finalized. For now this
> > behavior makes sense, as otherwise Fission would break DWARF consumers
> who
> > doesn't know anything about DW_AT_ranges_base.
> >
> >
> > Added:
> >     llvm/trunk/test/DebugInfo/Inputs/fission-ranges.cc
> >     llvm/trunk/test/DebugInfo/Inputs/fission-ranges.elf-x86_64   (with
> props)
> > Modified:
> >     llvm/trunk/lib/DebugInfo/DWARFUnit.cpp
> >     llvm/trunk/test/DebugInfo/llvm-symbolizer.test
> >
> > Modified: llvm/trunk/lib/DebugInfo/DWARFUnit.cpp
> > URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/DWARFUnit.cpp?rev=210809&r1=210808&r2=210809&view=diff
> >
> ==============================================================================
> > --- llvm/trunk/lib/DebugInfo/DWARFUnit.cpp (original)
> > +++ llvm/trunk/lib/DebugInfo/DWARFUnit.cpp Thu Jun 12 13:52:35 2014
> > @@ -225,8 +225,12 @@ size_t DWARFUnit::extractDIEsIfNeeded(bo
> >      setBaseAddress(BaseAddr);
> >      AddrOffsetSectionBase =
> DieArray[0].getAttributeValueAsSectionOffset(
> >          this, DW_AT_GNU_addr_base, 0);
> > -    RangeSectionBase = DieArray[0].getAttributeValueAsSectionOffset(
> > -        this, DW_AT_GNU_ranges_base, 0);
> > +    // Users of old DWARF may not know about DW_AT_ranges_base, so it
> is ignored
> > +    // for skeleton CU DIE (e.g. DW_AT_ranges are *not* relative to it).
> > +    if (Version > 4) {
> > +      RangeSectionBase = DieArray[0].getAttributeValueAsSectionOffset(
> > +          this, DW_AT_GNU_ranges_base, 0);
>
> In theory (I say in theory, because we haven't implemented this yet)
> you shouldn't need to conditionalize by version, but just by attribute
> name. DW_AT_GNU_ranges_base would be relative for only the things in
> the dwo, and DW_AT_ranges_base will be relative for all the things in
> the dwo and .o.
>

Sounds reasonable, submitted r210945 to remove version conditionalizing
(and a fallback from DW_AT_ranges_base to DW_AT_GNU_ranges_base).


>
> > +    }
> >    }
> >
> >    setDIERelations();
> > @@ -272,7 +276,9 @@ bool DWARFUnit::parseDWO() {
> >    }
> >    // Share .debug_addr and .debug_ranges section with compile unit in
> .dwo
> >    DWOCU->setAddrOffsetSection(AddrOffsetSection, AddrOffsetSectionBase);
> > -  DWOCU->setRangesSection(RangeSection, RangeSectionBase);
> > +  uint32_t DWORangesBase = DieArray[0].getAttributeValueAsSectionOffset(
> > +      this, DW_AT_GNU_ranges_base, 0);
> > +  DWOCU->setRangesSection(RangeSection, DWORangesBase);
> >    return true;
> >  }
> >
> >
> > Added: llvm/trunk/test/DebugInfo/Inputs/fission-ranges.cc
> > URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/Inputs/fission-ranges.cc?rev=210809&view=auto
> >
> ==============================================================================
> > --- llvm/trunk/test/DebugInfo/Inputs/fission-ranges.cc (added)
> > +++ llvm/trunk/test/DebugInfo/Inputs/fission-ranges.cc Thu Jun 12
> 13:52:35 2014
> > @@ -0,0 +1,17 @@
> > +static inline int inlined_f() {
> > +  volatile int x = 2;
> > +  return x;
> > +}
> > +
> > +int main() {
> > +  return inlined_f();
> > +}
> > +
> > +// Build instructions:
> > +// $ mkdir /tmp/dbginfo
> > +// $ cp fission-ranges.cc /tmp/dbginfo/
> > +// $ cd /tmp/dbginfo
> > +// $ gcc -gsplit-dwarf -O2 -fPIC fission-ranges.cc -c -o obj2.o
> > +// $ clang -gsplit-dwarf -O2 -fsanitize=address -fPIC -Dmain=foo
> fission-ranges.cc -c -o obj1.o
> > +// $ gcc obj1.o obj2.o -shared -o <output>
> > +// $ objcopy --remove-section=.debug_aranges <output>
> >
> > Added: llvm/trunk/test/DebugInfo/Inputs/fission-ranges.elf-x86_64
> > URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/Inputs/fission-ranges.elf-x86_64?rev=210809&view=auto
> >
> ==============================================================================
> > Binary file - no diff available.
> >
> > Propchange: llvm/trunk/test/DebugInfo/Inputs/fission-ranges.elf-x86_64
> >
> ------------------------------------------------------------------------------
> >     svn:executable = *
> >
> > Propchange: llvm/trunk/test/DebugInfo/Inputs/fission-ranges.elf-x86_64
> >
> ------------------------------------------------------------------------------
> >     svn:mime-type = application/octet-stream
> >
> > Modified: llvm/trunk/test/DebugInfo/llvm-symbolizer.test
> > URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/llvm-symbolizer.test?rev=210809&r1=210808&r2=210809&view=diff
> >
> ==============================================================================
> > --- llvm/trunk/test/DebugInfo/llvm-symbolizer.test (original)
> > +++ llvm/trunk/test/DebugInfo/llvm-symbolizer.test Thu Jun 12 13:52:35
> 2014
> > @@ -17,6 +17,7 @@ RUN: echo "%p/Inputs/macho-universal 0x1
> >  RUN: echo "%p/Inputs/macho-universal:i386 0x1f67" >> %t.input
> >  RUN: echo "%p/Inputs/macho-universal:x86_64 0x100000f05" >> %t.input
> >  RUN: echo "%p/Inputs/llvm-symbolizer-dwo-test 0x400514" >> %t.input
> > +RUN: echo "%p/Inputs/fission-ranges.elf-x86_64 0x720" >> %t.input
> >
> >  RUN: llvm-symbolizer --functions=linkage --inlining --demangle=false \
> >  RUN:    --default-arch=i386 < %t.input | FileCheck %s
> > @@ -90,6 +91,9 @@ CHECK:      _Z3inci
> >  CHECK: main
> >  CHECK-NEXT: llvm-symbolizer-dwo-test.cc:11
> >
> > +CHECK: main
> > +CHECK-NEXT: {{.*}}fission-ranges.cc:6
> > +
> >  RUN: echo "unexisting-file 0x1234" > %t.input2
> >  RUN: llvm-symbolizer < %t.input2
> >
> >
> >
> > _______________________________________________
> > llvm-commits mailing list
> > llvm-commits at cs.uiuc.edu
> > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
>



-- 
Alexey Samsonov
vonosmas at gmail.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20140613/6cf868b5/attachment.html>


More information about the llvm-commits mailing list