Skip to content

[cDAC] fix some DacDbi bugs#126971

Closed
rcj1 wants to merge 2 commits intodotnet:mainfrom
rcj1:fix-some-bugs
Closed

[cDAC] fix some DacDbi bugs#126971
rcj1 wants to merge 2 commits intodotnet:mainfrom
rcj1:fix-some-bugs

Conversation

@rcj1
Copy link
Copy Markdown
Contributor

@rcj1 rcj1 commented Apr 15, 2026

  • Correctly implement IsValueType to look for ValueType flag on MethodTables
  • Implement GetCurrentException
  • Fix validation in HasTypeParams - DAC was returning the value of a flag, cDAC was returning 1/0. Fixed native impl to return 1/0.

@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 updates the cDAC DacDbi implementation to better match native DAC behavior for value-type classification, current-exception retrieval, and generic-variable detection, and adjusts the related contract surface and tests.

Changes:

  • Add IRuntimeTypeSystem.IsValueType and implement it in RuntimeTypeSystem_1 (method-table flags + typedesc fallback).
  • Implement DacDbiImpl.GetCurrentException via the Thread contract’s current-exception handle API.
  • Fix native MethodTable::ContainsGenericVariables to return a proper BOOL (0/1), aligning HasTypeParams behavior.

Reviewed changes

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

Show a summary per file
File Description
src/native/managed/cdac/tests/DumpTests/DacDbi/DacDbiThreadDumpTests.cs Updates dump-based test expectations for GetCurrentException.
src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Legacy/Dbi/DacDbiImpl.cs Switches DacDbi GetCurrentException to use Thread contract handle API; updates IsValueType to call RTS.
src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Contracts/RuntimeTypeSystemHelpers/MethodTableFlags_1.cs Adds helper flag/property for detecting value types from method table flags.
src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Contracts/Contracts/RuntimeTypeSystem_1.cs Implements IsValueType(TypeHandle) in the RuntimeTypeSystem contract implementation.
src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Abstractions/Contracts/IThread.cs Removes obsolete GetThrowableObject API from the Thread contract abstraction.
src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Abstractions/Contracts/IRuntimeTypeSystem.cs Adds IsValueType(TypeHandle) to the RuntimeTypeSystem contract abstraction.
src/coreclr/vm/methodtable.h Normalizes ContainsGenericVariables return type/value to true BOOL semantics (0/1).
docs/design/datacontracts/RuntimeTypeSystem.md Documents the new IsValueType RTS API.


public bool HasComponentSize => GetFlag(WFLAGS_HIGH.HasComponentSize) != 0;
public bool IsInterface => GetFlag(WFLAGS_HIGH.Category_Mask) == WFLAGS_HIGH.Category_Interface;
public bool IsValueType => GetFlag(WFLAGS_HIGH.Category_Mask) == WFLAGS_HIGH.Category_ValueType;
Comment on lines 147 to 154
TargetPointer current = storeData.FirstThread;
Assert.NotEqual(TargetPointer.Null, current);

ulong exception;
int hr = dbi.GetCurrentException(current, &exception);

// GetCurrentException depends on Thread.GetThrowableObject which is not yet
// implemented in the Thread contract. Skip until the contract is available.
if (hr == unchecked((int)0x80004001)) // E_NOTIMPL — GetThrowableObject not yet in Thread contract
{
throw new SkipTestException("GetThrowableObject not yet implemented in Thread contract");
}

Assert.Equal(System.HResults.S_OK, hr);
Assert.NotEqual(0ul, exception);
}
Comment on lines +528 to 529
TargetPointer throwable = _target.Contracts.Thread.GetCurrentExceptionHandle(new TargetPointer(vmThread))
*pRetVal = throwable.Value;
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.

2 participants