]> granicus.if.org Git - llvm/commitdiff
Slightly better fix for dealing with no-id-stream PDBs.
authorZachary Turner <zturner@google.com>
Mon, 12 Jun 2017 21:46:51 +0000 (21:46 +0000)
committerZachary Turner <zturner@google.com>
Mon, 12 Jun 2017 21:46:51 +0000 (21:46 +0000)
The last fix required the user to manually add the required
feature.  This caused an LLD test to fail because I failed to
update LLD.  In practice we can hide this logic so it can just
be transparently added when we write the PDB.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@305236 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/DebugInfo/PDB/Native/TpiStreamBuilder.h
lib/DebugInfo/PDB/Native/PDBFileBuilder.cpp
tools/llvm-pdbutil/llvm-pdbutil.cpp

index 21cfa83e6af4efa25b7253f08fe0413f045395fa..411720d6f56b5694308a627066d05bd7b3921890 100644 (file)
@@ -58,6 +58,8 @@ public:
 
   Error finalizeMsfLayout();
 
+  uint32_t getRecordCount() const { return TypeRecords.size(); }
+
   Error commit(const msf::MSFLayout &Layout, WritableBinaryStreamRef Buffer);
 
   uint32_t calculateSerializedLength();
index 2c6465e6fb2a81cc454088c9c6ab151415c3a945..12b0c3b36c1dd44e10c3f482c35983b078f43406 100644 (file)
@@ -80,6 +80,16 @@ Error PDBFileBuilder::addNamedStream(StringRef Name, uint32_t Size) {
 }
 
 Expected<msf::MSFLayout> PDBFileBuilder::finalizeMsfLayout() {
+
+  if (Ipi && Ipi->getRecordCount() > 0) {
+    // 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.
+    auto &Info = getInfoBuilder();
+    Info.addFeature(PdbRaw_FeatureSig::VC140);
+  }
+
   uint32_t StringsLen = Strings.calculateSerializedSize();
 
   if (auto EC = addNamedStream("/names", StringsLen))
index 44ab0d93aea146e25fa2bf4cf8ab0fb53a087e7a..dc46da4a90f3b8875f7174e43f81944e8d9c7103 100644 (file)
@@ -580,14 +580,6 @@ 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));
 }