diff options
author | Nico Weber <nicolasweber@gmx.de> | 2019-07-17 22:59:52 +0000 |
---|---|---|
committer | Nico Weber <nicolasweber@gmx.de> | 2019-07-17 22:59:52 +0000 |
commit | 7bb5fc058314dba81dd652d8dcc74e133db0b445 (patch) | |
tree | df24b539828a7de97fb3f20673955070d4a84d8d /llvm/lib/DebugInfo | |
parent | 7872d76a16d30a7ee33068c87aa5bb910f48ea64 (diff) | |
download | bcm5719-llvm-7bb5fc058314dba81dd652d8dcc74e133db0b445.tar.gz bcm5719-llvm-7bb5fc058314dba81dd652d8dcc74e133db0b445.zip |
llvm-pdbdump: Fix several smaller issues with injected source compression handling
- getCompression() used to return a PDB_SourceCompression even though
the docs for IDiaInjectedSource are explicit about the return value
being compiler-dependent. Return an uint32_t instead, and make the
printing code handle unknown values better by printing "Unknown" and
the int value instead of not printing any compression.
- Print compressed contents as hex dump, not as string.
- Add compression type "DotNet", which is used (at least) by csc.exe,
the C# compiler. Also add a lengthy comment describing the stream
contents (derived from looking at the raw hex contents long enough
to see the GUIDs, which led me to the roslyn and mono implementations
for handling this).
- The native injected source dumper was dumping the contents of the
whole data stream -- but csc.exe writes a stream that's padded with
zero bytes to the next 512 boundary, and the dia api doesn't display
those padding bytes. So make NativeInjectedSource::getCode() do the
same thing.
Differential Revision: https://reviews.llvm.org/D64879
llvm-svn: 366386
Diffstat (limited to 'llvm/lib/DebugInfo')
-rw-r--r-- | llvm/lib/DebugInfo/PDB/DIA/DIAInjectedSource.cpp | 4 | ||||
-rw-r--r-- | llvm/lib/DebugInfo/PDB/Native/NativeEnumInjectedSources.cpp | 11 | ||||
-rw-r--r-- | llvm/lib/DebugInfo/PDB/PDBExtras.cpp | 7 |
3 files changed, 12 insertions, 10 deletions
diff --git a/llvm/lib/DebugInfo/PDB/DIA/DIAInjectedSource.cpp b/llvm/lib/DebugInfo/PDB/DIA/DIAInjectedSource.cpp index 211b4e11ac4..032b230b5fa 100644 --- a/llvm/lib/DebugInfo/PDB/DIA/DIAInjectedSource.cpp +++ b/llvm/lib/DebugInfo/PDB/DIA/DIAInjectedSource.cpp @@ -41,11 +41,11 @@ std::string DIAInjectedSource::getVirtualFileName() const { &IDiaInjectedSource::get_virtualFilename); } -PDB_SourceCompression DIAInjectedSource::getCompression() const { +uint32_t DIAInjectedSource::getCompression() const { DWORD Compression = 0; if (S_OK != SourceFile->get_sourceCompression(&Compression)) return PDB_SourceCompression::None; - return static_cast<PDB_SourceCompression>(Compression); + return static_cast<uint32_t>(Compression); } std::string DIAInjectedSource::getCode() const { diff --git a/llvm/lib/DebugInfo/PDB/Native/NativeEnumInjectedSources.cpp b/llvm/lib/DebugInfo/PDB/Native/NativeEnumInjectedSources.cpp index 7c7901b708c..f17ff5bb01f 100644 --- a/llvm/lib/DebugInfo/PDB/Native/NativeEnumInjectedSources.cpp +++ b/llvm/lib/DebugInfo/PDB/Native/NativeEnumInjectedSources.cpp @@ -17,14 +17,15 @@ namespace pdb { namespace { -Expected<std::string> readStreamData(BinaryStream &Stream) { - uint32_t Offset = 0, DataLength = Stream.getLength(); +Expected<std::string> readStreamData(BinaryStream &Stream, uint32_t Limit) { + uint32_t Offset = 0, DataLength = std::min(Limit, Stream.getLength()); std::string Result; Result.reserve(DataLength); while (Offset < DataLength) { ArrayRef<uint8_t> Data; if (auto E = Stream.readLongestContiguousChunk(Offset, Data)) return std::move(E); + Data = Data.take_front(DataLength - Offset); Offset += Data.size(); Result += toStringRef(Data); } @@ -62,9 +63,7 @@ public: return *VName; } - PDB_SourceCompression getCompression() const override { - return static_cast<PDB_SourceCompression>(Entry.Compression); - } + uint32_t getCompression() const override { return Entry.Compression; } std::string getCode() const override { // Get name of stream storing the data. @@ -81,7 +80,7 @@ public: return "(failed to open data stream)"; } - auto Data = readStreamData(**ExpectedFileStream); + auto Data = readStreamData(**ExpectedFileStream, Entry.FileSize); if (!Data) { consumeError(Data.takeError()); return "(failed to read data)"; diff --git a/llvm/lib/DebugInfo/PDB/PDBExtras.cpp b/llvm/lib/DebugInfo/PDB/PDBExtras.cpp index 59eadd71856..354a99476c4 100644 --- a/llvm/lib/DebugInfo/PDB/PDBExtras.cpp +++ b/llvm/lib/DebugInfo/PDB/PDBExtras.cpp @@ -320,14 +320,17 @@ raw_ostream &llvm::pdb::operator<<(raw_ostream &OS, return OS; } -raw_ostream &llvm::pdb::operator<<(raw_ostream &OS, - const PDB_SourceCompression &Compression) { +raw_ostream &llvm::pdb::dumpPDBSourceCompression(raw_ostream &OS, + uint32_t Compression) { switch (Compression) { CASE_OUTPUT_ENUM_CLASS_NAME(PDB_SourceCompression, None, OS) CASE_OUTPUT_ENUM_CLASS_NAME(PDB_SourceCompression, Huffman, OS) CASE_OUTPUT_ENUM_CLASS_NAME(PDB_SourceCompression, LZ, OS) CASE_OUTPUT_ENUM_CLASS_STR(PDB_SourceCompression, RunLengthEncoded, "RLE", OS) + CASE_OUTPUT_ENUM_CLASS_NAME(PDB_SourceCompression, DotNet, OS) + default: + OS << "Unknown (" << Compression << ")"; } return OS; } |