[cDAC] Add DacDbi APIs to fill DebuggerIPCE_ExpandedTypeData#128001
Draft
[cDAC] Add DacDbi APIs to fill DebuggerIPCE_ExpandedTypeData#128001
Conversation
add fill expanded type data apis
Contributor
|
Tagging subscribers to this area: @steveisok, @tommcdon, @dotnet/dotnet-diag |
3 tasks
Contributor
There was a problem hiding this comment.
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 newObjectMethodTableglobal through the contract + test mocks. - Implement
TypeHandleToExpandedTypeInfoandGetObjectExpandedTypeInfoin the managedDacDbiImpl, including little-endian writes matching nativePortable<T>. - Update native DBI interface/IDL and call sites to route “type id -> type info” through
TypeHandleToExpandedTypeInfo, and removeGetObjectExpandedTypeInfoFromID.
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 | |||
This was referenced May 10, 2026
Open
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Implement DacDbi APIs
TypeHandleToExpandedTypeInfoandGetObjectExpandedTypeInfoin cDACAdd RuntimeTypeSystem cDAC API
public virtual bool IsObject(TypeHandle typeHandle);Tested on internal diagnostics tests