<div dir="ltr">Thanks for the help. Should be fixed in r253395</div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Nov 17, 2015 at 3:19 PM, Reid Kleckner <span dir="ltr"><<a href="mailto:rnk@google.com" target="_blank">rnk@google.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Appears to still be busted locally.</div><div class="HOEnZb"><div class="h5"><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Nov 17, 2015 at 2:42 PM, David Blaikie via llvm-commits <span dir="ltr"><<a href="mailto:llvm-commits@lists.llvm.org" target="_blank">llvm-commits@lists.llvm.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Right, sorry about that. Hopefully fixed by r253392</div><div><div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Nov 17, 2015 at 2:33 PM, NAKAMURA Takumi <span dir="ltr"><<a href="mailto:geek4civic@gmail.com" target="_blank">geek4civic@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 dir="ltr">It broke msvc build; <a href="http://lab.llvm.org:8011/builders/clang-x64-ninja-win7/builds/7363" target="_blank">http://lab.llvm.org:8011/builders/clang-x64-ninja-win7/builds/7363</a><br></div><div><div><br><div class="gmail_quote"><div dir="ltr">On Tue, Nov 17, 2015 at 9:42 AM David Blaikie via llvm-commits <<a href="mailto:llvm-commits@lists.llvm.org" target="_blank">llvm-commits@lists.llvm.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: dblaikie<br>
Date: Mon Nov 16 18:39:55 2015<br>
New Revision: 253277<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=253277&view=rev" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project?rev=253277&view=rev</a><br>
Log:<br>
dwarfdump: Use the index to find the right abbrev offset in DWP files<br>
<br>
Modified:<br>
    llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFCompileUnit.h<br>
    llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFContext.h<br>
    llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFTypeUnit.h<br>
    llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFUnit.h<br>
    llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFUnitIndex.h<br>
    llvm/trunk/lib/DebugInfo/DWARF/DWARFContext.cpp<br>
    llvm/trunk/lib/DebugInfo/DWARF/DWARFUnit.cpp<br>
    llvm/trunk/lib/DebugInfo/DWARF/DWARFUnitIndex.cpp<br>
    llvm/trunk/test/DebugInfo/Inputs/dwarfdump-dwp.x86_64.o<br>
    llvm/trunk/test/DebugInfo/dwarfdump-dwp.test<br>
<br>
Modified: llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFCompileUnit.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFCompileUnit.h?rev=253277&r1=253276&r2=253277&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFCompileUnit.h?rev=253277&r1=253276&r2=253277&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFCompileUnit.h (original)<br>
+++ llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFCompileUnit.h Mon Nov 16 18:39:55 2015<br>
@@ -19,9 +19,12 @@ public:<br>
   DWARFCompileUnit(DWARFContext &Context, const DWARFSection &Section,<br>
                    const DWARFDebugAbbrev *DA, StringRef RS, StringRef SS,<br>
                    StringRef SOS, StringRef AOS, bool LE,<br>
-                   const DWARFUnitSectionBase &UnitSection)<br>
-      : DWARFUnit(Context, Section, DA, RS, SS, SOS, AOS, LE, UnitSection) {}<br>
+                   const DWARFUnitSectionBase &UnitSection,<br>
+                   const DWARFUnitIndex::Entry *Entry)<br>
+      : DWARFUnit(Context, Section, DA, RS, SS, SOS, AOS, LE, UnitSection,<br>
+                  Entry) {}<br>
   void dump(raw_ostream &OS);<br>
+  static const DWARFSectionKind Section = DW_SECT_INFO;<br>
   // VTable anchor.<br>
   ~DWARFCompileUnit() override;<br>
 };<br>
