aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZachary Turner <zturner@google.com>2016-05-25 03:43:17 +0000
committerZachary Turner <zturner@google.com>2016-05-25 03:43:17 +0000
commit85ed80b9e69787452b4c78e37f38e2080b5b87fc (patch)
tree44b413e079629f59bb640c5dfa2a96f47c9eb689
parent2487f19258f721915709b902ac178f74bf560574 (diff)
downloadllvm-85ed80b9e69787452b4c78e37f38e2080b5b87fc.zip
llvm-85ed80b9e69787452b4c78e37f38e2080b5b87fc.tar.gz
llvm-85ed80b9e69787452b4c78e37f38e2080b5b87fc.tar.bz2
[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. llvm-svn: 270653
-rw-r--r--llvm/include/llvm/DebugInfo/PDB/Raw/InfoStream.h1
-rw-r--r--llvm/include/llvm/DebugInfo/PDB/Raw/NameMap.h2
-rw-r--r--llvm/include/llvm/DebugInfo/PDB/Raw/TpiStream.h2
-rw-r--r--llvm/lib/DebugInfo/PDB/Raw/InfoStream.cpp5
-rw-r--r--llvm/lib/DebugInfo/PDB/Raw/NameMap.cpp5
-rw-r--r--llvm/lib/DebugInfo/PDB/Raw/TpiStream.cpp8
-rw-r--r--llvm/test/DebugInfo/PDB/pdbdump-headers.test21
-rw-r--r--llvm/tools/llvm-pdbdump/llvm-pdbdump.cpp91
8 files changed, 121 insertions, 14 deletions
diff --git a/llvm/include/llvm/DebugInfo/PDB/Raw/InfoStream.h b/llvm/include/llvm/DebugInfo/PDB/Raw/InfoStream.h
index c0a3256..6c5c590 100644
--- a/llvm/include/llvm/DebugInfo/PDB/Raw/InfoStream.h
+++ b/llvm/include/llvm/DebugInfo/PDB/Raw/InfoStream.h
@@ -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; }
diff --git a/llvm/include/llvm/DebugInfo/PDB/Raw/NameMap.h b/llvm/include/llvm/DebugInfo/PDB/Raw/NameMap.h
index 451e98d..b832976 100644
--- a/llvm/include/llvm/DebugInfo/PDB/Raw/NameMap.h
+++ b/llvm/include/llvm/DebugInfo/PDB/Raw/NameMap.h
@@ -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;
};
diff --git a/llvm/include/llvm/DebugInfo/PDB/Raw/TpiStream.h b/llvm/include/llvm/DebugInfo/PDB/Raw/TpiStream.h
index ac7c797..f815e5c 100644
--- a/llvm/include/llvm/DebugInfo/PDB/Raw/TpiStream.h
+++ b/llvm/include/llvm/DebugInfo/PDB/Raw/TpiStream.h
@@ -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;
diff --git a/llvm/lib/DebugInfo/PDB/Raw/InfoStream.cpp b/llvm/lib/DebugInfo/PDB/Raw/InfoStream.cpp
index be90285..ccc4a5e 100644
--- a/llvm/lib/DebugInfo/PDB/Raw/InfoStream.cpp
+++ b/llvm/lib/DebugInfo/PDB/Raw/InfoStream.cpp
@@ -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);
}
diff --git a/llvm/lib/DebugInfo/PDB/Raw/NameMap.cpp b/llvm/lib/DebugInfo/PDB/Raw/NameMap.cpp
index b3bd94c..202e717 100644
--- a/llvm/lib/DebugInfo/PDB/Raw/NameMap.cpp
+++ b/llvm/lib/DebugInfo/PDB/Raw/NameMap.cpp
@@ -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())
diff --git a/llvm/lib/DebugInfo/PDB/Raw/TpiStream.cpp b/llvm/lib/DebugInfo/PDB/Raw/TpiStream.cpp
index db2ea20..ed988bb 100644
--- a/llvm/lib/DebugInfo/PDB/Raw/TpiStream.cpp
+++ b/llvm/lib/DebugInfo/PDB/Raw/TpiStream.cpp
@@ -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);
}
diff --git a/llvm/test/DebugInfo/PDB/pdbdump-headers.test b/llvm/test/DebugInfo/PDB/pdbdump-headers.test
index 18681ac..9af170b 100644
--- a/llvm/test/DebugInfo/PDB/pdbdump-headers.test
+++ b/llvm/test/DebugInfo/PDB/pdbdump-headers.test
@@ -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
diff --git a/llvm/tools/llvm-pdbdump/llvm-pdbdump.cpp b/llvm/tools/llvm-pdbdump/llvm-pdbdump.cpp
index 0946873..5071e9e 100644
--- a/llvm/tools/llvm-pdbdump/llvm-pdbdump.cpp
+++ b/llvm/tools/llvm-pdbdump/llvm-pdbdump.cpp
@@ -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;