Skip to content

HostSymbolProvider: implement IClrSymbolProvider.TryGetFieldOffset#5899

Open
max-charlamb wants to merge 1 commit into
dotnet:mainfrom
max-charlamb:max-charlamb/symbolprovider-field-offset
Open

HostSymbolProvider: implement IClrSymbolProvider.TryGetFieldOffset#5899
max-charlamb wants to merge 1 commit into
dotnet:mainfrom
max-charlamb:max-charlamb/symbolprovider-field-offset

Conversation

@max-charlamb

@max-charlamb max-charlamb commented Jun 25, 2026

Copy link
Copy Markdown
Member

Summary

Implements IClrSymbolProvider.TryGetFieldOffset in HostSymbolProvider, resolving (typeName, fieldName) -> offset through the host's type system: IModuleSymbols.TryGetType -> IType.TryGetField -> IField.Offset (backed by the debugger, e.g. DbgEng over the loaded PDBs). The lookup is scoped to the module at moduleBase, mirroring TryGetSymbolAddress.

Dependency

Depends on microsoft/clrmd#1488, which adds IClrSymbolProvider.TryGetFieldOffset. This won't compile in CI until that ships and Microsoft.Diagnostics.Runtime is bumped via dependency flow. Opened as a draft; hold until the ClrMD bump lands.

Implements the new IClrSymbolProvider.TryGetFieldOffset method by
resolving (typeName, fieldName) -> offset through the host's type
system: IModuleSymbols.TryGetType -> IType.TryGetField -> IField.Offset
(backed by the debugger, e.g. DbgEng over the loaded PDBs).

moduleBase == 0 searches every loaded module; NativeAOT single-file
images have one managed module, so the first hit is unambiguous.

Used by the cDAC for NativeAOT, where managed type layout is not
available through ECMA metadata at runtime but is present in the image's
debug info. typeName is the name as it appears in the debug info (the
ILC-mangled UDT name, e.g. S_P_CoreLib_System_Exception).

Depends on the ClrMD change adding IClrSymbolProvider.TryGetFieldOffset;
requires a Microsoft.Diagnostics.Runtime version bump (via dependency
flow) before this compiles in CI.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@max-charlamb max-charlamb marked this pull request as ready for review June 25, 2026 16:00
@max-charlamb max-charlamb requested a review from a team as a code owner June 25, 2026 16:01

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Implements IClrSymbolProvider.TryGetFieldOffset in HostSymbolProvider by routing (moduleBase, typeName, fieldName) -> offset through the host’s module-scoped symbol/type system (IModuleSymbols.TryGetTypeIType.TryGetFieldIField.Offset). This extends the existing “scope to moduleBase” behavior used for symbol-address lookup to field-offset lookup as well.

Changes:

  • Extend HostSymbolProvider to support field offset resolution scoped to a specific module base address.
  • Update the class summary to reflect the expanded responsibilities of the adapter.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@max-charlamb max-charlamb enabled auto-merge (squash) June 25, 2026 16:12
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.

3 participants