<br>
Modified: llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFContext.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFContext.h?rev=253277&r1=253276&r2=253277&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFContext.h?rev=253277&r1=253276&r2=253277&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFContext.h (original)<br>
+++ llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFContext.h Mon Nov 16 18:39:55 2015<br>
@@ -41,6 +41,8 @@ class DWARFContext : public DIContext {<br>
<br>
   DWARFUnitSection<DWARFCompileUnit> CUs;<br>
   std::vector<DWARFUnitSection<DWARFTypeUnit>> TUs;<br>
+  std::unique_ptr<DWARFUnitIndex> CUIndex;<br>
+  std::unique_ptr<DWARFUnitIndex> TUIndex;<br>
   std::unique_ptr<DWARFDebugAbbrev> Abbrev;<br>
   std::unique_ptr<DWARFDebugLoc> Loc;<br>
   std::unique_ptr<DWARFDebugAranges> Aranges;<br>
@@ -145,6 +147,9 @@ public:<br>
     return DWOCUs[index].get();<br>
   }<br>
<br>
+  const DWARFUnitIndex &getCUIndex();<br>
+  const DWARFUnitIndex &getTUIndex();<br>
+<br>
   /// Get a pointer to the parsed DebugAbbrev object.<br>
   const DWARFDebugAbbrev *getDebugAbbrev();<br>
<br>
<br>
Modified: llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFTypeUnit.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFTypeUnit.h?rev=253277&r1=253276&r2=253277&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFTypeUnit.h?rev=253277&r1=253276&r2=253277&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFTypeUnit.h (original)<br>
+++ llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFTypeUnit.h Mon Nov 16 18:39:55 2015<br>
@@ -22,12 +22,16 @@ public:<br>
   DWARFTypeUnit(DWARFContext &Context, const DWARFSection &Section,<br>
                 const DWARFDebugAbbrev *DA, StringRef RS, StringRef SS,<br>
                 StringRef SOS, StringRef AOS, bool LE,<br>
-                const DWARFUnitSectionBase &UnitSection)<br>
-      : DWARFUnit(Context, Section, DA, RS, SS, SOS, AOS, LE, UnitSection) {}<br>
+                const DWARFUnitSectionBase &UnitSection,<br>
+                const DWARFUnitIndex::Entry *Entry)<br>
+      : DWARFUnit(Context, Section, DA, RS, SS, SOS, AOS, LE, UnitSection,<br>
+                  Entry) {}<br>
   uint32_t getHeaderSize() const override {<br>
     return DWARFUnit::getHeaderSize() + 12;<br>
   }<br>
   void dump(raw_ostream &OS);<br>
+  static const DWARFSectionKind Section = DW_SECT_TYPES;<br>
+<br>
 protected:<br>
   bool extractImpl(DataExtractor debug_info, uint32_t *offset_ptr) override;<br>
 };<br>
<br>
Modified: llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFUnit.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFUnit.h?rev=253277&r1=253276&r2=253277&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFUnit.h?rev=253277&r1=253276&r2=253277&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFUnit.h (original)<br>
+++ llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFUnit.h Mon Nov 16 18:39:55 2015<br>
@@ -16,6 +16,7 @@<br>
 #include "llvm/DebugInfo/DWARF/DWARFDebugRangeList.h"<br>
 #include "llvm/DebugInfo/DWARF/DWARFRelocMap.h"<br>
 #include "llvm/DebugInfo/DWARF/DWARFSection.h"<br>
+#include "llvm/DebugInfo/DWARF/DWARFUnitIndex.h"<br>
 #include <vector><br>
