forked from OSchip/llvm-project
[pdb] Don't error on missing FPO streams
64-bit PDBs never have FPO data. They have xdata instead. Also improve error recovery of stream summary dumping while I'm here. llvm-svn: 273046
This commit is contained in:
parent
d76efc14b9
commit
11582c59d7
|
@ -58,6 +58,10 @@ public:
|
||||||
|
|
||||||
PDB_Machine getMachineType() const;
|
PDB_Machine getMachineType() const;
|
||||||
|
|
||||||
|
enum { InvalidStreamIndex = 0xffff };
|
||||||
|
|
||||||
|
/// If the given stream type is present, returns its stream index. If it is
|
||||||
|
/// not present, returns InvalidStreamIndex.
|
||||||
uint32_t getDebugStreamIndex(DbgHeaderType Type) const;
|
uint32_t getDebugStreamIndex(DbgHeaderType Type) const;
|
||||||
|
|
||||||
ArrayRef<ModuleInfoEx> modules() const;
|
ArrayRef<ModuleInfoEx> modules() const;
|
||||||
|
|
|
@ -316,6 +316,11 @@ Error DbiStream::initializeSectionHeadersData() {
|
||||||
// Initializes this->Fpos.
|
// Initializes this->Fpos.
|
||||||
Error DbiStream::initializeFpoRecords() {
|
Error DbiStream::initializeFpoRecords() {
|
||||||
uint32_t StreamNum = getDebugStreamIndex(DbgHeaderType::NewFPO);
|
uint32_t StreamNum = getDebugStreamIndex(DbgHeaderType::NewFPO);
|
||||||
|
|
||||||
|
// This means there is no FPO data.
|
||||||
|
if (StreamNum == InvalidStreamIndex)
|
||||||
|
return Error::success();
|
||||||
|
|
||||||
if (StreamNum >= Pdb.getNumStreams())
|
if (StreamNum >= Pdb.getNumStreams())
|
||||||
return make_error<RawError>(raw_error_code::no_stream);
|
return make_error<RawError>(raw_error_code::no_stream);
|
||||||
|
|
||||||
|
|
|
@ -67,33 +67,28 @@ Error LLVMOutputStyle::dumpStreamSummary() {
|
||||||
if (!opts::DumpStreamSummary)
|
if (!opts::DumpStreamSummary)
|
||||||
return Error::success();
|
return Error::success();
|
||||||
|
|
||||||
|
// It's OK if we fail to load some of these streams, we still attempt to print
|
||||||
|
// what we can.
|
||||||
auto Dbi = File.getPDBDbiStream();
|
auto Dbi = File.getPDBDbiStream();
|
||||||
if (!Dbi)
|
|
||||||
return Dbi.takeError();
|
|
||||||
|
|
||||||
auto Tpi = File.getPDBTpiStream();
|
auto Tpi = File.getPDBTpiStream();
|
||||||
if (!Tpi)
|
|
||||||
return Tpi.takeError();
|
|
||||||
|
|
||||||
auto Ipi = File.getPDBIpiStream();
|
auto Ipi = File.getPDBIpiStream();
|
||||||
if (!Ipi)
|
|
||||||
return Ipi.takeError();
|
|
||||||
|
|
||||||
auto Info = File.getPDBInfoStream();
|
auto Info = File.getPDBInfoStream();
|
||||||
if (!Info)
|
|
||||||
return Info.takeError();
|
|
||||||
|
|
||||||
ListScope L(P, "Streams");
|
ListScope L(P, "Streams");
|
||||||
uint32_t StreamCount = File.getNumStreams();
|
uint32_t StreamCount = File.getNumStreams();
|
||||||
std::unordered_map<uint16_t, const ModuleInfoEx *> ModStreams;
|
std::unordered_map<uint16_t, const ModuleInfoEx *> ModStreams;
|
||||||
std::unordered_map<uint16_t, std::string> NamedStreams;
|
std::unordered_map<uint16_t, std::string> NamedStreams;
|
||||||
|
|
||||||
for (auto &ModI : Dbi->modules()) {
|
if (Dbi) {
|
||||||
uint16_t SN = ModI.Info.getModuleStreamIndex();
|
for (auto &ModI : Dbi->modules()) {
|
||||||
ModStreams[SN] = &ModI;
|
uint16_t SN = ModI.Info.getModuleStreamIndex();
|
||||||
|
ModStreams[SN] = &ModI;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
for (auto &NSE : Info->named_streams()) {
|
if (Info) {
|
||||||
NamedStreams[NSE.second] = NSE.first();
|
for (auto &NSE : Info->named_streams()) {
|
||||||
|
NamedStreams[NSE.second] = NSE.first();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (uint16_t StreamIdx = 0; StreamIdx < StreamCount; ++StreamIdx) {
|
for (uint16_t StreamIdx = 0; StreamIdx < StreamCount; ++StreamIdx) {
|
||||||
|
@ -110,42 +105,49 @@ Error LLVMOutputStyle::dumpStreamSummary() {
|
||||||
Value = "TPI Stream";
|
Value = "TPI Stream";
|
||||||
else if (StreamIdx == StreamIPI)
|
else if (StreamIdx == StreamIPI)
|
||||||
Value = "IPI Stream";
|
Value = "IPI Stream";
|
||||||
else if (StreamIdx == Dbi->getGlobalSymbolStreamIndex())
|
else if (Dbi && StreamIdx == Dbi->getGlobalSymbolStreamIndex())
|
||||||
Value = "Global Symbol Hash";
|
Value = "Global Symbol Hash";
|
||||||
else if (StreamIdx == Dbi->getPublicSymbolStreamIndex())
|
else if (Dbi && StreamIdx == Dbi->getPublicSymbolStreamIndex())
|
||||||
Value = "Public Symbol Hash";
|
Value = "Public Symbol Hash";
|
||||||
else if (StreamIdx == Dbi->getSymRecordStreamIndex())
|
else if (Dbi && StreamIdx == Dbi->getSymRecordStreamIndex())
|
||||||
Value = "Public Symbol Records";
|
Value = "Public Symbol Records";
|
||||||
else if (StreamIdx == Tpi->getTypeHashStreamIndex())
|
else if (Tpi && StreamIdx == Tpi->getTypeHashStreamIndex())
|
||||||
Value = "TPI Hash";
|
Value = "TPI Hash";
|
||||||
else if (StreamIdx == Tpi->getTypeHashStreamAuxIndex())
|
else if (Tpi && StreamIdx == Tpi->getTypeHashStreamAuxIndex())
|
||||||
Value = "TPI Aux Hash";
|
Value = "TPI Aux Hash";
|
||||||
else if (StreamIdx == Ipi->getTypeHashStreamIndex())
|
else if (Ipi && StreamIdx == Ipi->getTypeHashStreamIndex())
|
||||||
Value = "IPI Hash";
|
Value = "IPI Hash";
|
||||||
else if (StreamIdx == Ipi->getTypeHashStreamAuxIndex())
|
else if (Ipi && StreamIdx == Ipi->getTypeHashStreamAuxIndex())
|
||||||
Value = "IPI Aux Hash";
|
Value = "IPI Aux Hash";
|
||||||
else if (StreamIdx == Dbi->getDebugStreamIndex(DbgHeaderType::Exception))
|
else if (Dbi &&
|
||||||
|
StreamIdx == Dbi->getDebugStreamIndex(DbgHeaderType::Exception))
|
||||||
Value = "Exception Data";
|
Value = "Exception Data";
|
||||||
else if (StreamIdx == Dbi->getDebugStreamIndex(DbgHeaderType::Fixup))
|
else if (Dbi && StreamIdx == Dbi->getDebugStreamIndex(DbgHeaderType::Fixup))
|
||||||
Value = "Fixup Data";
|
Value = "Fixup Data";
|
||||||
else if (StreamIdx == Dbi->getDebugStreamIndex(DbgHeaderType::FPO))
|
else if (Dbi && StreamIdx == Dbi->getDebugStreamIndex(DbgHeaderType::FPO))
|
||||||
Value = "FPO Data";
|
Value = "FPO Data";
|
||||||
else if (StreamIdx == Dbi->getDebugStreamIndex(DbgHeaderType::NewFPO))
|
else if (Dbi &&
|
||||||
|
StreamIdx == Dbi->getDebugStreamIndex(DbgHeaderType::NewFPO))
|
||||||
Value = "New FPO Data";
|
Value = "New FPO Data";
|
||||||
else if (StreamIdx == Dbi->getDebugStreamIndex(DbgHeaderType::OmapFromSrc))
|
else if (Dbi &&
|
||||||
|
StreamIdx == Dbi->getDebugStreamIndex(DbgHeaderType::OmapFromSrc))
|
||||||
Value = "Omap From Source Data";
|
Value = "Omap From Source Data";
|
||||||
else if (StreamIdx == Dbi->getDebugStreamIndex(DbgHeaderType::OmapToSrc))
|
else if (Dbi &&
|
||||||
|
StreamIdx == Dbi->getDebugStreamIndex(DbgHeaderType::OmapToSrc))
|
||||||
Value = "Omap To Source Data";
|
Value = "Omap To Source Data";
|
||||||
else if (StreamIdx == Dbi->getDebugStreamIndex(DbgHeaderType::Pdata))
|
else if (Dbi && StreamIdx == Dbi->getDebugStreamIndex(DbgHeaderType::Pdata))
|
||||||
Value = "Pdata";
|
Value = "Pdata";
|
||||||
else if (StreamIdx == Dbi->getDebugStreamIndex(DbgHeaderType::SectionHdr))
|
else if (Dbi &&
|
||||||
|
StreamIdx == Dbi->getDebugStreamIndex(DbgHeaderType::SectionHdr))
|
||||||
Value = "Section Header Data";
|
Value = "Section Header Data";
|
||||||
else if (StreamIdx ==
|
else if (Dbi &&
|
||||||
Dbi->getDebugStreamIndex(DbgHeaderType::SectionHdrOrig))
|
StreamIdx ==
|
||||||
|
Dbi->getDebugStreamIndex(DbgHeaderType::SectionHdrOrig))
|
||||||
Value = "Section Header Original Data";
|
Value = "Section Header Original Data";
|
||||||
else if (StreamIdx == Dbi->getDebugStreamIndex(DbgHeaderType::TokenRidMap))
|
else if (Dbi &&
|
||||||
|
StreamIdx == Dbi->getDebugStreamIndex(DbgHeaderType::TokenRidMap))
|
||||||
Value = "Token Rid Data";
|
Value = "Token Rid Data";
|
||||||
else if (StreamIdx == Dbi->getDebugStreamIndex(DbgHeaderType::Xdata))
|
else if (Dbi && StreamIdx == Dbi->getDebugStreamIndex(DbgHeaderType::Xdata))
|
||||||
Value = "Xdata";
|
Value = "Xdata";
|
||||||
else {
|
else {
|
||||||
auto ModIter = ModStreams.find(StreamIdx);
|
auto ModIter = ModStreams.find(StreamIdx);
|
||||||
|
@ -168,6 +170,17 @@ Error LLVMOutputStyle::dumpStreamSummary() {
|
||||||
|
|
||||||
P.printString(Label, Value);
|
P.printString(Label, Value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Consume errors from missing streams.
|
||||||
|
if (!Dbi)
|
||||||
|
consumeError(Dbi.takeError());
|
||||||
|
if (!Tpi)
|
||||||
|
consumeError(Tpi.takeError());
|
||||||
|
if (!Ipi)
|
||||||
|
consumeError(Ipi.takeError());
|
||||||
|
if (!Info)
|
||||||
|
consumeError(Info.takeError());
|
||||||
|
|
||||||
P.flush();
|
P.flush();
|
||||||
return Error::success();
|
return Error::success();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue