[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.

llvm-svn: 305235
This commit is contained in:
Zachary Turner 2017-06-12 21:34:53 +00:00
parent 4b027e8f89
commit 990d0c8158
6 changed files with 26 additions and 4 deletions

View File

@ -35,6 +35,7 @@ public:
uint32_t getStreamSize() const;
bool containsIdStream() const;
PdbRaw_ImplVer getVersion() const;
uint32_t getSignature() const;
uint32_t getAge() const;

View File

@ -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);
}

View File

@ -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",

View File

@ -739,10 +739,12 @@ Error LLVMOutputStyle::dumpTpiStream(uint32_t StreamIdx) {
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)";

View File

@ -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();

View File

@ -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()) {