Skip to content

Add missing portable PDB debug data types and fix the FPO value - #781

Merged
Washi1337 merged 1 commit into
Washi1337:developmentfrom
Sergio0694:issue/missing-debug-data-types
Sep 10, 2026
Merged

Washi1337 merged 1 commit into
Washi1337:developmentfrom
Sergio0694:issue/missing-debug-data-types

Conversation

@Sergio0694

Copy link
Copy Markdown
Contributor

Summary

Adds the two portable PDB debug data types that DebugDataType was missing, and fixes Fpo, which was defined as 0 instead of 3.

Motivation

DebugDataType has no members for two of the debug directory entry types that every deterministic .NET assembly built with embedded symbols carries:

Constant Value Status
IMAGE_DEBUG_TYPE_EMBEDDED_PORTABLE_PDB 17 missing
IMAGE_DEBUG_TYPE_PDBCHECKSUM 19 missing

Both are defined by the Portable PDB specification and are present in System.Reflection.PortableExecutable.DebugDirectoryEntryType. Reading and writing these entries already works (they fall through to CustomDebugDataSegment in DefaultDebugDataReader), but callers have to cast a magic number to name them:

// Today
image.DebugData.Add(new DebugDataEntry(new CustomDebugDataSegment((DebugDataType)17, pdb)));

// With this change
image.DebugData.Add(new DebugDataEntry(new CustomDebugDataSegment(DebugDataType.EmbeddedPortablePdb, pdb)));

Separately, Fpo is declared as 0, but IMAGE_DEBUG_TYPE_FPO is 3. As a result DebugDataType.Fpo == DebugDataType.Unknown is true, and a real type 3 entry is surfaced as an unnamed (DebugDataType)3 instead of Fpo. This looks like a typo rather than something intentional, since every other member matches its winnt.h value.

Changes

  • src/AsmResolver.PE/Debug/DebugDataType.cs: adds EmbeddedPortablePdb = 17 and PdbChecksum = 19, and corrects Fpo from 0 to 3.

  • test/AsmResolver.PE.Tests/Debug/DebugDataEntryTest.cs: adds PersistentPortablePdbEntries, asserting that entries of the newly named types survive a build and reload round trip alongside Repro.

Notes

Changing the value of Fpo is technically a source and binary compatible but behavior changing fix, so it is worth calling out explicitly. In practice nothing can be relying on the current value in a meaningful way: it is indistinguishable from Unknown, so any code branching on DebugDataType.Fpo today is matching unknown entries rather than FPO entries. I am happy to split it into its own pull request if you would rather keep the additions separate from the fix.

18 is deliberately not added: unlike 17 and 19 it is not part of the specification linked above and has no winnt.h constant.

All 313 tests in AsmResolver.PE.Tests pass.

@Washi1337 Washi1337 added enhancement pe Issues related to AsmResolver.PE portable-pdb Issues related to AsmResolver.Symbols.PortablePdb labels Aug 28, 2026
@Washi1337 Washi1337 added this to the 6.1.0 milestone Aug 28, 2026
@Washi1337

Copy link
Copy Markdown
Owner

LGTM, if you can rebase the branch to latest dev then I can merge it safely.

The FPO debug data type was defined as 0 rather than 3, which made it an alias
of Unknown, so a type 3 debug directory entry never mapped onto it.

Also adds the two portable PDB debug data types defined by the Portable PDB
specification, which had no members: EMBEDDED_PORTABLE_PDB (17) and
PDBCHECKSUM (19).

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@Sergio0694
Sergio0694 force-pushed the issue/missing-debug-data-types branch from 5a27444 to a05472f Compare September 10, 2026 10:49
@Washi1337
Washi1337 merged commit a7cdd85 into Washi1337:development Sep 10, 2026
7 checks passed
@Sergio0694
Sergio0694 deleted the issue/missing-debug-data-types branch September 10, 2026 11:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement pe Issues related to AsmResolver.PE portable-pdb Issues related to AsmResolver.Symbols.PortablePdb

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants