OSDN Git Service

[PDB] Handle an empty globals hash table with no buckets
authorReid Kleckner <rnk@google.com>
Fri, 27 Oct 2017 00:45:51 +0000 (00:45 +0000)
committerReid Kleckner <rnk@google.com>
Fri, 27 Oct 2017 00:45:51 +0000 (00:45 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@316722 91177308-0d34-0410-b5e6-96231b3b80d8

lib/DebugInfo/PDB/Native/GlobalsStream.cpp
test/DebugInfo/PDB/Inputs/pdbdump-globals-empty.pdb [new file with mode: 0644]
test/DebugInfo/PDB/pdbdump-globals-empty.test [new file with mode: 0644]
tools/llvm-pdbutil/DumpOutputStyle.cpp

index 1fe35a6..97bbbeb 100644 (file)
@@ -117,7 +117,8 @@ Error GSIHashTable::read(BinaryStreamReader &Reader) {
     return EC;
   if (auto EC = readGSIHashRecords(HashRecords, HashHdr, Reader))
     return EC;
-  if (auto EC = readGSIHashBuckets(HashBuckets, HashBitmap, HashHdr, Reader))
-    return EC;
+  if (HashHdr->HrSize > 0)
+    if (auto EC = readGSIHashBuckets(HashBuckets, HashBitmap, HashHdr, Reader))
+      return EC;
   return Error::success();
 }
diff --git a/test/DebugInfo/PDB/Inputs/pdbdump-globals-empty.pdb b/test/DebugInfo/PDB/Inputs/pdbdump-globals-empty.pdb
new file mode 100644 (file)
index 0000000..a688d39
Binary files /dev/null and b/test/DebugInfo/PDB/Inputs/pdbdump-globals-empty.pdb differ
diff --git a/test/DebugInfo/PDB/pdbdump-globals-empty.test b/test/DebugInfo/PDB/pdbdump-globals-empty.test
new file mode 100644 (file)
index 0000000..59a06ea
--- /dev/null
@@ -0,0 +1,6 @@
+RUN: llvm-pdbutil dump -globals %S/Inputs/pdbdump-globals-empty.pdb | FileCheck %s
+
+CHECK:                        Global Symbols
+CHECK: ============================================================
+CHECK:   Records
+CHECK-NOT: S_
index 8a4d21b..5b02d68 100644 (file)
@@ -639,9 +639,11 @@ Error DumpOutputStyle::dumpUdtStats() {
     }
 
     auto &SymbolRecords = cantFail(getPdb().getPDBSymbolStream());
-    auto &Globals = cantFail(getPdb().getPDBGlobalsStream());
+    auto ExpGlobals = getPdb().getPDBGlobalsStream();
+    if (!ExpGlobals)
+      return ExpGlobals.takeError();
 
-    for (uint32_t PubSymOff : Globals.getGlobalsTable()) {
+    for (uint32_t PubSymOff : ExpGlobals->getGlobalsTable()) {
       CVSymbol Sym = SymbolRecords.readRecord(PubSymOff);
       HandleOneSymbol(Sym);
     }