This is an archive of the discontinued LLVM Phabricator instance.

llvm-pdbdump: Fix several smaller issues with injected source compression handling
ClosedPublic

Authored by thakis on Jul 17 2019, 12:37 PM.

Details

Summary
  • 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.

Diff Detail

Event Timeline

thakis created this revision.Jul 17 2019, 12:37 PM
Herald added a project: Restricted Project. · View Herald TranscriptJul 17 2019, 12:38 PM
Herald added a subscriber: hiraditya. · View Herald Transcript
rnk accepted this revision.Jul 17 2019, 1:53 PM

lgtm with a suggestion

llvm/lib/DebugInfo/PDB/Native/NativeEnumInjectedSources.cpp
20

Perhaps Limit should be uint32_t since PDBs have some inherent 32-bit size limitations, and this is PDB-specific code? It would avoid the casts for std::min.

This revision is now accepted and ready to land.Jul 17 2019, 1:53 PM
thakis marked an inline comment as done.Jul 17 2019, 3:23 PM

Thanks!

llvm/lib/DebugInfo/PDB/Native/NativeEnumInjectedSources.cpp
20

You're completely right. I had done this because IPDBInjectedSource::getCodeByteSize() returns 64-bit, but Entry.FileSize is just 32 bits.

getCodeByteSize() returns 64 bit because that's what the DIA version returns: https://docs.microsoft.com/en-us/visualstudio/debugger/debug-interface-access/idiainjectedsource-get-length?view=vs-2019

But it also says "the same value as returned by the IDiaInjectedSource::get_source method" and that returns a DWORD. Weird that dia returns 64-bit. Anyhow, changed just this function here to take a uint32_t, and I'm now passing in Entry.FileSize.

This revision was automatically updated to reflect the committed changes.