Skip to content

[cDAC] Implement GetManagedStoppedContext for cDAC#128865

Open
barosiak wants to merge 11 commits into
dotnet:mainfrom
barosiak:barosiak/GetManagedStoppedContext
Open

[cDAC] Implement GetManagedStoppedContext for cDAC#128865
barosiak wants to merge 11 commits into
dotnet:mainfrom
barosiak:barosiak/GetManagedStoppedContext

Conversation

@barosiak
Copy link
Copy Markdown
Member

@barosiak barosiak commented Jun 1, 2026

Summary

Implement GetManagedStoppedContext in the cDAC DBI layer, porting the logic from the native DAC. Add the InteropDebuggingHijacked field to the Thread data descriptor.

Changes

  • Port GetManagedStoppedContext to managed cDAC with #if DEBUG legacy validation
  • Add InteropDebuggingHijacked to Thread data descriptor (native, managed, docs)
  • Add mock infrastructure for ResumableFrame and redirected thread frames
  • Add tests covering all code paths

@barosiak barosiak self-assigned this Jun 1, 2026
Copilot AI review requested due to automatic review settings June 1, 2026 21:11
@barosiak barosiak changed the title Implement GetManagedStoppedContext for cDAC [cDAC] Implement GetManagedStoppedContext for cDAC Jun 1, 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.

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

Ports the DAC GetManagedStoppedContext implementation to the cDAC managed DBI layer, exposes the InteropDebuggingHijacked field on the Thread descriptor, and adds mock infrastructure plus tests covering each branch (hijacked, filter-context, redirected-thread, no-context).

Changes:

  • Implement GetManagedStoppedContext in DacDbiImpl mirroring native logic (hijacked → null; else filter context; else RedirectedThreadFrame::TargetContextPtr), with #if DEBUG legacy parity validation.
  • Add InteropDebuggingHijacked to the Thread data descriptor on both native (threads.h, datadescriptor.inc) and managed (Data/Thread.cs, MockDescriptors.Thread.cs) sides, plus docs.
  • Add MockResumableFrame and AddRedirectedThreadFrame helpers; new [Theory] tests covering all four code paths.

Reviewed changes

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

Show a summary per file
File Description
src/coreclr/vm/threads.h Expose m_fInteropDebuggingHijacked offset via cdac_data<Thread>.
src/coreclr/vm/datadescriptor/datadescriptor.inc Register Thread.InteropDebuggingHijacked (T_UINT32).
src/native/managed/cdac/.../Data/Thread.cs Add InteropDebuggingHijacked [Field].
src/native/managed/cdac/.../Dbi/DacDbiImpl.cs Port GetManagedStoppedContext from native DAC with debug-time legacy validation.
src/native/managed/cdac/tests/MockDescriptors/MockDescriptors.Thread.cs Add layout/property for InteropDebuggingHijacked; expose DebuggerFilterContext.
src/native/managed/cdac/tests/MockDescriptors/MockDescriptors.Frame.cs Add MockResumableFrame, RedirectedThreadFrameIdentifierValue, AddRedirectedThreadFrame.
src/native/managed/cdac/tests/DacDbiImplTests.cs Add four [Theory] tests covering the implementation's branches.
docs/design/datacontracts/Thread.md Document new InteropDebuggingHijacked field.

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.

We should not be doing all these field reads outside of the contract APIs. The idea is that the contract encapsulate the important concepts about runtime structures, and that the consumers - the DacDbi and SOS APIs, for example - can put them together without looking at the offsets and other implementation details of the runtime. For example you could have a Thread API GetRedirectedContext to get the redirected context (or NULL if it doesn't exist), and an API IsInteropDebuggingHijacked

@barosiak barosiak requested a review from rcj1 June 1, 2026 23:57
Comment thread docs/design/datacontracts/Thread.md Outdated
Copilot AI review requested due to automatic review settings June 2, 2026 17:53
@barosiak barosiak requested a review from rcj1 June 2, 2026 17:55
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

Copilot reviewed 10 out of 10 changed files in this pull request and generated 2 comments.

Comment thread docs/design/datacontracts/Thread.md Outdated
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings June 2, 2026 18:11
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

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

Comment thread docs/design/datacontracts/Thread.md Outdated
Comment thread docs/design/datacontracts/Thread.md Outdated
Comment thread docs/design/datacontracts/Thread.md Outdated
Comment thread docs/design/datacontracts/Thread.md Outdated
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings June 2, 2026 19:00
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.

Copilot's findings

  • Files reviewed: 10/10 changed files
  • Comments generated: 1

@barosiak barosiak requested a review from rcj1 June 2, 2026 19:53
Comment thread docs/design/datacontracts/Thread.md Outdated
Copy link
Copy Markdown
Member

@noahfalk noahfalk left a comment

Choose a reason for hiding this comment

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

This looks good to me, either with the current API shape or if we merge more of it into ThreadData.

Copilot AI review requested due to automatic review settings June 2, 2026 21:40
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.

Copilot's findings

  • Files reviewed: 13/13 changed files
  • Comments generated: 2

Comment thread src/native/managed/cdac/tests/DacDbiImplTests.cs Outdated
Comment thread docs/design/datacontracts/StackWalk.md Outdated
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings June 2, 2026 21:51
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.

Copilot's findings

  • Files reviewed: 13/13 changed files
  • Comments generated: 2

Comment thread docs/design/datacontracts/Thread.md Outdated
@barosiak barosiak requested review from max-charlamb and noahfalk June 2, 2026 23:42
Comment thread docs/design/datacontracts/StackWalk.md Outdated
Copilot AI review requested due to automatic review settings June 3, 2026 00:00
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

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

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

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.

5 participants