[llvm] r265457 - llvm-dwp: Handle GCC's use of multiple debug_types.dwo sections in a single .dwo file

David Blaikie via llvm-commits llvm-commits at lists.llvm.org
Tue Apr 5 13:26:51 PDT 2016


Author: dblaikie
Date: Tue Apr  5 15:26:50 2016
New Revision: 265457

URL: http://llvm.org/viewvc/llvm-project?rev=265457&view=rev
Log:
llvm-dwp: Handle GCC's use of multiple debug_types.dwo sections in a single .dwo file

(also includes the .test file missing from my previous commit, r265452)

Added:
    llvm/trunk/test/tools/llvm-dwp/X86/gcc_type.test
Modified:
    llvm/trunk/tools/llvm-dwp/llvm-dwp.cpp

Added: llvm/trunk/test/tools/llvm-dwp/X86/gcc_type.test
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/tools/llvm-dwp/X86/gcc_type.test?rev=265457&view=auto
==============================================================================
--- llvm/trunk/test/tools/llvm-dwp/X86/gcc_type.test (added)
+++ llvm/trunk/test/tools/llvm-dwp/X86/gcc_type.test Tue Apr  5 15:26:50 2016
@@ -0,0 +1,9 @@
+RUN: llvm-dwp %p/../Inputs/gcc_type/a.dwo -o %t
+RUN: llvm-dwarfdump %t | FileCheck %s
+RUN: not llvm-dwp %p/../Inputs/gcc_type/a.dwo %p/../Inputs/gcc_type/a.dwo -o %t 2>&1 | FileCheck --check-prefix=DUP %s
+
+CHECK: Type Unit
+CHECK: Type Unit
+
+// Check that llvm-dwp can parse DW_FORM_string for CU name
+DUP: Duplicate DWO ID ({{.*}}) in 'a.cpp' and 'a.cpp'

Modified: llvm/trunk/tools/llvm-dwp/llvm-dwp.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-dwp/llvm-dwp.cpp?rev=265457&r1=265456&r2=265457&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-dwp/llvm-dwp.cpp (original)
+++ llvm/trunk/tools/llvm-dwp/llvm-dwp.cpp Tue Apr  5 15:26:50 2016
@@ -231,36 +231,36 @@ static void addAllTypesFromDWP(
 
 static void addAllTypes(MCStreamer &Out,
                         MapVector<uint64_t, UnitIndexEntry> &TypeIndexEntries,
-                        MCSection *OutputTypes, StringRef Types,
+                        MCSection *OutputTypes,
+                        const std::vector<StringRef> &TypesSections,
                         const UnitIndexEntry &CUEntry, uint32_t &TypesOffset) {
-  if (Types.empty())
-    return;
-
-  Out.SwitchSection(OutputTypes);
-  uint32_t Offset = 0;
-  DataExtractor Data(Types, true, 0);
-  while (Data.isValidOffset(Offset)) {
-    UnitIndexEntry Entry = CUEntry;
-    // Zero out the debug_info contribution
-    Entry.Contributions[0] = {};
-    auto &C = Entry.Contributions[DW_SECT_TYPES - DW_SECT_INFO];
-    C.Offset = TypesOffset;
-    auto PrevOffset = Offset;
-    // Length of the unit, including the 4 byte length field.
-    C.Length = Data.getU32(&Offset) + 4;
-
-    Data.getU16(&Offset); // Version
-    Data.getU32(&Offset); // Abbrev offset
-    Data.getU8(&Offset);  // Address size
-    auto Signature = Data.getU64(&Offset);
-    Offset = PrevOffset + C.Length;
+  for (StringRef Types : TypesSections) {
+    Out.SwitchSection(OutputTypes);
+    uint32_t Offset = 0;
+    DataExtractor Data(Types, true, 0);
+    while (Data.isValidOffset(Offset)) {
+      UnitIndexEntry Entry = CUEntry;
+      // Zero out the debug_info contribution
+      Entry.Contributions[0] = {};
+      auto &C = Entry.Contributions[DW_SECT_TYPES - DW_SECT_INFO];
+      C.Offset = TypesOffset;
+      auto PrevOffset = Offset;
+      // Length of the unit, including the 4 byte length field.
+      C.Length = Data.getU32(&Offset) + 4;
+
+      Data.getU16(&Offset); // Version
+      Data.getU32(&Offset); // Abbrev offset
+      Data.getU8(&Offset);  // Address size
+      auto Signature = Data.getU64(&Offset);
+      Offset = PrevOffset + C.Length;
 
-    auto P = TypeIndexEntries.insert(std::make_pair(Signature, Entry));
-    if (!P.second)
-      continue;
+      auto P = TypeIndexEntries.insert(std::make_pair(Signature, Entry));
+      if (!P.second)
+        continue;
 
-    Out.EmitBytes(Types.substr(PrevOffset, C.Length));
-    TypesOffset += C.Length;
+      Out.EmitBytes(Types.substr(PrevOffset, C.Length));
+      TypesOffset += C.Length;
+    }
   }
 }
 
@@ -399,7 +399,7 @@ static std::error_code write(MCStreamer
 
     StringRef CurStrSection;
     StringRef CurStrOffsetSection;
-    StringRef CurTypesSection;
+    std::vector<StringRef> CurTypesSection;
     StringRef InfoSection;
     StringRef AbbrevSection;
     StringRef CurCUIndexSection;
@@ -468,7 +468,7 @@ static std::error_code write(MCStreamer
       else if (OutSection == StrSection)
         CurStrSection = Contents;
       else if (OutSection == TypesSection)
-        CurTypesSection = Contents;
+        CurTypesSection.push_back(Contents);
       else if (OutSection == CUIndexSection)
         CurCUIndexSection = Contents;
       else if (OutSection == TUIndexSection)
@@ -517,6 +517,7 @@ static std::error_code write(MCStreamer
       }
 
       if (!CurTypesSection.empty()) {
+        assert(CurTypesSection.size() == 1);
         if (CurTUIndexSection.empty())
           return make_error_code(std::errc::invalid_argument);
         DWARFUnitIndex TUIndex(DW_SECT_TYPES);
@@ -525,7 +526,7 @@ static std::error_code write(MCStreamer
         if (!TUIndex.parse(TUIndexData))
           return make_error_code(std::errc::invalid_argument);
         addAllTypesFromDWP(Out, TypeIndexEntries, TUIndex, TypesSection,
-                           CurTypesSection, CurEntry,
+                           CurTypesSection.front(), CurEntry,
                            ContributionOffsets[DW_SECT_TYPES - DW_SECT_INFO]);
       }
     } else {




More information about the llvm-commits mailing list