Skip to content

[cDAC] Implement GetNativeCodeSequencePointsAndVarInfo for cDAC#129267

Open
barosiak wants to merge 9 commits into
dotnet:mainfrom
barosiak:barosiak/GetNativeCodeSequencePointsAndVarInfo
Open

[cDAC] Implement GetNativeCodeSequencePointsAndVarInfo for cDAC#129267
barosiak wants to merge 9 commits into
dotnet:mainfrom
barosiak:barosiak/GetNativeCodeSequencePointsAndVarInfo

Conversation

@barosiak

@barosiak barosiak commented Jun 11, 2026

Copy link
Copy Markdown
Member

Summary

Implement GetNativeCodeSequencePointsAndVarInfo in the cDAC DacDbiImpl. The interface is changed from output-pointer parameters (NativeVarData*, SequencePoints*) to a callback pattern (FP_NATIVEVARINFO_CALLBACK, FP_SEQUENCEPOINT_CALLBACK), since the managed cDAC cannot use the native forDbi allocator.
Also adds TryGetMethodSignature to IRuntimeTypeSystem to fix GetArgCount and ClrDataFrame methods failing on methods without metadata tokens (e.g. async variants), and removes the unused vlMemory member from ICorDebugInfo::VarLoc (with a JIT/EE version GUID bump).

Changes

  • dacdbi.idl / dacdbiinterface.h / dacdbiimpl.h - Add callback typedefs, update method signature
  • dacdbiimpl.cpp - Rewrite method to use callbacks, remove GetNativeVarData/GetSequencePoints helpers
  • module.cpp - Rewrite LoadNativeInfo with callback struct
  • IDacDbiInterface.cs - Add VarLocType, VarLoc, NativeVarInfo, DbiOffsetMapping structs, DbiSourceTypes enum and update method signature
  • DacDbiImpl.cs - Implement GetNativeCodeSequencePointsAndVarInfo
  • DacDbiImpl.NativeCodeInfo.cs - conversion helpers and DEBUG validation
  • RuntimeTypeSystem.md - Document TryGetMethodSignature and AsyncMethodData descriptors
  • DacDbiImplTests.cs - unit tests for VarLoc type mapping, field-level conversion, and SourceTypes flag conversion
  • IRuntimeTypeSystem.cs / RuntimeTypeSystem_1.cs - Add TryGetMethodSignature
  • AsyncMethodData.cs / method.hpp / siginfo.hpp / datadescriptor.inc - Expose Sig and cSig fields from AsyncMethodData
  • ClrDataFrame.cs - Extract GetFrameMethodDesc helper, update callers to use TryGetMethodSignature
  • TypeNameBuilder.cs / MethodSignatureHelpers.cs - Use TryGetMethodSignature for signature resolution

@barosiak barosiak self-assigned this Jun 11, 2026
Copilot AI review requested due to automatic review settings June 11, 2026 00:10
@dotnet-policy-service

Copy link
Copy Markdown
Contributor

Tagging subscribers to this area: @steveisok, @tommcdon, @dotnet/dotnet-diag
See info in area-owners.md if you want to be subscribed.

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

This PR updates the DAC↔DBI contract for GetNativeCodeSequencePointsAndVarInfo to use a callback-based enumeration model (instead of DBI-allocated output buffers), and wires up the managed cDAC (DacDbiImpl) implementation plus supporting interop structs and unit tests.

Changes:

  • Replaces out-pointer buffer parameters with callback delegates for native var info and sequence points (IDL + native headers + native implementation + DBI consumer).
  • Adds managed interop representations for native debug-info types and implements the cDAC-side method that enumerates var info and sequence points via callbacks.
  • Adds unit tests for var location kind mapping and SourceTypes flag conversion.

Reviewed changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated 8 comments.

Show a summary per file
File Description
src/native/managed/cdac/tests/UnitTests/DacDbiImplTests.cs Adds unit tests for VarLoc kind/field mapping and SourceTypes flag conversion.
src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Legacy/Dbi/IDacDbiInterface.cs Adds managed interop structs/enums and updates method signature to callback-based pattern.
src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Legacy/Dbi/DacDbiImpl.NativeCodeInfo.cs Adds conversion helpers, fixed-arg counting helper, and DEBUG legacy validation.
src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Legacy/Dbi/DacDbiImpl.cs Implements callback-based GetNativeCodeSequencePointsAndVarInfo using cDAC contracts.
src/coreclr/inc/dacdbi.idl Updates the COM IDL to define callback typedefs and the new method signature.
src/coreclr/inc/cordebuginfo.h Documents that specific debug-info types are mirrored in managed code.
src/coreclr/debug/inc/dacdbiinterface.h Updates the native interface signature and adds callback typedefs.
src/coreclr/debug/di/module.cpp Updates CordbNativeCode::LoadNativeInfo to collect entries via callbacks and initialize its internal containers.
src/coreclr/debug/daccess/dacdbiimpl.h Updates the native DAC implementation signature to the new callback-based shape.
src/coreclr/debug/daccess/dacdbiimpl.cpp Rewrites the DAC implementation to enumerate var info / sequence points and invoke callbacks.

