Skip to content

Add cross-platform PDB dumping to ilspycmd - #4197

Open
siegfriedpammer wants to merge 5 commits into
masterfrom
feature/dump-pdb
Open

siegfriedpammer wants to merge 5 commits into
masterfrom
feature/dump-pdb

Conversation

@siegfriedpammer

Copy link
Copy Markdown
Member

Adds ilspycmd support for dumping decoded PDB information and Portable PDB metadata tables, replacing the DEBUG-only Pdb2Xml UI command and removing the DiaSymReader dependency chain.

Validation:

  • OPENSSL_ENABLE_SHA1_SIGNATURES=1 dotnet test --project ICSharpCode.ILSpyCmd.Tests/ICSharpCode.ILSpyCmd.Tests.csproj --report-trx --filter "FullyQualifiedName~DumpPdbOptionTests|FullyQualifiedName~DumpTableOptionTests" passed, 24 tests.

Assisted-by: OpenCode:openai/gpt-5.5:OpenCode

Microsoft.DiaSymReader.Converter.Xml was the only reason the app referenced
the DiaSymReader chain, and it dragged the NETStandard.Library 1.6.1 shim set
with it: 77 packages in ILSpy's lock file, several of them needing security
overrides to keep NuGet audit quiet. The command itself only ever ran on
Windows, because the converter reaches into native COM.

Nothing is lost that the tooling cannot do without it. ilspycmd prints the
metadata tables, and Mono.Cecil's symbol readers - already a dependency, and
already what DebugInfoUtils falls back to for a Windows PDB - read both PDB
formats in managed code on every OS.

Assisted-by: Claude:claude-opus-5:Claude Code
The metadata-table dumper only knew the Cor tables, so the debug metadata a
Portable PDB carries had no command-line view at all; the GUI has shown those
eight tables for years. Moving the dumper into ILSpyX puts it next to the PDB
providers it now needs and makes it available to any host, not just ilspycmd.

Two things a user would otherwise trip over: a standalone .pdb is accepted as
an input file, and asking an assembly for a debug table resolves the embedded
or adjacent PDB instead of reporting an empty table. Reading a debug table
without either would silently print nothing at all.

The GUI's StateMachineMethod reader moves to a shared extension. Its own copy
read the MethodDef column with ReadInt16 and switched to the wide form at
ushort.MaxValue rather than 1 << 16, so a large enough method table would have
produced negative RIDs.

Assisted-by: Claude:claude-opus-5:Claude Code
The Pdb2Xml command that just left the app was the only way to see a PDB's
contents, and it was Windows-only. Mono.Cecil's symbol readers cover the
Portable and the Windows (native MSF) format in managed code and pick the
right one themselves, so a single dump path serves both on every OS.

Cecil's object model, rather than raw metadata, is what makes this work for
Windows PDBs at all: they have no metadata tables for --dump-table to read.
That also settles the split between the two options - --dump-table stays the
raw row view of a Portable PDB, --dump-pdb is the decoded one.

Neither symbol reader exposes the document list, so the documents are
collected from the sequence points that reference them.

Assisted-by: Claude:claude-opus-5:Claude Code
PdbDumper reads both Portable and Windows PDBs, but only the Portable path
had tests: Mono.Cecil's native PDB writer is COM-only, so the format cannot
be produced off Windows. The fixture is compiled here by the in-box C#
compiler, which still emits it, and the test asserts the PDB really is the
native format before reading anything out of it - otherwise the suite would
silently re-cover the Portable path.

Assisted-by: Claude:claude-opus-5[1m]:Claude Code
Release builds may optimize away an otherwise unused local even when the PDB still carries local-variable information for active test methods. Assert on a local that survives the Release test assembly so the dump coverage is not tied to optimizer behavior.

Assisted-by: OpenCode:openai/gpt-5.5:OpenCode

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant