From: Zachary Turner Date: Mon, 12 Jun 2017 21:57:41 +0000 (+0000) Subject: [llvm-pdbutil] Fix one more issue with no-id-stream PDBs. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=684815613062f24ca87368295152ef7c3fb37cda;p=llvm [llvm-pdbutil] Fix one more issue with no-id-stream PDBs. This one occurred when we were dumping symbols, we have code that is prepared to dump many different types of symbols, including symbols which reference an ID stream. So when creating the dumper object, we assume that there is an ID stream. Fix this assumption. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@305237 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/tools/llvm-pdbutil/LLVMOutputStyle.cpp b/tools/llvm-pdbutil/LLVMOutputStyle.cpp index 444541a0773..4719f00f07f 100644 --- a/tools/llvm-pdbutil/LLVMOutputStyle.cpp +++ b/tools/llvm-pdbutil/LLVMOutputStyle.cpp @@ -89,7 +89,7 @@ struct PageStats { class C13RawVisitor : public DebugSubsectionVisitor { public: C13RawVisitor(ScopedPrinter &P, LazyRandomTypeCollection &TPI, - LazyRandomTypeCollection &IPI) + LazyRandomTypeCollection *IPI) : P(P), TPI(TPI), IPI(IPI) {} Error visitUnknown(DebugUnknownSubsectionRef &Unknown) override { @@ -299,13 +299,18 @@ public: private: Error dumpTypeRecord(StringRef Label, TypeIndex Index) { - CompactTypeDumpVisitor CTDV(IPI, Index, &P); - DictScope D(P, Label); - if (IPI.contains(Index)) { - CVType Type = IPI.getType(Index); - if (auto EC = codeview::visitTypeRecord(Type, CTDV)) - return EC; - } else { + bool Success = false; + if (IPI) { + CompactTypeDumpVisitor CTDV(*IPI, Index, &P); + DictScope D(P, Label); + if (IPI->contains(Index)) { + CVType Type = IPI->getType(Index); + if (auto EC = codeview::visitTypeRecord(Type, CTDV)) + return EC; + } + } + + if (!Success) { P.printString( llvm::formatv("Index: {0:x} (unknown function)", Index.getIndex()) .str()); @@ -339,7 +344,7 @@ private: ScopedPrinter &P; LazyRandomTypeCollection &TPI; - LazyRandomTypeCollection &IPI; + LazyRandomTypeCollection *IPI; }; } @@ -881,6 +886,8 @@ Error LLVMOutputStyle::dumpDbiStream() { return Error::success(); } + ExitOnError Err("Error while processing DBI Stream"); + auto DS = File.getPDBDbiStream(); if (!DS) return DS.takeError(); @@ -972,10 +979,10 @@ Error LLVMOutputStyle::dumpDbiStream() { } if (!opts::shared::DumpModuleSubsections.empty()) { ListScope SS(P, "Subsections"); - auto ExpectedIpi = initializeTypeDatabase(StreamIPI); - if (!ExpectedIpi) - return ExpectedIpi.takeError(); - auto &Ipi = *ExpectedIpi; + auto &InfoS = Err(File.getPDBInfoStream()); + LazyRandomTypeCollection *Ipi = nullptr; + if (InfoS.containsIdStream()) + Ipi = &Err(initializeTypeDatabase(StreamIPI)); auto ExpectedStrings = File.getStringTable(); if (!ExpectedStrings) return joinErrors(