Comment thread src/coreclr/debug/di/module.cpp Outdated
Comment thread src/native/managed/cdac/tests/UnitTests/DacDbiImplTests.cs
Comment thread src/coreclr/debug/di/module.cpp Outdated

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

Copilot reviewed 22 out of 22 changed files in this pull request and generated 4 comments.

VLT_INVALID,
}

// The native VarLoc struct contains a union with a void* member (vlMemory),

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.

I think we can remove this member

@rcj1 rcj1 Jun 18, 2026

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.

This will probably require changing the layout in src/coreclr/tools/Common/JitInterface/CorInfoTypes.VarInfo.cs as well as the JITEEVersionIdentifier

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Removed. Is that what you had in mind?

@noahfalk noahfalk left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I agree with the outstanding comments, but otherwise LGTM

string? paramName = GetParameterName(mdReader, methodDef, mdIndex);
OutputBufferHelpers.CopyStringToBuffer(name, bufLen, nameLen, paramName ?? string.Empty);
uint token = rts.GetMethodToken(mdh);
MetadataReader? mdReader = (EcmaMetadataUtils.GetRowId(token) != 0)

@rcj1 rcj1 Jun 17, 2026

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.

What happens without the null row check? And how does the native equivalent deal with this?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Array Get/Set/Address methods aren't no-metadata but carry a nil MethodDef token, which would throw when resolving the param name from an invalid row.
FindParamOfMethod just returns an error HRESULT for a nil token, so the row-id check skips name resolution to match.

Comment thread src/coreclr/debug/daccess/dacdbiimpl.cpp Outdated
Copilot AI review requested due to automatic review settings June 22, 2026 23:44
@barosiak barosiak removed the request for review from MichalStrehovsky June 22, 2026 23:45

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

Copilot reviewed 25 out of 25 changed files in this pull request and generated 5 comments.

Comment thread src/coreclr/debug/daccess/dacdbiimpl.cpp
Copilot AI review requested due to automatic review settings June 23, 2026 00:23

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

Copilot reviewed 25 out of 25 changed files in this pull request and generated 3 comments.

Comment thread src/coreclr/debug/daccess/dacdbiimpl.cpp Outdated
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings June 23, 2026 00:44

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

Copilot reviewed 25 out of 25 changed files in this pull request and generated 4 comments.

public virtual bool IsAsyncMethod(MethodDescHandle methodDesc);

// Gets the raw signature bytes for a MethodDesc by checking the stored signature,
// then the async variant signature, then ECMA metadata. Returns false if no

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.

The implementation details of where you look for these are not part of the contract, please remove from this comment block

{
[Field] public uint Flags { get; }
[Field] public TargetPointer Sig { get; }
[Field] public uint cSig { get; }

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.

Suggested change
[Field] public uint cSig { get; }
[Field] public uint CSig { get; }

nit

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

We shouldn't use Hungarian notation in C# anyways. See VASigCookie where these are renamed to SignaturePointer/SignatureLength.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Looking at this more, we may want to actually have an IData type for Signature instead of accessing the fields directly across multiple types (VASigCookie and now AsyncMethodData)

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.

Sounds good

@rcj1 rcj1 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.

LGTM modulo a few nits.

Comment on lines +1552 to +1556
if (methodDesc.Classification is MethodClassification.Dynamic or MethodClassification.EEImpl or MethodClassification.Array)
{
signature = AsStoredSigMethodDesc(methodDesc).Signature;
return true;
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Use existing IsStoredSigMethodDesc

Comment on lines +252 to +254
// Gets the raw signature bytes for a MethodDesc by checking stored signature, async variant signature, then metadata.
// Returns false if no signature could be resolved.
bool TryGetMethodSignature(MethodDescHandle methodDesc, out ReadOnlySpan<byte> signature) => throw new NotImplementedException();

@max-charlamb max-charlamb Jun 24, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Does it make more sense to implement just the Async variant signature lookup? These other operations are already exposed. Similar idea to #129484 (comment)

It seems like we could expose this helper functionality on MethodSignatureHelpers

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.

I prefer consolidating them just because I do not see one being used without the other and they all serve the same purpose.

@max-charlamb max-charlamb Jun 24, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Then we should remove the stored sig variant (IsStoredSigMethodDesc).

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants