Skip to content

[cDAC] Implement DacDbi GetVarArgSig API#128106

Draft
Copilot wants to merge 5 commits into
mainfrom
copilot/implement-cdac-dacdbi-getvarargsig
Draft

[cDAC] Implement DacDbi GetVarArgSig API#128106
Copilot wants to merge 5 commits into
mainfrom
copilot/implement-cdac-dacdbi-getvarargsig

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented May 12, 2026

Adding Signature cDAC APIs

    TargetPointer GetVarArgArgsBase(TargetPointer vaSigCookieAddr) => throw new NotImplementedException();
    void GetVarArgSignature(TargetPointer vaSigCookieAddr, out TargetPointer signatureAddress, out uint signatureLength) => throw new NotImplementedException();

Copilot AI self-assigned this May 12, 2026
Copilot AI review requested due to automatic review settings May 12, 2026 23:27
Copilot AI review requested due to automatic review settings May 12, 2026 23:27
@rcj1 rcj1 changed the title Implement cDAC DacDbi GetVarArgSig on Signature contract [cDAC] Implement DacDbi GetVarArgSig API May 12, 2026
Copilot AI review requested due to automatic review settings May 12, 2026 23:30
@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.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

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 extends the cDAC Signature contract and CoreCLR data descriptors to support DAC/DBI vararg cookie decoding (arg base + raw signature pointer/length), and wires that through the managed legacy DACDBI implementation, with accompanying documentation and unit tests.

Changes:

  • Extend ISignature and implement vararg cookie helpers in Signature_1 (GetVarArgArgsBase, GetVarArgSignature).
  • Introduce a new VASigCookie data descriptor (native) and a managed reader type to expose sizeOfArgs and the embedded Signature pointer/length.
  • Update the legacy DacDbiImpl.GetVarArgSig to use the new contract APIs and add docs/tests.
Show a summary per file
File Description
src/native/managed/cdac/tests/SignatureTests.cs Adds unit tests for vararg cookie signature/arg-base APIs and error paths.
src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Legacy/Dbi/DacDbiImpl.cs Implements GetVarArgSig via cDAC Signature contract (with DEBUG cross-validation).
src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Contracts/Data/VASigCookie.cs Adds managed data reader for the VASigCookie descriptor fields.
src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Contracts/Contracts/Signature/Signature_1.cs Implements the new vararg cookie APIs on the v1 Signature contract.
src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Abstractions/DataType.cs Adds DataType.VASigCookie.
src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Abstractions/Contracts/ISignature.cs Adds new public members to ISignature.
src/coreclr/vm/siginfo.hpp Grants cDAC data access to Signature’s private fields for cookie decoding.
src/coreclr/vm/datadescriptor/datadescriptor.inc Adds the VASigCookie native data descriptor definition.
src/coreclr/vm/ceeload.h Adds cdac_data<VASigCookie> offsets to reach Signature’s pointer/length.
docs/design/datacontracts/Signature.md Documents new APIs, new data descriptor, and vararg cookie decoding behavior.

Copilot's findings

Comments suppressed due to low confidence (1)

src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Abstractions/DataType.cs:183

  • DataType is a public enum with implicit sequential values. Inserting VASigCookie here will shift the numeric values of all subsequent members (the GC Data Types), which is a breaking change for any consumers persisting/casting these values or for any protocol that relies on stable IDs. Prefer appending new members at the end, or assigning an explicit value to the new member (and/or explicitly pinning the existing values) to avoid renumbering.
    ComInterfaceEntry,
    InternalComInterfaceDispatch,
    AuxiliarySymbolInfo,
    VASigCookie,
    CodeRangeMapRangeList,

    /* GC Data Types */

    GCHeap,
  • Files reviewed: 10/10 changed files
  • Comments generated: 4

Comment on lines +55 to +72
TargetPointer ISignature.GetVarArgArgsBase(TargetPointer vaSigCookieAddr)
{
if (vaSigCookieAddr == TargetPointer.Null)
throw new ArgumentException("VASigCookie address must be non-null.", nameof(vaSigCookieAddr));
// Compute the address of the first argument. On x86 the args are pushed below the cookie
// pointer (stack grows down on the args walk), so the first argument lies at
// vaSigCookieAddr + sizeOfArgs.
// On all other platforms the first argument follows the cookie pointer in memory
// (stack grows up on the args walk), so its address is at
// vaSigCookieAddr + sizeof(VASigCookie*).
if (_target.Contracts.RuntimeInfo.GetTargetArchitecture() == RuntimeInfoArchitecture.X86)
{
Data.VASigCookie cookie = GetCookie(vaSigCookieAddr);
return new TargetPointer(vaSigCookieAddr.Value + cookie.SizeOfArgs);
}

return new TargetPointer(vaSigCookieAddr.Value + (ulong)_target.PointerSize);
}
Comment on lines +80 to +83
signatureAddress = cookie.SignaturePointer;
signatureLength = cookie.SignatureLength;
Debug.Assert(signatureAddress != TargetPointer.Null || signatureLength == 0,
"VASigCookie has a non-zero signature length but a null signature pointer.");
Comment thread docs/design/datacontracts/Signature.md
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.

3 participants