[llvm] r305235 - [llvm-pdbdump] Don't fail on PDBs with no ID stream.

Zachary Turner via llvm-commits llvm-commits at lists.llvm.org
Mon Jun 12 14:34:54 PDT 2017


Author: zturner
Date: Mon Jun 12 16:34:53 2017
New Revision: 305235

URL: http://llvm.org/viewvc/llvm-project?rev=305235&view=rev
Log:
[llvm-pdbdump] Don't fail on PDBs with no ID stream.

Older PDBs don't have this.  Its presence is detected by using
the various "feature" flags that come at the end of the PDB
Stream.  Detect this, and don't try to dump the ID stream if the
features tells us it's not present.

Modified:
    llvm/trunk/include/llvm/DebugInfo/PDB/Native/InfoStream.h
    llvm/trunk/lib/DebugInfo/PDB/Native/InfoStream.cpp
    llvm/trunk/test/lit.cfg
    llvm/trunk/tools/llvm-pdbutil/LLVMOutputStyle.cpp
    llvm/trunk/tools/llvm-pdbutil/YAMLOutputStyle.cpp
    llvm/trunk/tools/llvm-pdbutil/llvm-pdbutil.cpp

Modified: llvm/trunk/include/llvm/DebugInfo/PDB/Native/InfoStream.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/PDB/Native/InfoStream.h?rev=305235&r1=305234&r2=305235&view=diff
==============================================================================
--- llvm/trunk/include/llvm/DebugInfo/PDB/Native/InfoStream.h (original)
+++ llvm/trunk/include/llvm/DebugInfo/PDB/Native/InfoStream.h Mon Jun 12 16:34:53 2017
@@ -35,6 +35,7 @@ public:
 
   uint32_t getStreamSize() const;
 
+  bool containsIdStream() const;
   PdbRaw_ImplVer getVersion() const;
   uint32_t getSignature() const;
   uint32_t getAge() const;

Modified: llvm/trunk/lib/DebugInfo/PDB/Native/InfoStream.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/PDB/Native/InfoStream.cpp?rev=305235&r1=305234&r2=305235&view=diff
==============================================================================
--- llvm/trunk/lib/DebugInfo/PDB/Native/InfoStream.cpp (original)
+++ llvm/trunk/lib/DebugInfo/PDB/Native/InfoStream.cpp Mon Jun 12 16:34:53 2017
@@ -102,6 +102,10 @@ InfoStream::named_streams() const {
   return NamedStreams.entries();
 }
 
+bool InfoStream::containsIdStream() const {
+  return !!(Features & PdbFeatureContainsIdStream);
+}
+
 PdbRaw_ImplVer InfoStream::getVersion() const {
   return static_cast<PdbRaw_ImplVer>(Version);
 }

Modified: llvm/trunk/test/lit.cfg
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/lit.cfg?rev=305235&r1=305234&r2=305235&view=diff
==============================================================================
--- llvm/trunk/test/lit.cfg (original)
+++ llvm/trunk/test/lit.cfg Mon Jun 12 16:34:53 2017
@@ -301,7 +301,7 @@ for pattern in [r"\bbugpoint\b(?!-)",
                 r"\bllvm-modextract\b",
                 r"\bllvm-nm\b",
                 r"\bllvm-objdump\b",
-                r"\bllvm-pdbdump\b",
+                r"\bllvm-pdbutil\b",
                 r"\bllvm-profdata\b",
                 r"\bllvm-ranlib\b",
                 r"\bllvm-readobj\b",

Modified: llvm/trunk/tools/llvm-pdbutil/LLVMOutputStyle.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-pdbutil/LLVMOutputStyle.cpp?rev=305235&r1=305234&r2=305235&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-pdbutil/LLVMOutputStyle.cpp (original)
+++ llvm/trunk/tools/llvm-pdbutil/LLVMOutputStyle.cpp Mon Jun 12 16:34:53 2017
@@ -739,10 +739,12 @@ Error LLVMOutputStyle::dumpTpiStream(uin
     Label = "Type Info Stream (TPI)";
     VerLabel = "TPI Version";
   } else if (StreamIdx == StreamIPI) {
-    if (!File.hasPDBIpiStream()) {
-      P.printString("Type Info Stream (IPI) not present");
+    auto InfoS = File.getPDBInfoStream();
+    if (!InfoS)
+      return InfoS.takeError();
+
+    if (!File.hasPDBIpiStream() || !InfoS->containsIdStream())
       return Error::success();
-    }
     DumpRecordBytes = opts::raw::DumpIpiRecordBytes;
     DumpRecords = opts::raw::DumpIpiRecords;
     Label = "Type Info Stream (IPI)";

Modified: llvm/trunk/tools/llvm-pdbutil/YAMLOutputStyle.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-pdbutil/YAMLOutputStyle.cpp?rev=305235&r1=305234&r2=305235&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-pdbutil/YAMLOutputStyle.cpp (original)
+++ llvm/trunk/tools/llvm-pdbutil/YAMLOutputStyle.cpp Mon Jun 12 16:34:53 2017
@@ -293,6 +293,12 @@ Error YAMLOutputStyle::dumpIpiStream() {
   if (!opts::pdb2yaml::IpiStream)
     return Error::success();
 
+  auto InfoS = File.getPDBInfoStream();
+  if (!InfoS)
+    return InfoS.takeError();
+  if (!InfoS->containsIdStream())
+    return Error::success();
+
   auto IpiS = File.getPDBIpiStream();
   if (!IpiS)
     return IpiS.takeError();

Modified: llvm/trunk/tools/llvm-pdbutil/llvm-pdbutil.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-pdbutil/llvm-pdbutil.cpp?rev=305235&r1=305234&r2=305235&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-pdbutil/llvm-pdbutil.cpp (original)
+++ llvm/trunk/tools/llvm-pdbutil/llvm-pdbutil.cpp Mon Jun 12 16:34:53 2017
@@ -580,6 +580,14 @@ static void yamlToPdb(StringRef Path) {
     IpiBuilder.addTypeRecord(Type.RecordData, None);
   }
 
+  if (!Ipi.Records.empty()) {
+    // In theory newer PDBs always have an ID stream, but by saying that we're
+    // only going to *really* have an ID stream if there is at least one ID
+    // record, we leave open the opportunity to test older PDBs such as those
+    // that don't have an ID stream.
+    InfoBuilder.addFeature(PdbRaw_FeatureSig::VC140);
+  }
+
   ExitOnErr(Builder.commit(opts::yaml2pdb::YamlPdbOutputFile));
 }
 
@@ -855,6 +863,7 @@ static void mergePdbs() {
   MergedIpi.ForEachRecord([&DestIpi](TypeIndex TI, ArrayRef<uint8_t> Data) {
     DestIpi.addTypeRecord(Data, None);
   });
+  Builder.getInfoBuilder().addFeature(PdbRaw_FeatureSig::VC140);
 
   SmallString<64> OutFile(opts::merge::PdbOutputFile);
   if (OutFile.empty()) {




More information about the llvm-commits mailing list