Skip to content

[cDAC] Implement GetLastExceptionState on IXCLRDataTask#125540

Merged
barosiak merged 1 commit intodotnet:mainfrom
barosiak:barosiak/GetLastExceptionState
Mar 16, 2026
Merged

[cDAC] Implement GetLastExceptionState on IXCLRDataTask#125540
barosiak merged 1 commit intodotnet:mainfrom
barosiak:barosiak/GetLastExceptionState

Conversation

@barosiak
Copy link
Copy Markdown
Member

Summary

Implement GetLastExceptionState on the managed ClrDataTask (IXCLRDataTask). Reads LastThrownObjectHandle from the Thread contract, constructs a ClrDataExceptionState with CLRDATA_EXCEPTION_PARTIAL and no nested exception chain, following the same pattern as GetCurrentExceptionState.

Test Results

6 new unit tests pass covering no-exception, with-exception, and nested-exception-not-propagated scenarios, with no regressions.

@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 adds support for retrieving a thread’s last thrown exception state through the cDAC legacy IXCLRDataTask surface, and introduces tests to validate the new behavior.

Changes:

  • Updates IXCLRDataTask.GetLastExceptionState to use DacComNullableByRef<IXCLRDataExceptionState> (consistent with other legacy-layer COM out parameters).
  • Implements ClrDataTask.GetLastExceptionState using ThreadData.LastThrownObjectHandle to construct a ClrDataExceptionState.
  • Adds new unit tests covering GetLastExceptionState success and failure cases, including “no previous exception info” behavior.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
src/native/managed/cdac/tests/ClrDataExceptionStateTests.cs Extends test helpers and adds new test coverage for GetLastExceptionState.
src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Legacy/IXCLRData.cs Changes the COM interface signature for GetLastExceptionState to use DacComNullableByRef.
src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Legacy/ClrDataTask.cs Implements GetLastExceptionState backed by ThreadData.LastThrownObjectHandle.

You can also share your feedback on Copilot code review. Take the survey.

Copy link
Copy Markdown
Contributor

@rcj1 rcj1 left a comment

Choose a reason for hiding this comment

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

Lgtm

@barosiak barosiak merged commit 934cd4d into dotnet:main Mar 16, 2026
58 checks passed
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