Skip to content

[cDAC] Remove GetObjectContents DacDbi API#128012

Closed
Copilot wants to merge 3 commits intomainfrom
copilot/change-create-heap-reference-value-arg
Closed

[cDAC] Remove GetObjectContents DacDbi API#128012
Copilot wants to merge 3 commits intomainfrom
copilot/change-create-heap-reference-value-arg

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented May 10, 2026

Delete this API, we don't need it. Object size is already available through GetBasicObjectInfo.

Copilot AI and others added 2 commits May 10, 2026 22:30
…Contents DACDBI API

Co-authored-by: rcj1 <77995559+rcj1@users.noreply.github.com>
Co-authored-by: rcj1 <77995559+rcj1@users.noreply.github.com>
Copilot AI review requested due to automatic review settings May 10, 2026 23:51
Copilot AI review requested due to automatic review settings May 10, 2026 23:51
@rcj1 rcj1 changed the title Switch IsDelegate DACDBI input to CORDB_ADDRESS [cDAC] Remove GetObjectContents DacDbi API May 10, 2026
@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.

@rcj1 rcj1 requested review from jkotas, max-charlamb and noahfalk May 10, 2026 23:54
@rcj1 rcj1 marked this pull request as ready for review May 10, 2026 23:55
Copilot AI review requested due to automatic review settings May 10, 2026 23:55
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 updates the CoreCLR DAC/DBI contract and its managed “legacy/cDAC” projection by removing the GetObjectContents API and adjusting delegate-related APIs to operate on raw CORDB_ADDRESS object addresses, with corresponding right-side updates to stop depending on GetObjectContents.

Changes:

  • Removes GetObjectContents from the native IDL/header contract and from the managed legacy/cDAC COM surface.
  • Switches IsDelegate / delegate helper methods to accept CORDB_ADDRESS instead of VMPTR_Object, and updates call sites accordingly.
  • Refactors right-side heap reference creation to use the object address directly (no DAC roundtrip to “deconstruct” a VMPTR).
Show a summary per file
File Description
src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Legacy/Dbi/IDacDbiInterface.cs Removes the managed COM interface entry for GetObjectContents; renames IsDelegate parameter for clarity.
src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Legacy/Dbi/DacDbiImpl.cs Drops the legacy fallback wrapper for GetObjectContents; updates IsDelegate signature to match the contract change.
src/coreclr/inc/dacdbi.idl Removes GetObjectContents from the IDL and changes delegate-related methods to use CORDB_ADDRESS.
src/coreclr/debug/inc/dacdbiinterface.h Removes GetObjectContents from the C++ interface and updates delegate method signatures/docs.
src/coreclr/debug/di/rspriv.h Updates right-side helper signature to accept an object address instead of VMPTR_Object.
src/coreclr/debug/di/divalue.cpp Removes GetObjectContents usage; passes CORDB_ADDRESS directly for delegate queries/target extraction.
src/coreclr/debug/daccess/dacdbiimpl.h Updates DAC implementation declarations for the delegate APIs; removes GetObjectContents declaration.
src/coreclr/debug/daccess/dacdbiimpl.cpp Removes GetObjectContents implementation; updates delegate APIs to operate on raw addresses.

Copilot's findings

Comments suppressed due to low confidence (1)

src/coreclr/inc/dacdbi.idl:364

  • This change removes/reshapes methods on IDacDbiInterface (vtable layout + parameter types). That’s a protocol-breaking change; without bumping kCurrentDacDbiProtocolBreakingChangeCounter (src/coreclr/debug/inc/dacdbistructures.h:676) older DBI/DAC pairs could still pass CheckDbiVersion and then call mismatched vtable slots, leading to crashes/corruption. Please increment the counter and document the new value in the DbiVersion comment block.
    HRESULT IsVmObjectHandleValid([in] VMPTR_OBJECTHANDLE vmHandle, [out] BOOL * pResult);
    HRESULT IsWinRTModule([in] VMPTR_Module vmModule, [out] BOOL * pIsWinRT);
    HRESULT GetHandleAddressFromVmHandle([in] VMPTR_OBJECTHANDLE vmHandle, [out] CORDB_ADDRESS * pRetVal);

    // Object Contents and Monitor
    HRESULT GetThreadOwningMonitorLock([in] VMPTR_Object vmObject, [out] struct MonitorLockInfo * pRetVal);
    HRESULT EnumerateMonitorEventWaitList([in] VMPTR_Object vmObject, [in] FP_THREAD_ENUMERATION_CALLBACK fpCallback, [in] CALLBACK_DATA pUserData);

    // Attach State
  • Files reviewed: 8/8 changed files
  • Comments generated: 2

Comment thread src/coreclr/inc/dacdbi.idl Outdated
Comment thread src/coreclr/debug/inc/dacdbiinterface.h
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings May 11, 2026 00:05
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.

Copilot's findings

  • Files reviewed: 8/8 changed files
  • Comments generated: 1

Comment thread src/coreclr/inc/dacdbi.idl
IDacDbiInterface *pDAC = GetProcess()->GetDAC();

VMPTR_Object vmObj;
IfFailThrow(pDAC->GetObject(objAddr, &vmObj));
Copy link
Copy Markdown
Member

@max-charlamb max-charlamb May 11, 2026

Choose a reason for hiding this comment

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

Is there a reason to move away from VMPTR_Object in favor of the not type safe CORDB_ADDRESS?

I see in this code path it is a bit redundant, but it seems reasonable to thread all of the object creation through the same method for the purpose of address validation (if we want that).

It looks like we could greatly reduce the PR diff if we limit this change to removing the method.

If we still want to change the VMPTR_Object to CORDB_ADDRESS could we do it in a separate PR and handle all the uses uniformly?

Copy link
Copy Markdown
Contributor

@rcj1 rcj1 May 11, 2026

Choose a reason for hiding this comment

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

We need to use CORDB_ADDRESS instead of the VMPTR because VMPTR is not designed to allow us to grab the raw address in the DBI. (Well, technically theres VmPtrToCookie, but I’m not sure it was designed for this.) I am thinking about a way to handle this uniformly - maybe we can provide a conversion operator from VMPTR to another opaque handle type that we only use on signatures.

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.

Actually, maybe there is a good way to keep the type safety in the general case. But nevertheless, as this path started out with a raw CORDB_ADDRESS, I don’t think we’re really losing much here.

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.

Eh, the thing is with the status quo shape we could verify the object if we wanted to. I wonder if we could just leave this as-is and replace the DBI API with a conversion operator.

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.

4 participants