mirror of
https://github.com/RPCS3/llvm.git
synced 2024-12-16 00:17:32 +00:00
[llvm-pdbdump] Dump stream summary list.
Try to figure out what each stream is, and dump its name. This gives us a better picture of what streams we still don't understand. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@270653 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
0dfc65a906
commit
ec842a3379
@ -33,6 +33,7 @@ public:
|
||||
PDB_UniqueId getGuid() const;
|
||||
|
||||
uint32_t getNamedStreamIndex(llvm::StringRef Name) const;
|
||||
iterator_range<StringMapConstIterator<uint32_t>> named_streams() const;
|
||||
|
||||
PDBFile &getFile() { return Pdb; }
|
||||
|
||||
|
@ -28,6 +28,8 @@ public:
|
||||
|
||||
bool tryGetValue(StringRef Name, uint32_t &Value) const;
|
||||
|
||||
iterator_range<StringMapConstIterator<uint32_t>> entries() const;
|
||||
|
||||
private:
|
||||
StringMap<uint32_t> Mapping;
|
||||
};
|
||||
|
@ -37,6 +37,8 @@ public:
|
||||
uint32_t TypeIndexBegin() const;
|
||||
uint32_t TypeIndexEnd() const;
|
||||
uint32_t NumTypeRecords() const;
|
||||
uint16_t getTypeHashStreamIndex() const;
|
||||
uint16_t getTypeHashStreamAuxIndex() const;
|
||||
|
||||
iterator_range<codeview::TypeIterator> types(bool *HadError) const;
|
||||
|
||||
|
@ -53,6 +53,11 @@ uint32_t InfoStream::getNamedStreamIndex(llvm::StringRef Name) const {
|
||||
return Result;
|
||||
}
|
||||
|
||||
iterator_range<StringMapConstIterator<uint32_t>>
|
||||
InfoStream::named_streams() const {
|
||||
return NamedStreams.entries();
|
||||
}
|
||||
|
||||
PdbRaw_ImplVer InfoStream::getVersion() const {
|
||||
return static_cast<PdbRaw_ImplVer>(Version);
|
||||
}
|
||||
|
@ -127,6 +127,11 @@ Error NameMap::load(StreamReader &Stream) {
|
||||
return Error::success();
|
||||
}
|
||||
|
||||
iterator_range<StringMapConstIterator<uint32_t>> NameMap::entries() const {
|
||||
return llvm::make_range<StringMapConstIterator<uint32_t>>(Mapping.begin(),
|
||||
Mapping.end());
|
||||
}
|
||||
|
||||
bool NameMap::tryGetValue(StringRef Name, uint32_t &Value) const {
|
||||
auto Iter = Mapping.find(Name);
|
||||
if (Iter == Mapping.end())
|
||||
|
@ -129,6 +129,14 @@ uint32_t TpiStream::NumTypeRecords() const {
|
||||
return TypeIndexEnd() - TypeIndexBegin();
|
||||
}
|
||||
|
||||
uint16_t TpiStream::getTypeHashStreamIndex() const {
|
||||
return Header->HashStreamIndex;
|
||||
}
|
||||
|
||||
uint16_t TpiStream::getTypeHashStreamAuxIndex() const {
|
||||
return Header->HashAuxStreamIndex;
|
||||
}
|
||||
|
||||
iterator_range<codeview::TypeIterator> TpiStream::types(bool *HadError) const {
|
||||
return codeview::makeTypeRange(RecordsBuffer.data(), /*HadError=*/HadError);
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
; RUN: llvm-pdbdump -raw-headers -raw-tpi-records -raw-tpi-record-bytes -raw-module-syms \
|
||||
; RUN: -raw-sym-record-bytes -raw-publics -raw-module-files -raw-stream-name=/names \
|
||||
; RUN: %p/Inputs/empty.pdb | FileCheck -check-prefix=EMPTY %s
|
||||
; RUN: -raw-stream-summary %p/Inputs/empty.pdb | FileCheck -check-prefix=EMPTY %s
|
||||
; RUN: llvm-pdbdump -raw-headers -raw-stream-name=/names -raw-modules -raw-module-files \
|
||||
; RUN: %p/Inputs/big-read.pdb | FileCheck -check-prefix=BIG %s
|
||||
; RUN: llvm-pdbdump -raw-headers %p/Inputs/bad-block-size.pdb | FileCheck -check-prefix=BAD-BLOCK-SIZE %s
|
||||
@ -17,6 +17,25 @@
|
||||
; EMPTY-NEXT: DirectoryBlocks: [23]
|
||||
; EMPTY-NEXT: NumStreams: 17
|
||||
; EMPTY-NEXT: }
|
||||
; EMPTY-NEXT: Streams [
|
||||
; EMPTY-NEXT: Stream 0: [MSF Superblock] (40 bytes)
|
||||
; EMPTY-NEXT: Stream 1: [PDB Stream] (118 bytes)
|
||||
; EMPTY-NEXT: Stream 2: [TPI Stream] (5392 bytes)
|
||||
; EMPTY-NEXT: Stream 3: [DBI Stream] (739 bytes)
|
||||
; EMPTY-NEXT: Stream 4: [IPI Stream] (784 bytes)
|
||||
; EMPTY-NEXT: Stream 5: [Named Stream "/LinkInfo"] (0 bytes)
|
||||
; EMPTY-NEXT: Stream 6: [Global Symbol Hash] (556 bytes)
|
||||
; EMPTY-NEXT: Stream 7: [Public Symbol Hash] (604 bytes)
|
||||
; EMPTY-NEXT: Stream 8: [Public Symbol Records] (104 bytes)
|
||||
; EMPTY-NEXT: Stream 9: [Named Stream "/src/headerblock"] (0 bytes)
|
||||
; EMPTY-NEXT: Stream 10: [???] (160 bytes)
|
||||
; EMPTY-NEXT: Stream 11: [???] (32 bytes)
|
||||
; EMPTY-NEXT: Stream 12: [Module "d:\src\llvm\test\DebugInfo\PDB\Inputs\empty.obj"] (308 bytes)
|
||||
; EMPTY-NEXT: Stream 13: [Named Stream "/names"] (239 bytes)
|
||||
; EMPTY-NEXT: Stream 14: [Module "* Linker *"] (520 bytes)
|
||||
; EMPTY-NEXT: Stream 15: [TPI Hash] (308 bytes)
|
||||
; EMPTY-NEXT: Stream 16: [???] (68 bytes)
|
||||
; EMPTY-NEXT: ]
|
||||
; EMPTY-NEXT: PDB Stream {
|
||||
; EMPTY-NEXT: Version: 20000404
|
||||
; EMPTY-NEXT: Signature: 0x54E507E2
|
||||
|
@ -106,12 +106,12 @@ cl::opt<uint64_t> LoadAddress(
|
||||
|
||||
cl::opt<bool> DumpHeaders("raw-headers", cl::desc("dump PDB headers"),
|
||||
cl::cat(NativeOtions));
|
||||
cl::opt<bool> DumpStreamSizes("raw-stream-sizes",
|
||||
cl::desc("dump PDB stream sizes"),
|
||||
cl::cat(NativeOtions));
|
||||
cl::opt<bool> DumpStreamBlocks("raw-stream-blocks",
|
||||
cl::desc("dump PDB stream blocks"),
|
||||
cl::cat(NativeOtions));
|
||||
cl::opt<bool> DumpStreamSummary("raw-stream-summary",
|
||||
cl::desc("dump summary of the PDB streams"),
|
||||
cl::cat(NativeOtions));
|
||||
cl::opt<bool> DumpTpiRecords("raw-tpi-records",
|
||||
cl::desc("dump CodeView type records"),
|
||||
cl::cat(NativeOtions));
|
||||
@ -203,17 +203,82 @@ static Error dumpFileHeaders(ScopedPrinter &P, PDBFile &File) {
|
||||
return Error::success();
|
||||
}
|
||||
|
||||
static Error dumpStreamSizes(ScopedPrinter &P, PDBFile &File) {
|
||||
if (!opts::DumpStreamSizes)
|
||||
static Error dumpStreamSummary(ScopedPrinter &P, PDBFile &File) {
|
||||
if (!opts::DumpStreamSummary)
|
||||
return Error::success();
|
||||
|
||||
ListScope L(P, "StreamSizes");
|
||||
auto DbiS = File.getPDBDbiStream();
|
||||
if (auto EC = DbiS.takeError())
|
||||
return EC;
|
||||
auto TpiS = File.getPDBTpiStream();
|
||||
if (auto EC = TpiS.takeError())
|
||||
return EC;
|
||||
auto InfoS = File.getPDBInfoStream();
|
||||
if (auto EC = InfoS.takeError())
|
||||
return EC;
|
||||
DbiStream &DS = DbiS.get();
|
||||
TpiStream &TS = TpiS.get();
|
||||
InfoStream &IS = InfoS.get();
|
||||
|
||||
ListScope L(P, "Streams");
|
||||
uint32_t StreamCount = File.getNumStreams();
|
||||
for (uint32_t StreamIdx = 0; StreamIdx < StreamCount; ++StreamIdx) {
|
||||
std::string Name("Stream ");
|
||||
Name += to_string(StreamIdx);
|
||||
P.printNumber(Name, File.getStreamByteSize(StreamIdx));
|
||||
std::unordered_map<uint16_t, const ModuleInfoEx *> ModStreams;
|
||||
std::unordered_map<uint16_t, std::string> NamedStreams;
|
||||
|
||||
for (auto &ModI : DS.modules()) {
|
||||
uint16_t SN = ModI.Info.getModuleStreamIndex();
|
||||
ModStreams[SN] = &ModI;
|
||||
}
|
||||
for (auto &NSE : IS.named_streams()) {
|
||||
NamedStreams[NSE.second] = NSE.first();
|
||||
}
|
||||
|
||||
for (uint16_t StreamIdx = 0; StreamIdx < StreamCount; ++StreamIdx) {
|
||||
std::string Label("Stream ");
|
||||
Label += to_string(StreamIdx);
|
||||
std::string Value;
|
||||
if (StreamIdx == 0)
|
||||
Value = "MSF Superblock";
|
||||
else if (StreamIdx == StreamPDB)
|
||||
Value = "PDB Stream";
|
||||
else if (StreamIdx == StreamDBI)
|
||||
Value = "DBI Stream";
|
||||
else if (StreamIdx == StreamTPI)
|
||||
Value = "TPI Stream";
|
||||
else if (StreamIdx == StreamIPI)
|
||||
Value = "IPI Stream";
|
||||
else if (StreamIdx == DS.getGlobalSymbolStreamIndex())
|
||||
Value = "Global Symbol Hash";
|
||||
else if (StreamIdx == DS.getPublicSymbolStreamIndex())
|
||||
Value = "Public Symbol Hash";
|
||||
else if (StreamIdx == DS.getSymRecordStreamIndex())
|
||||
Value = "Public Symbol Records";
|
||||
else if (StreamIdx == TS.getTypeHashStreamIndex())
|
||||
Value = "TPI Hash";
|
||||
else if (StreamIdx == TS.getTypeHashStreamAuxIndex())
|
||||
Value = "TPI Aux Hash";
|
||||
else {
|
||||
auto ModIter = ModStreams.find(StreamIdx);
|
||||
auto NSIter = NamedStreams.find(StreamIdx);
|
||||
if (ModIter != ModStreams.end()) {
|
||||
Value = "Module \"";
|
||||
Value += ModIter->second->Info.getModuleName();
|
||||
Value += "\"";
|
||||
} else if (NSIter != NamedStreams.end()) {
|
||||
Value = "Named Stream \"";
|
||||
Value += NSIter->second;
|
||||
Value += "\"";
|
||||
} else {
|
||||
Value = "???";
|
||||
}
|
||||
}
|
||||
Value = "[" + Value + "]";
|
||||
Value =
|
||||
Value + " (" + to_string(File.getStreamByteSize(StreamIdx)) + " bytes)";
|
||||
|
||||
P.printString(Label, Value);
|
||||
}
|
||||
P.flush();
|
||||
return Error::success();
|
||||
}
|
||||
|
||||
@ -473,7 +538,7 @@ static Error dumpStructure(RawSession &RS) {
|
||||
if (auto EC = dumpFileHeaders(P, File))
|
||||
return EC;
|
||||
|
||||
if (auto EC = dumpStreamSizes(P, File))
|
||||
if (auto EC = dumpStreamSummary(P, File))
|
||||
return EC;
|
||||
|
||||
if (auto EC = dumpStreamBlocks(P, File))
|
||||
@ -515,9 +580,9 @@ bool isRawDumpEnabled() {
|
||||
return true;
|
||||
if (opts::DumpPublics)
|
||||
return true;
|
||||
if (opts::DumpStreamBlocks)
|
||||
if (opts::DumpStreamSummary)
|
||||
return true;
|
||||
if (opts::DumpStreamSizes)
|
||||
if (opts::DumpStreamBlocks)
|
||||
return true;
|
||||
if (opts::DumpSymRecordBytes)
|
||||
return true;
|
||||
|
Loading…
Reference in New Issue
Block a user