[cDAC] Implement GetPartialUserState for cDAC#127848
Open
barosiak wants to merge 4 commits intodotnet:mainfrom
Open
[cDAC] Implement GetPartialUserState for cDAC#127848barosiak wants to merge 4 commits intodotnet:mainfrom
barosiak wants to merge 4 commits intodotnet:mainfrom
Conversation
Contributor
|
Tagging subscribers to this area: @steveisok, @tommcdon, @dotnet/dotnet-diag |
Contributor
There was a problem hiding this comment.
Pull request overview
Implements DacDbiImpl.GetPartialUserState in the managed cDAC reader by mapping thread state flags from the IThread contract (including new Interruptible and StateNC/ThreadStateNC) to a typed CorDebugUserState, and adds unit + dump-based tests to validate the mapping.
Changes:
- Extend the Thread contract surface to expose
Interruptibleplus a newStateNCfield (ThreadStateNC) and plumb it through descriptors, data model, and contract implementation. - Replace the legacy-delegation stub for
GetPartialUserStatewith a managed implementation (plus DEBUG cross-validation against legacy DAC). - Add unit and dump tests validating state-flag mapping and
GetPartialUserStateresults.
Reviewed changes
Copilot reviewed 12 out of 12 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| src/native/managed/cdac/tests/ThreadTests.cs | Adds a unit test ensuring raw state fields map to ThreadState / ThreadStateNC. |
| src/native/managed/cdac/tests/MockDescriptors/MockDescriptors.Thread.cs | Extends mock Thread layout to include StateNC and exposes setters. |
| src/native/managed/cdac/tests/DumpTests/DacDbi/DacDbiThreadDumpTests.cs | Adds dump test cross-validating GetPartialUserState against IThread contract data. |
| src/native/managed/cdac/tests/ClrDataExceptionStateTests.cs | Updates mocks constructing ThreadData to include the new StateNC field. |
| src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Legacy/Dbi/IDacDbiInterface.cs | Introduces typed CorDebugUserState and updates GetPartialUserState signature. |
| src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Legacy/Dbi/DacDbiImpl.cs | Implements GetPartialUserState using thread contract data and DEBUG cross-validation. |
| src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Contracts/Data/Thread.cs | Reads new StateNC field from the Thread data descriptor. |
| src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Contracts/Contracts/Thread_1.cs | Maps StateNC into ThreadData and adds Interruptible mapping. |
| src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Abstractions/Contracts/IThread.cs | Extends ThreadState, adds ThreadStateNC, and adds StateNC to ThreadData. |
| src/coreclr/vm/threads.h | Annotates thread state bits and adds m_StateNC to the cDAC data offsets. |
| src/coreclr/vm/datadescriptor/datadescriptor.inc | Adds Thread.StateNC field to the cDAC data descriptor. |
| docs/design/datacontracts/Thread.md | Documents new ThreadState.Interruptible, ThreadStateNC, and ThreadData.StateNC. |
jkotas
reviewed
May 6, 2026
jkotas
reviewed
May 6, 2026
jkotas
approved these changes
May 6, 2026
Comment on lines
5694
to
5695
| // Don't report Thread::TS_AbortRequested | ||
|
|
Member
There was a problem hiding this comment.
Suggested change
| // Don't report Thread::TS_AbortRequested |
Not sure what's the point of this comment
| enum ThreadStateNoConcurrency | ||
| { | ||
| TSNC_Unknown = 0x00000000, // threads are initialized this way | ||
| TSNC_Unknown = 0x00000000, // threads are initialized this way [cDAC] [Thread]: Contract depends on this value. |
Member
There was a problem hiding this comment.
Suggested change
| TSNC_Unknown = 0x00000000, // threads are initialized this way [cDAC] [Thread]: Contract depends on this value. | |
| TSNC_Unknown = 0x00000000, // threads are initialized this way |
Comment on lines
+747
to
+751
| public int GetPartialUserState(ulong vmThread, CorDebugUserState* pRetVal) | ||
| { | ||
| *pRetVal = default; | ||
| int hr = HResults.S_OK; | ||
| try |
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.
Summary
Replaces the legacy-delegation stub in DacDbiImpl.GetPartialUserState with a managed implementation using the IThread contract, mirroring the native C++ logic in dacdbiimpl.cpp that maps thread state flags to CorDebugUserState.
Changes