From: Reid Kleckner Date: Fri, 27 Oct 2017 00:45:51 +0000 (+0000) Subject: [PDB] Handle an empty globals hash table with no buckets X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=eb271e82ff427f0796db172f40535dd9fb01104c;p=llvm [PDB] Handle an empty globals hash table with no buckets git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@316722 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/DebugInfo/PDB/Native/GlobalsStream.cpp b/lib/DebugInfo/PDB/Native/GlobalsStream.cpp index 1fe35a691c3..97bbbebd575 100644 --- a/lib/DebugInfo/PDB/Native/GlobalsStream.cpp +++ b/lib/DebugInfo/PDB/Native/GlobalsStream.cpp @@ -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 index 00000000000..a688d399895 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 index 00000000000..59a06ea5e85 --- /dev/null +++ b/test/DebugInfo/PDB/pdbdump-globals-empty.test @@ -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_ diff --git a/tools/llvm-pdbutil/DumpOutputStyle.cpp b/tools/llvm-pdbutil/DumpOutputStyle.cpp index 8a4d21b27ba..5b02d68bc7a 100644 --- a/tools/llvm-pdbutil/DumpOutputStyle.cpp +++ b/tools/llvm-pdbutil/DumpOutputStyle.cpp @@ -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); }