]> granicus.if.org Git - llvm/commitdiff
[llvm-pdbutil] Fix one more issue with no-id-stream PDBs.
authorZachary Turner <zturner@google.com>
Mon, 12 Jun 2017 21:57:41 +0000 (21:57 +0000)
committerZachary Turner <zturner@google.com>
Mon, 12 Jun 2017 21:57:41 +0000 (21:57 +0000)
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

tools/llvm-pdbutil/LLVMOutputStyle.cpp

index 444541a07731ab0bdc7c7d54e845230b6701ffc5..4719f00f07faea2eb7d253d6eb503c995691d758 100644 (file)
@@ -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(