<br>
 namespace llvm {<br>
@@ -39,7 +40,8 @@ public:<br>
   virtual DWARFUnit *getUnitForOffset(uint32_t Offset) const = 0;<br>
<br>
   void parse(DWARFContext &C, const DWARFSection &Section);<br>
-  void parseDWO(DWARFContext &C, const DWARFSection &DWOSection);<br>
+  void parseDWO(DWARFContext &C, const DWARFSection &DWOSection,<br>
+                DWARFUnitIndex *Index = nullptr);<br>
<br>
 protected:<br>
   virtual void parseImpl(DWARFContext &Context, const DWARFSection &Section,<br>
@@ -49,6 +51,9 @@ protected:<br>
   ~DWARFUnitSectionBase() = default;<br>
 };<br>
<br>
+const DWARFUnitIndex &getDWARFUnitIndex(DWARFContext &Context,<br>
+                                        DWARFSectionKind Kind);<br>
+<br>
 /// Concrete instance of DWARFUnitSection, specialized for one Unit type.<br>
 template<typename UnitType><br>
 class DWARFUnitSection final : public SmallVector<std::unique_ptr<UnitType>, 1>,<br>
@@ -81,11 +86,13 @@ private:<br>
                  StringRef SOS, StringRef AOS, bool LE) override {<br>
     if (Parsed)<br>
       return;<br>
+    const auto &Index = getDWARFUnitIndex(Context, UnitType::Section);<br>
     DataExtractor Data(Section.Data, LE, 0);<br>
     uint32_t Offset = 0;<br>
     while (Data.isValidOffset(Offset)) {<br>
-      auto U = llvm::make_unique<UnitType>(Context, Section, DA, RS, SS, SOS,<br>
-                                           AOS, LE, *this);<br>
+      auto U =<br>
+          llvm::make_unique<UnitType>(Context, Section, DA, RS, SS, SOS, AOS,<br>
+                                      LE, *this, Index.getFromOffset(Offset));<br>
       if (!U->extract(Data, &Offset))<br>
         break;<br>
       this->push_back(std::move(U));<br>
@@ -129,6 +136,8 @@ class DWARFUnit {<br>
   };<br>
   std::unique_ptr<DWOHolder> DWO;<br>
<br>
+  const DWARFUnitIndex::Entry *IndexEntry;<br>
+<br>
 protected:<br>
   virtual bool extractImpl(DataExtractor debug_info, uint32_t *offset_ptr);<br>
   /// Size in bytes of the unit header.<br>
@@ -138,7 +147,8 @@ public:<br>
   DWARFUnit(DWARFContext &Context, const DWARFSection &Section,<br>
             const DWARFDebugAbbrev *DA, StringRef RS, StringRef SS,<br>
             StringRef SOS, StringRef AOS, bool LE,<br>
-            const DWARFUnitSectionBase &UnitSection);<br>
+            const DWARFUnitSectionBase &UnitSection,<br>
+            const DWARFUnitIndex::Entry *IndexEntry = nullptr);<br>
<br>
   virtual ~DWARFUnit();<br>
<br>
<br>
Modified: llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFUnitIndex.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFUnitIndex.h?rev=253277&r1=253276&r2=253277&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFUnitIndex.h?rev=253277&r1=253276&r2=253277&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFUnitIndex.h (original)<br>
+++ llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFUnitIndex.h Mon Nov 16 18:39:55 2015<br>
@@ -17,6 +17,17 @@<br>
<br>
 namespace llvm {<br>
<br>
+enum DWARFSectionKind {<br>
+  DW_SECT_INFO = 1,<br>
+  DW_SECT_TYPES,<br>
+  DW_SECT_ABBREV,<br>
+  DW_SECT_LINE,<br>
+  DW_SECT_LOC,<br>
+  DW_SECT_STR_OFFSETS,<br>
+  DW_SECT_MACINFO,<br>
+  DW_SECT_MACRO,<br>
+};<br>
+<br>
 class DWARFUnitIndex {<br>
   struct Header {<br>
     uint32_t Version;<br>
@@ -28,36 +39,34 @@ class DWARFUnitIndex {<br>
     void dump(raw_ostream &OS) const;<br>
   };<br>
<br>
-  struct HashRow {<br>
+public:<br>
+  class Entry {<br>
+    const DWARFUnitIndex *Index;<br>
     uint64_t Signature;<br>
     struct SectionContribution {<br>
       uint32_t Offset;<br>
-      uint32_t Size;<br>
+      uint32_t Length;<br>
     };<br>
     std::unique_ptr<SectionContribution[]> Contributions;<br>
-  };<br>
+    friend class DWARFUnitIndex;<br>
<br>
-  enum DwarfSection {<br>
-    DW_SECT_INFO = 1,<br>
-    DW_SECT_TYPES,<br>
-    DW_SECT_ABBREV,<br>
-    DW_SECT_LINE,<br>
-    DW_SECT_LOC,<br>
-    DW_SECT_STR_OFFSETS,<br>
-    DW_SECT_MACINFO,<br>
-    DW_SECT_MACRO,<br>
+  public:<br>
+    const SectionContribution *getOffset(DWARFSectionKind Sec) const;<br>
+    const SectionContribution *getOffset() const;<br>
   };<br>
<br>
   struct Header Header;<br>
<br>
-  std::unique_ptr<DwarfSection[]> ColumnKinds;<br>
-  std::unique_ptr<HashRow[]> Rows;<br>
+  int InfoColumn = -1;<br>
+  std::unique_ptr<DWARFSectionKind[]> ColumnKinds;<br>
+  std::unique_ptr<Entry[]> Rows;<br>
<br>
-  static StringRef getColumnHeader(DwarfSection DS);<br>
+  static StringRef getColumnHeader(DWARFSectionKind DS);<br>
<br>
 public:<br>
   bool parse(DataExtractor IndexData);<br>
   void dump(raw_ostream &OS) const;<br>
+  const Entry *getFromOffset(uint32_t Offset) const;<br>
 };<br>
 }<br>
<br>
<br>
Modified: llvm/trunk/lib/DebugInfo/DWARF/DWARFContext.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/DWARF/DWARFContext.cpp?rev=253277&r1=253276&r2=253277&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/DWARF/DWARFContext.cpp?rev=253277&r1=253276&r2=253277&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/lib/DebugInfo/DWARF/DWARFContext.cpp (original)<br>
+++ llvm/trunk/lib/DebugInfo/DWARF/DWARFContext.cpp Mon Nov 16 18:39:55 2015<br>
@@ -274,6 +274,28 @@ void DWARFContext::dump(raw_ostream &OS,<br>
                      getStringSection(), isLittleEndian());<br>
 }<br>
<br>
+const DWARFUnitIndex &DWARFContext::getCUIndex() {<br>
+  if (CUIndex)<br>
+    return *CUIndex;<br>
+<br>
+  DataExtractor CUIndexData(getCUIndexSection(), isLittleEndian(), 0);<br>
+<br>
+  CUIndex = llvm::make_unique<DWARFUnitIndex>();<br>
+  CUIndex->parse(CUIndexData);<br>
+  return *CUIndex;<br>
+}<br>
+<br>
+const DWARFUnitIndex &DWARFContext::getTUIndex() {<br>
+  if (TUIndex)<br>
+    return *TUIndex;<br>
+<br>
+  DataExtractor TUIndexData(getTUIndexSection(), isLittleEndian(), 0);<br>
+<br>
+  TUIndex = llvm::make_unique<DWARFUnitIndex>();<br>
+  TUIndex->parse(TUIndexData);<br>
+  return *TUIndex;<br>
+}<br>
+<br>
 const DWARFDebugAbbrev *DWARFContext::getDebugAbbrev() {<br>
   if (Abbrev)<br>
     return Abbrev.get();<br>
<br>
Modified: llvm/trunk/lib/DebugInfo/DWARF/DWARFUnit.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/DWARF/DWARFUnit.cpp?rev=253277&r1=253276&r2=253277&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/DWARF/DWARFUnit.cpp?rev=253277&r1=253276&r2=253277&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/lib/DebugInfo/DWARF/DWARFUnit.cpp (original)<br>
+++ llvm/trunk/lib/DebugInfo/DWARF/DWARFUnit.cpp Mon Nov 16 18:39:55 2015<br>
@@ -14,7 +14,7 @@<br>
 #include "llvm/Support/Path.h"<br>
 #include <cstdio><br>
<br>
-using namespace llvm;<br>
+namespace llvm {<br>
 using namespace dwarf;<br>
<br>
 void DWARFUnitSectionBase::parse(DWARFContext &C, const DWARFSection &Section) {<br>
@@ -24,7 +24,8 @@ void DWARFUnitSectionBase::parse(DWARFCo<br>
 }<br>
<br>
 void DWARFUnitSectionBase::parseDWO(DWARFContext &C,<br>
-                                    const DWARFSection &DWOSection) {<br>
+                                    const DWARFSection &DWOSection,<br>
+                                    DWARFUnitIndex *Index) {<br>
   parseImpl(C, DWOSection, C.getDebugAbbrevDWO(), C.getRangeDWOSection(),<br>
             C.getStringDWOSection(), C.getStringOffsetDWOSection(),<br>
             C.getAddrSection(), C.isLittleEndian());<br>
@@ -33,10 +34,11 @@ void DWARFUnitSectionBase::parseDWO(DWAR<br>
 DWARFUnit::DWARFUnit(DWARFContext &DC, const DWARFSection &Section,<br>
                      const DWARFDebugAbbrev *DA, StringRef RS, StringRef SS,<br>
                      StringRef SOS, StringRef AOS, bool LE,<br>
-                     const DWARFUnitSectionBase &UnitSection)<br>
+                     const DWARFUnitSectionBase &UnitSection,<br>
+                     const DWARFUnitIndex::Entry *IndexEntry)<br>
     : Context(DC), InfoSection(Section), Abbrev(DA), RangeSection(RS),<br>
       StringSection(SS), StringOffsetSection(SOS), AddrOffsetSection(AOS),<br>
-      isLittleEndian(LE), UnitSection(UnitSection) {<br>
+      isLittleEndian(LE), UnitSection(UnitSection), IndexEntry(IndexEntry) {<br>
   clear();<br>
 }<br>
<br>
@@ -69,6 +71,17 @@ bool DWARFUnit::extractImpl(DataExtracto<br>
   Length = debug_info.getU32(offset_ptr);<br>
   Version = debug_info.getU16(offset_ptr);<br>
   uint64_t AbbrOffset = debug_info.getU32(offset_ptr);<br>
+  if (IndexEntry) {<br>
+    if (AbbrOffset)<br>
+      return false;<br>
+    auto *UnitContrib = IndexEntry->getOffset();<br>
+    if (!UnitContrib || UnitContrib->Length != (Length + 4))<br>
+      return false;<br>
+    auto *AbbrEntry = IndexEntry->getOffset(DW_SECT_ABBREV);<br>
+    if (!AbbrEntry)<br>
+      return false;<br>
+    AbbrOffset = AbbrEntry->Offset;<br>
+  }<br>
   AddrSize = debug_info.getU8(offset_ptr);<br>
<br>
   bool LengthOK = debug_info.isValidOffset(getNextUnitOffset() - 1);<br>
@@ -375,3 +388,12 @@ DWARFUnit::getInlinedChainForAddress(uin<br>
     return DWARFDebugInfoEntryInlinedChain();<br>
   return SubprogramDIE->getInlinedChainForAddress(ChainCU, Address);<br>
 }<br>
+<br>
+const DWARFUnitIndex &getDWARFUnitIndex(DWARFContext &Context,<br>
+                                        DWARFSectionKind Kind) {<br>
+  if (Kind == DW_SECT_INFO)<br>
+    return Context.getCUIndex();<br>
+  assert(Kind == DW_SECT_TYPES);<br>
+  return Context.getTUIndex();<br>
+}<br>
+}<br>
<br>
Modified: llvm/trunk/lib/DebugInfo/DWARF/DWARFUnitIndex.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/DWARF/DWARFUnitIndex.cpp?rev=253277&r1=253276&r2=253277&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/DWARF/DWARFUnitIndex.cpp?rev=253277&r1=253276&r2=253277&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/lib/DebugInfo/DWARF/DWARFUnitIndex.cpp (original)<br>
+++ llvm/trunk/lib/DebugInfo/DWARF/DWARFUnitIndex.cpp Mon Nov 16 18:39:55 2015<br>
@@ -39,10 +39,10 @@ bool DWARFUnitIndex::parse(DataExtractor<br>
                       (2 * Header.NumUnits + 1) * 4 * Header.NumColumns))<br>
     return false;<br>
<br>
-  Rows = llvm::make_unique<HashRow[]>(Header.NumBuckets);<br>
+  Rows = llvm::make_unique<Entry[]>(Header.NumBuckets);<br>
   auto Contribs =<br>
-      llvm::make_unique<HashRow::SectionContribution *[]>(Header.NumUnits);<br>
-  ColumnKinds = llvm::make_unique<DwarfSection[]>(Header.NumColumns);<br>
+      llvm::make_unique<Entry::SectionContribution *[]>(Header.NumUnits);<br>
+  ColumnKinds = llvm::make_unique<DWARFSectionKind[]>(Header.NumColumns);<br>
<br>
   // Read Hash Table of Signatures<br>
   for (unsigned i = 0; i != Header.NumBuckets; ++i)<br>
@@ -53,35 +53,43 @@ bool DWARFUnitIndex::parse(DataExtractor<br>
     auto Index = IndexData.getU32(&Offset);<br>
     if (!Index)<br>
       continue;<br>
+    Rows[i].Index = this;<br>
     Rows[i].Contributions =<br>
-        llvm::make_unique<HashRow::SectionContribution[]>(Header.NumColumns);<br>
+        llvm::make_unique<Entry::SectionContribution[]>(Header.NumColumns);<br>
     Contribs[Index - 1] = Rows[i].Contributions.get();<br>
   }<br>
<br>
   // Read the Column Headers<br>
-  for (unsigned i = 0; i != Header.NumColumns; ++i)<br>
-    ColumnKinds[i] = static_cast<DwarfSection>(IndexData.getU32(&Offset));<br>
+  for (unsigned i = 0; i != Header.NumColumns; ++i) {<br>
+    ColumnKinds[i] = static_cast<DWARFSectionKind>(IndexData.getU32(&Offset));<br>
+    if (ColumnKinds[i] == DW_SECT_INFO || ColumnKinds[i] == DW_SECT_TYPES) {<br>
+      if (InfoColumn != -1)<br>
+        return false;<br>
+      InfoColumn = i;<br>
+    }<br>
+  }<br>
+<br>
+  if (InfoColumn == -1)<br>
+    return false;<br>
<br>
   // Read Table of Section Offsets<br>
   for (unsigned i = 0; i != Header.NumUnits; ++i) {<br>
     auto *Contrib = Contribs[i];<br>
-    for (unsigned i = 0; i != Header.NumColumns; ++i) {<br>
+    for (unsigned i = 0; i != Header.NumColumns; ++i)<br>
       Contrib[i].Offset = IndexData.getU32(&Offset);<br>
-    }<br>
   }<br>
<br>
   // Read Table of Section Sizes<br>
   for (unsigned i = 0; i != Header.NumUnits; ++i) {<br>
     auto *Contrib = Contribs[i];<br>
-    for (unsigned i = 0; i != Header.NumColumns; ++i) {<br>
-      Contrib[i].Size = IndexData.getU32(&Offset);<br>
-    }<br>
+    for (unsigned i = 0; i != Header.NumColumns; ++i)<br>
+      Contrib[i].Length = IndexData.getU32(&Offset);<br>
   }<br>
<br>
   return true;<br>
 }<br>
<br>
-StringRef DWARFUnitIndex::getColumnHeader(DwarfSection DS) {<br>
+StringRef DWARFUnitIndex::getColumnHeader(DWARFSectionKind DS) {<br>
 #define CASE(DS)                                                               \<br>
   case DW_SECT_##DS:                                                           \<br>
     return #DS;<br>
@@ -95,7 +103,7 @@ StringRef DWARFUnitIndex::getColumnHeade<br>
     CASE(MACINFO);<br>
     CASE(MACRO);<br>
   }<br>
-  llvm_unreachable("unknown DwarfSection");<br>
+  llvm_unreachable("unknown DWARFSectionKind");<br>
 }<br>
<br>
 void DWARFUnitIndex::dump(raw_ostream &OS) const {<br>
@@ -113,11 +121,33 @@ void DWARFUnitIndex::dump(raw_ostream &O<br>
       OS << format("%5u 0x%016" PRIx64 " ", i, Row.Signature);<br>
       for (unsigned i = 0; i != Header.NumColumns; ++i) {<br>
         auto &Contrib = Contribs[i];<br>
-        OS << format("[0x%08u, 0x%08u) ", Contrib.Offset,<br>
-                     Contrib.Offset + Contrib.Size);<br>
+        OS << format("[0x%08x, 0x%08x) ", Contrib.Offset,<br>
+                     Contrib.Offset + Contrib.Length);<br>
       }<br>
       OS << '\n';<br>
     }<br>
   }<br>
 }<br>
+<br>
+const DWARFUnitIndex::Entry::SectionContribution *<br>
+DWARFUnitIndex::Entry::getOffset(DWARFSectionKind Sec) const {<br>
+  uint32_t i = 0;<br>
+  for (; i != Index->Header.NumColumns; ++i)<br>
+    if (Index->ColumnKinds[i] == Sec)<br>
+      return &Contributions[i];<br>
+  return nullptr;<br>
+}<br>
+const DWARFUnitIndex::Entry::SectionContribution *<br>
+DWARFUnitIndex::Entry::getOffset() const {<br>
+  return &Contributions[Index->InfoColumn];<br>
+}<br>
+<br>
+const DWARFUnitIndex::Entry *<br>
+DWARFUnitIndex::getFromOffset(uint32_t Offset) const {<br>
+  for (uint32_t i = 0; i != Header.NumBuckets; ++i)<br>
+    if (const auto &Contribs = Rows[i].Contributions)<br>
+      if (Contribs[InfoColumn].Offset == Offset)<br>
+        return &Rows[i];<br>
+  return nullptr;<br>
+}<br>
 }<br>
<br>
Modified: llvm/trunk/test/DebugInfo/Inputs/dwarfdump-dwp.x86_64.o<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/Inputs/dwarfdump-dwp.x86_64.o?rev=253277&r1=253276&r2=253277&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/Inputs/dwarfdump-dwp.x86_64.o?rev=253277&r1=253276&r2=253277&view=diff</a><br>
==============================================================================<br>
Binary files llvm/trunk/test/DebugInfo/Inputs/dwarfdump-dwp.x86_64.o (original) and llvm/trunk/test/DebugInfo/Inputs/dwarfdump-dwp.x86_64.o Mon Nov 16 18:39:55 2015 differ<br>
<br>
Modified: llvm/trunk/test/DebugInfo/dwarfdump-dwp.test<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/dwarfdump-dwp.test?rev=253277&r1=253276&r2=253277&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/dwarfdump-dwp.test?rev=253277&r1=253276&r2=253277&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/test/DebugInfo/dwarfdump-dwp.test (original)<br>
+++ llvm/trunk/test/DebugInfo/dwarfdump-dwp.test Mon Nov 16 18:39:55 2015<br>
@@ -6,20 +6,37 @@ RUN: llvm-dwarfdump %p/Inputs/dwarfdump-<br>
 ;   foo a;<br>
 ; b.cpp:<br>
 ;   struct bar { };<br>
-;   bar b;<br>
+;   bar b() {<br>
+;   }<br>
+<br>
+; CHECK: .debug_info.dwo contents:<br>
+; CHECK: Compile Unit<br>
+<br>
+; Verify that the second CU uses the index for its abbrev offset<br>
+; CHECK: Compile Unit<br>
+; CHECK-SAME: abbr_offset = 0x0043<br>
+; CHECK: DW_TAG_compile_unit<br>
+; CHECK-NOT: DW_TAG<br>
+; FIXME: Implement str_offsets support so we find b.cpp here \/<br>
+; CHECK:   DW_AT_name {{.*}} "a.cpp"<br>
+<br>
+; Verify that abbreviations are decoded using the abbrev offset in the index<br>
+; CHECK:   DW_TAG_subprogram<br>
+; CHECK:   DW_TAG_structure_type<br>
<br>
 ; CHECK: .debug_cu_index contents:<br>
 ; CHECK-NEXT: version = 2 slots = 16<br>
-; CHECK:      Index Signature          INFO                     ABBREV                   LINE                     STR_OFFSETS<br>
+; CHECK:      Index Signature          INFO                     ABBREV                   LINE                     STR_OFFSETS<br>
 ; CHECK-NEXT: ----- ------------------ ------------------------ ------------------------ ------------------------ ------------------------<br>
-; CHECK-NEXT:     8 0x03c30756e2d45008 [0x00000000, 0x00000045) [0x00000000, 0x00000067) [0x00000000, 0x00000026) [0x00000000, 0x00000016)<br>
-; CHECK-NEXT:    12 0x9aeb3a61ed48510c [0x00000045, 0x00000090) [0x00000067, 0x00000134) [0x00000026, 0x00000052) [0x00000016, 0x00000032)<br>
+; CHECK-NEXT:     2 0xfef104c25502f092 [0x0000002d, 0x0000005f) [0x00000043, 0x0000008e) [0x0000001a, 0x00000034) [0x00000010, 0x00000024)<br>
+; CHECK-NEXT:     8 0x03c30756e2d45008 [0x00000000, 0x0000002d) [0x00000000, 0x00000043) [0x00000000, 0x0000001a) [0x00000000, 0x00000010)<br>
<br>
 ; CHECK: .debug_tu_index contents:<br>
 ; CHECK-NEXT: version = 2 slots = 16<br>
 ; CHECK:      Index Signature          TYPES                    ABBREV                   LINE                     STR_OFFSETS<br>
 ; CHECK-NEXT: ----- ------------------ ------------------------ ------------------------ ------------------------ ------------------------<br>
-; CHECK-NEXT:     8 0x1d02f3be30cc5688 [0x00000036, 0x00000072) [0x00000067, 0x00000134) [0x00000026, 0x00000052) [0x00000016, 0x00000032)<br>
-; CHECK-NEXT:    12 0x3875c0e21cda63fc [0x00000000, 0x00000036) [0x00000000, 0x00000067) [0x00000000, 0x00000026) [0x00000000, 0x00000016)<br>
+; CHECK-NEXT:     8 0x1d02f3be30cc5688 [0x00000024, 0x00000048) [0x00000043, 0x0000008e) [0x0000001a, 0x00000034) [0x00000010, 0x00000024)<br>
+; CHECK-NEXT:    12 0x3875c0e21cda63fc [0x00000000, 0x00000024) [0x00000000, 0x00000043) [0x00000000, 0x0000001a) [0x00000000, 0x00000010)<br>
<br>
-; TODO: use the index section offset info to correctly dump debug_info<br>
+; TODO: use the index section offset info to correctly dump strings in debug info<br>
+; TODO: use the index section offset info to correctly dump file names in debug info<br>
<br>
<br>
_______________________________________________<br>
llvm-commits mailing list<br>
<a href="mailto:llvm-commits@lists.llvm.org" target="_blank">llvm-commits@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits</a><br>
</blockquote></div>
</div></div></blockquote></div><br></div>
</div></div><br>_______________________________________________<br>
llvm-commits mailing list<br>
<a href="mailto:llvm-commits@lists.llvm.org" target="_blank">llvm-commits@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits</a><br>
<br></blockquote></div><br></div>
</div></div></blockquote></div><br></div>