[llvm] r267241 - llvm-symbolizer: Avoid infinite recursion walking dwos where the dwo contains a dwo_name attribute

David Blaikie via llvm-commits llvm-commits at lists.llvm.org
Fri Apr 22 15:50:56 PDT 2016


Author: dblaikie
Date: Fri Apr 22 17:50:56 2016
New Revision: 267241

URL: http://llvm.org/viewvc/llvm-project?rev=267241&view=rev
Log:
llvm-symbolizer: Avoid infinite recursion walking dwos where the dwo contains a dwo_name attribute

The dwo_name was added to dwo files to improve diagnostics in dwp, but
it confuses tools that attempt to load any dwo named by a dwo_name, even
ones inside dwos. Avoid this by keeping track of whether a unit is
already a dwo unit, and if so, not loading further dwos.

Added:
    llvm/trunk/test/DebugInfo/Inputs/split-dwarf-empty.dwo
    llvm/trunk/test/DebugInfo/Inputs/split-dwarf-empty.o
    llvm/trunk/test/DebugInfo/llvm-symbolizer-split-dwarf-empty.test
Modified:
    llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFCompileUnit.h
    llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFTypeUnit.h
    llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFUnit.h
    llvm/trunk/lib/DebugInfo/DWARF/DWARFUnit.cpp

Modified: llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFCompileUnit.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFCompileUnit.h?rev=267241&r1=267240&r2=267241&view=diff
==============================================================================
--- llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFCompileUnit.h (original)
+++ llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFCompileUnit.h Fri Apr 22 17:50:56 2016
@@ -19,10 +19,10 @@ public:
   DWARFCompileUnit(DWARFContext &Context, const DWARFSection &Section,
                    const DWARFDebugAbbrev *DA, StringRef RS, StringRef SS,
                    StringRef SOS, StringRef AOS, StringRef LS, bool LE,
-                   const DWARFUnitSectionBase &UnitSection,
+                   bool IsDWO, const DWARFUnitSectionBase &UnitSection,
                    const DWARFUnitIndex::Entry *Entry)
-      : DWARFUnit(Context, Section, DA, RS, SS, SOS, AOS, LS, LE, UnitSection,
-                  Entry) {}
+      : DWARFUnit(Context, Section, DA, RS, SS, SOS, AOS, LS, LE, IsDWO,
+                  UnitSection, Entry) {}
   void dump(raw_ostream &OS);
   static const DWARFSectionKind Section = DW_SECT_INFO;
   // VTable anchor.

Modified: llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFTypeUnit.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFTypeUnit.h?rev=267241&r1=267240&r2=267241&view=diff
==============================================================================
--- llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFTypeUnit.h (original)
+++ llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFTypeUnit.h Fri Apr 22 17:50:56 2016
@@ -21,11 +21,11 @@ private:
 public:
   DWARFTypeUnit(DWARFContext &Context, const DWARFSection &Section,
                 const DWARFDebugAbbrev *DA, StringRef RS, StringRef SS,
-                StringRef SOS, StringRef AOS, StringRef LS, bool LE,
+                StringRef SOS, StringRef AOS, StringRef LS, bool LE, bool IsDWO,
                 const DWARFUnitSectionBase &UnitSection,
                 const DWARFUnitIndex::Entry *Entry)
-      : DWARFUnit(Context, Section, DA, RS, SS, SOS, AOS, LS, LE, UnitSection,
-                  Entry) {}
+      : DWARFUnit(Context, Section, DA, RS, SS, SOS, AOS, LS, LE, IsDWO,
+                  UnitSection, Entry) {}
   uint32_t getHeaderSize() const override {
     return DWARFUnit::getHeaderSize() + 12;
   }

Modified: llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFUnit.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFUnit.h?rev=267241&r1=267240&r2=267241&view=diff
==============================================================================
--- llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFUnit.h (original)
+++ llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFUnit.h Fri Apr 22 17:50:56 2016
@@ -47,7 +47,7 @@ protected:
   virtual void parseImpl(DWARFContext &Context, const DWARFSection &Section,
                          const DWARFDebugAbbrev *DA, StringRef RS, StringRef SS,
                          StringRef SOS, StringRef AOS, StringRef LS,
-                         bool isLittleEndian) = 0;
+                         bool isLittleEndian, bool isDWO) = 0;
 
   ~DWARFUnitSectionBase() = default;
 };
