Skip to content

[cDAC] Add DacDbi APIs to fill DebuggerIPCE_ExpandedTypeData#128001

Draft
Copilot wants to merge 2 commits intomainfrom
copilot/implement-typehandle-to-expanded-type-info
Draft

[cDAC] Add DacDbi APIs to fill DebuggerIPCE_ExpandedTypeData#128001
Copilot wants to merge 2 commits intomainfrom
copilot/implement-typehandle-to-expanded-type-info

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented May 10, 2026

Implement DacDbi APIs TypeHandleToExpandedTypeInfo and GetObjectExpandedTypeInfo in cDAC

Add RuntimeTypeSystem cDAC API public virtual bool IsObject(TypeHandle typeHandle);

Tested on internal diagnostics tests

Copilot AI requested review from Copilot and removed request for Copilot May 10, 2026 01:09
@rcj1 rcj1 changed the title [cDAC] Use little-endian writes for IPCE structs and properly type DacDbi API parameters [cDAC] Add DacDbi APIs to fill DebuggerIPCE_ExpandedTypeData 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.

Copilot AI review requested due to automatic review settings May 10, 2026 04:17
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 DacDbi surface to produce DebuggerIPCE_ExpandedTypeData for a type handle or object address, and adds a RuntimeTypeSystem contract helper for recognizing the System.Object method table (so ELEMENT_TYPE_OBJECT can be reported distinctly from ELEMENT_TYPE_CLASS).

Changes:

  • Add IRuntimeTypeSystem.IsObject(TypeHandle) and plumb a new ObjectMethodTable global through the contract + test mocks.
  • Implement TypeHandleToExpandedTypeInfo and GetObjectExpandedTypeInfo in the managed DacDbiImpl, including little-endian writes matching native Portable<T>.
  • Update native DBI interface/IDL and call sites to route “type id -> type info” through TypeHandleToExpandedTypeInfo, and remove GetObjectExpandedTypeInfoFromID.
Show a summary per file
File Description
src/native/managed/cdac/tests/MockDescriptors/MockDescriptors.RuntimeTypeSystem.cs Adds a mock global for the Object method table and patches it to System.Object’s MT in the mock target.
src/native/managed/cdac/tests/MethodTableTests.cs Extends contract globals and asserts IsObject behavior for FreeObject MT vs System.Object MT.
src/native/managed/cdac/tests/DumpTests/RuntimeTypeSystemDumpTests.cs Adds dump-based assertions for IsObject across object/free/string MTs.
src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Legacy/Dbi/IDacDbiInterface.cs Introduces managed projections of AreValueTypesBoxed and DebuggerIPCE_*TypeData and updates method signatures to typed pointers.
src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Legacy/Dbi/DacDbiImpl.cs Implements TypeHandleToExpandedTypeInfo / GetObjectExpandedTypeInfo and shared filling helpers with Portable-compatible endianness.
src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Contracts/Contracts/RuntimeTypeSystem_1.cs Reads the ObjectMethodTable global and implements IsObject.
src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Abstractions/Contracts/IRuntimeTypeSystem.cs Adds the new IsObject(TypeHandle) API to the public contract interface.
src/coreclr/inc/dacdbi.idl Changes TypeHandleToExpandedTypeInfo to take a raw UINT64 and drops GetObjectExpandedTypeInfoFromID.
src/coreclr/debug/inc/dacdbistructures.h Gives AreValueTypesBoxed explicit values (0/1/2).
src/coreclr/debug/inc/dacdbiinterface.h Updates the COM interface signature and removes GetObjectExpandedTypeInfoFromID.
src/coreclr/debug/di/rstype.cpp Updates RS to call the new TypeHandleToExpandedTypeInfo signature (but currently extracts the handle unsafely).
src/coreclr/debug/di/process.cpp Routes GetTypeForTypeID through TypeHandleToExpandedTypeInfo using COR_TYPEID.token1.
src/coreclr/debug/daccess/dacdbiimpl.h Updates DAC interface declaration to match the new signature.
src/coreclr/debug/daccess/dacdbiimpl.cpp Removes the old FromID method and updates implementation/callers for the new signature + zero-inits output structs.
docs/design/datacontracts/RuntimeTypeSystem.md Documents IsObject and the ObjectMethodTable global (but the globals table still has an incorrect FreeObject global name).

Copilot's findings

  • Files reviewed: 15/15 changed files
  • Comments generated: 5

Comment on lines +1166 to +1167
UINT64 id;
memcpy(&id, &data->vmTypeHandle, sizeof(UINT64));
Comment on lines +1281 to +1320
public int TypeHandleToExpandedTypeInfo(int boxed, ulong vmTypeHandle, DebuggerIPCE_ExpandedTypeData* pTypeInfo)
{
*pTypeInfo = default;
int hr = HResults.S_OK;
try
{
IRuntimeTypeSystem rts = _target.Contracts.RuntimeTypeSystem;
TypeHandle th = rts.GetTypeHandle(new TargetPointer(vmTypeHandle));
TypeHandleToExpandedTypeInfoImpl(rts, (AreValueTypesBoxed)boxed, th, pTypeInfo);
}
catch (System.Exception ex)
{
hr = ex.HResult;
}
#if DEBUG
if (_legacy is not null)
{
DebuggerIPCE_ExpandedTypeData dataLocal;
int hrLocal = _legacy.TypeHandleToExpandedTypeInfo(boxed, vmTypeHandle, &dataLocal);
Debug.ValidateHResult(hr, hrLocal);
if (hr == HResults.S_OK)
{
ValidateExpandedTypeData(pTypeInfo, &dataLocal);
}
}
#endif
return hr;
}

public int GetObjectExpandedTypeInfo(int boxed, ulong addr, nint pTypeInfo)
=> LegacyFallbackHelper.CanFallback() && _legacy is not null ? _legacy.GetObjectExpandedTypeInfo(boxed, addr, pTypeInfo) : HResults.E_NOTIMPL;
public int GetObjectExpandedTypeInfo(int boxed, ulong addr, DebuggerIPCE_ExpandedTypeData* pTypeInfo)
{
*pTypeInfo = default;
int hr = HResults.S_OK;
try
{
IRuntimeTypeSystem rts = _target.Contracts.RuntimeTypeSystem;
TargetPointer mtAddr = _target.Contracts.Object.GetMethodTableAddress(new TargetPointer(addr));
TypeHandle th = rts.GetTypeHandle(mtAddr);
TypeHandleToExpandedTypeInfoImpl(rts, (AreValueTypesBoxed)boxed, th, pTypeInfo);
}
@@ -440,6 +442,7 @@ The contract depends on the following globals
| --- | --- |
| `ContinuationMethodTable` | A pointer to the address of the base `Continuation` `MethodTable`, or null if no continuations have been created
| `FreeObjectMethodTablePointer` | A pointer to the address of a `MethodTable` used by the GC to indicate reclaimed memory
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