Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Preserve custom debug information on types #948

Merged
merged 7 commits into from
Sep 25, 2024

Conversation

sbomer
Copy link
Contributor

@sbomer sbomer commented Jun 4, 2024

Upstreaming change from dotnet#185:

Portable PDBs may have CustomDebugInformation on many metadata entities (see HasCustomDebugInformation in https://github.com/dotnet/runtime/blob/main/docs/design/specs/PortablePdb-Metadata.md#customdebuginformation-table-0x37).

For a select few of the CustomDebugInformation kinds (for example state machine hoisted local scopes), cecil has dedicated types to represent these in the object model. For the rest, cecil just reads the custom debug info out of the blob heap as a byte[].

When writing back a module, cecil walks the metadata as represented in its object model, building the debug information as it goes.

So to support custom debug information for a new metadata token type:

  • the corresponding cecil type should be made to implement ICustomDebugInformationProvider,
  • the backing data for these getters should be populated on-demand, and also by the top-down walk in the immediate module reader, and
  • the top-down walk of metadata for writing should visit the cecil object and write its debug information.

This change implements the above for TypeDefinition. It extends the ISymbolReader/ISymbolWriter interfaces with a new method for reading/writing custom debug info for any ICustomDebugInformationProvider, and provides helpers for calling the symbol reader that can be used when adding custom debug information to other types in the future.

It doesn't include support for decoding the TypeDefinitionDocument debug info - it continues representing these as BinaryCustomDebugInformation.

Fixes dotnet/runtime#100051.

@sbomer
Copy link
Contributor Author

sbomer commented Jun 6, 2024

@jbevain note this is adding methods to the ISymbolReader and ISymbolWriter interfaces which is a breaking change for any implementors. I see we touched ISymbolWriter before (#810 (comment)), but wanted to check with you if this is an OK change.

@sbomer
Copy link
Contributor Author

sbomer commented Jun 10, 2024

I found an example of an implementation of ISymbolWriter outside of cecil: rolfbjarne/xamarin-macios@53874c8.

That one should be easy to fix if we update the interface, but still might change the tradeoffs here. Here's where it was updated in response to the last breaking change: xamarin/xamarin-macios@727a29d#diff-8ee2a110d03b4775ffc5e0a0fd4fdb4354cbea264f8671191ecc6e86609a232fR80

@jbevain jbevain merged commit a0f61f9 into jbevain:master Sep 25, 2024
2 checks passed
@jbevain
Copy link
Owner

jbevain commented Sep 25, 2024

Thanks!

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.

No TypeDefinitionDocuments entries compiled for enums/interfaces etc in pdb
2 participants