@@ -80,7 +80,8 @@ public:
 private:
   void parseImpl(DWARFContext &Context, const DWARFSection &Section,
                  const DWARFDebugAbbrev *DA, StringRef RS, StringRef SS,
-                 StringRef SOS, StringRef AOS, StringRef LS, bool LE) override {
+                 StringRef SOS, StringRef AOS, StringRef LS, bool LE,
+                 bool IsDWO) override {
     if (Parsed)
       return;
     const auto &Index = getDWARFUnitIndex(Context, UnitType::Section);
@@ -88,7 +89,7 @@ private:
     uint32_t Offset = 0;
     while (Data.isValidOffset(Offset)) {
       auto U = llvm::make_unique<UnitType>(Context, Section, DA, RS, SS, SOS,
-                                           AOS, LS, LE, *this,
+                                           AOS, LS, LE, IsDWO, *this,
                                            Index.getFromOffset(Offset));
       if (!U->extract(Data, &Offset))
         break;
@@ -113,6 +114,7 @@ class DWARFUnit {
   StringRef AddrOffsetSection;
   uint32_t AddrOffsetSectionBase;
   bool isLittleEndian;
+  bool isDWO;
   const DWARFUnitSectionBase &UnitSection;
 
   uint32_t Offset;
@@ -144,7 +146,7 @@ protected:
 public:
   DWARFUnit(DWARFContext &Context, const DWARFSection &Section,
             const DWARFDebugAbbrev *DA, StringRef RS, StringRef SS,
-            StringRef SOS, StringRef AOS, StringRef LS, bool LE,
+            StringRef SOS, StringRef AOS, StringRef LS, bool LE, bool IsDWO,
             const DWARFUnitSectionBase &UnitSection,
             const DWARFUnitIndex::Entry *IndexEntry = nullptr);
 

Modified: llvm/trunk/lib/DebugInfo/DWARF/DWARFUnit.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/DWARF/DWARFUnit.cpp?rev=267241&r1=267240&r2=267241&view=diff
==============================================================================
--- llvm/trunk/lib/DebugInfo/DWARF/DWARFUnit.cpp (original)
+++ llvm/trunk/lib/DebugInfo/DWARF/DWARFUnit.cpp Fri Apr 22 17:50:56 2016
@@ -20,7 +20,7 @@ using namespace dwarf;
 void DWARFUnitSectionBase::parse(DWARFContext &C, const DWARFSection &Section) {
   parseImpl(C, Section, C.getDebugAbbrev(), C.getRangeSection(),
             C.getStringSection(), StringRef(), C.getAddrSection(),
-            C.getLineSection().Data, C.isLittleEndian());
+            C.getLineSection().Data, C.isLittleEndian(), false);
 }
 
 void DWARFUnitSectionBase::parseDWO(DWARFContext &C,
@@ -28,13 +28,14 @@ void DWARFUnitSectionBase::parseDWO(DWAR
                                     DWARFUnitIndex *Index) {
   parseImpl(C, DWOSection, C.getDebugAbbrevDWO(), C.getRangeDWOSection(),
             C.getStringDWOSection(), C.getStringOffsetDWOSection(),
-            C.getAddrSection(), C.getLineDWOSection().Data, C.isLittleEndian());
+            C.getAddrSection(), C.getLineDWOSection().Data, C.isLittleEndian(),
+            true);
 }
 
 DWARFUnit::DWARFUnit(DWARFContext &DC, const DWARFSection &Section,
                      const DWARFDebugAbbrev *DA, StringRef RS, StringRef SS,
                      StringRef SOS, StringRef AOS, StringRef LS, bool LE,
-                     const DWARFUnitSectionBase &UnitSection,
+                     bool IsDWO, const DWARFUnitSectionBase &UnitSection,
                      const DWARFUnitIndex::Entry *IndexEntry)
     : Context(DC), InfoSection(Section), Abbrev(DA), RangeSection(RS),
       LineSection(LS), StringSection(SS), StringOffsetSection([&]() {
@@ -43,8 +44,8 @@ DWARFUnit::DWARFUnit(DWARFContext &DC, c
             return SOS.slice(C->Offset, C->Offset + C->Length);
         return SOS;
       }()),
-      AddrOffsetSection(AOS), isLittleEndian(LE), UnitSection(UnitSection),
-      IndexEntry(IndexEntry) {
+      AddrOffsetSection(AOS), isLittleEndian(LE), isDWO(IsDWO),
+      UnitSection(UnitSection), IndexEntry(IndexEntry) {
   clear();
 }
 
@@ -281,6 +282,8 @@ DWARFUnit::DWOHolder::DWOHolder(StringRe
 }
 
 bool DWARFUnit::parseDWO() {
+  if (isDWO)
+    return false;
   if (DWO.get())
     return false;
   extractDIEsIfNeeded(true);

Added: llvm/trunk/test/DebugInfo/Inputs/split-dwarf-empty.dwo
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/Inputs/split-dwarf-empty.dwo?rev=267241&view=auto
==============================================================================
Binary files llvm/trunk/test/DebugInfo/Inputs/split-dwarf-empty.dwo (added) and llvm/trunk/test/DebugInfo/Inputs/split-dwarf-empty.dwo Fri Apr 22 17:50:56 2016 differ

Added: llvm/trunk/test/DebugInfo/Inputs/split-dwarf-empty.o
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/Inputs/split-dwarf-empty.o?rev=267241&view=auto
==============================================================================
Binary files llvm/trunk/test/DebugInfo/Inputs/split-dwarf-empty.o (added) and llvm/trunk/test/DebugInfo/Inputs/split-dwarf-empty.o Fri Apr 22 17:50:56 2016 differ

Added: llvm/trunk/test/DebugInfo/llvm-symbolizer-split-dwarf-empty.test
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/llvm-symbolizer-split-dwarf-empty.test?rev=267241&view=auto
==============================================================================
--- llvm/trunk/test/DebugInfo/llvm-symbolizer-split-dwarf-empty.test (added)
+++ llvm/trunk/test/DebugInfo/llvm-symbolizer-split-dwarf-empty.test Fri Apr 22 17:50:56 2016
@@ -0,0 +1,10 @@
+REQUIRES: shell
+RUN: cd Output
+RUN: cp %p/Inputs/split-dwarf-empty.dwo %T
+RUN: echo "%p/Inputs/split-dwarf-empty.o 0xdeadbeef" > %t.input
+
+RUN: llvm-symbolizer --functions=linkage --inlining --demangle=false \
+RUN:    --default-arch=i386 < %t.input | FileCheck %s
+
+CHECK: ??
+CHECK: ??:0:0




More information about the llvm-commits mailing list