[llvm] r270653 - [llvm-pdbdump] Dump stream summary list.
Zachary Turner via llvm-commits
llvm-commits at lists.llvm.org
Tue May 24 20:43:18 PDT 2016
Author: zturner
Date: Tue May 24 22:43:17 2016
New Revision: 270653
URL: http://llvm.org/viewvc/llvm-project?rev=270653&view=rev
Log:
[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.
Modified:
llvm/trunk/include/llvm/DebugInfo/PDB/Raw/InfoStream.h
llvm/trunk/include/llvm/DebugInfo/PDB/Raw/NameMap.h
llvm/trunk/include/llvm/DebugInfo/PDB/Raw/TpiStream.h
llvm/trunk/lib/DebugInfo/PDB/Raw/InfoStream.cpp
llvm/trunk/lib/DebugInfo/PDB/Raw/NameMap.cpp
llvm/trunk/lib/DebugInfo/PDB/Raw/TpiStream.cpp
llvm/trunk/test/DebugInfo/PDB/pdbdump-headers.test
llvm/trunk/tools/llvm-pdbdump/llvm-pdbdump.cpp
Modified: llvm/trunk/include/llvm/DebugInfo/PDB/Raw/InfoStream.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/PDB/Raw/InfoStream.h?rev=270653&r1=270652&r2=270653&view=diff
==============================================================================
--- llvm/trunk/include/llvm/DebugInfo/PDB/Raw/InfoStream.h (original)
+++ llvm/trunk/include/llvm/DebugInfo/PDB/Raw/InfoStream.h Tue May 24 22:43:17 2016
@@ -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; }
Modified: llvm/trunk/include/llvm/DebugInfo/PDB/Raw/NameMap.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/PDB/Raw/NameMap.h?rev=270653&r1=270652&r2=270653&view=diff
==============================================================================
--- llvm/trunk/include/llvm/DebugInfo/PDB/Raw/NameMap.h (original)
+++ llvm/trunk/include/llvm/DebugInfo/PDB/Raw/NameMap.h Tue May 24 22:43:17 2016
@@ -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;
};
Modified: llvm/trunk/include/llvm/DebugInfo/PDB/Raw/TpiStream.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/PDB/Raw/TpiStream.h?rev=270653&r1=270652&r2=270653&view=diff
==============================================================================
--- llvm/trunk/include/llvm/DebugInfo/PDB/Raw/TpiStream.h (original)
+++ llvm/trunk/include/llvm/DebugInfo/PDB/Raw/TpiStream.h Tue May 24 22:43:17 2016
@@ -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;
Modified: llvm/trunk/lib/DebugInfo/PDB/Raw/InfoStream.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/PDB/Raw/InfoStream.cpp?rev=270653&r1=270652&r2=270653&view=diff
==============================================================================
--- llvm/trunk/lib/DebugInfo/PDB/Raw/InfoStream.cpp (original)
+++ llvm/trunk/lib/DebugInfo/PDB/Raw/InfoStream.cpp Tue May 24 22:43:17 2016
@@ -53,6 +53,11 @@ uint32_t InfoStream::getNamedStreamIndex
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);
}
Modified: llvm/trunk/lib/DebugInfo/PDB/Raw/NameMap.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/PDB/Raw/NameMap.cpp?rev=270653&r1=270652&r2=270653&view=diff
==============================================================================
--- llvm/trunk/lib/DebugInfo/PDB/Raw/NameMap.cpp (original)
+++ llvm/trunk/lib/DebugInfo/PDB/Raw/NameMap.cpp Tue May 24 22:43:17 2016
@@ -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())
Modified: llvm/trunk/lib/DebugInfo/PDB/Raw/TpiStream.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/PDB/Raw/TpiStream.cpp?rev=270653&r1=270652&r2=270653&view=diff
==============================================================================
--- llvm/trunk/lib/DebugInfo/PDB/Raw/TpiStream.cpp (original)
+++ llvm/trunk/lib/DebugInfo/PDB/Raw/TpiStream.cpp Tue May 24 22:43:17 2016
@@ -129,6 +129,14 @@ uint32_t TpiStream::NumTypeRecords() con
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);
}
Modified: llvm/trunk/test/DebugInfo/PDB/pdbdump-headers.test
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/PDB/pdbdump-headers.test?rev=270653&r1=270652&r2=270653&view=diff
==============================================================================
--- llvm/trunk/test/DebugInfo/PDB/pdbdump-headers.test (original)
+++ llvm/trunk/test/DebugInfo/PDB/pdbdump-headers.test Tue May 24 22:43:17 2016
@@ -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
Modified: llvm/trunk/tools/llvm-pdbdump/llvm-pdbdump.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-pdbdump/llvm-pdbdump.cpp?rev=270653&r1=270652&r2=270653&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-pdbdump/llvm-pdbdump.cpp (original)
+++ llvm/trunk/tools/llvm-pdbdump/llvm-pdbdump.cpp Tue May 24 22:43:17 2016
@@ -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(ScopedPrint
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 &R
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;
More information about the llvm-commits
mailing list