-
Notifications
You must be signed in to change notification settings - Fork 5.3k
[clr-interp] Add User Breakpoint Support for Interpreter Debugging #121911
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[clr-interp] Add User Breakpoint Support for Interpreter Debugging #121911
Conversation
This reverts commit 4bbc946.
Co-authored-by: Milos Kotlar <kotlarmilos@gmail.com>
0d9c6bc to
5b087e1
Compare
There was a problem hiding this 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 implements support for user breakpoints (System.Diagnostics.Debugger.Break()) in interpreted code by introducing an execution control abstraction layer. The implementation uses bytecode patching to replace interpreter instructions with INTOP_BREAKPOINT opcodes.
Key Changes
- Introduced
IExecutionControlinterface andInterpreterExecutionControlimplementation for bytecode patching - Modified debugger controller to delegate patch operations to execution control for interpreter code
- Implemented
GetFunctionSizeforInterpreterCodeManagerto support debugger operations - Disabled
JITCompletenotification for interpreter code as a temporary workaround - Added frame filtering to prevent interpreter frames from being treated as managed frames during stack walks
Reviewed changes
Copilot reviewed 11 out of 11 changed files in this pull request and generated 7 comments.
Show a summary per file
| File | Description |
|---|---|
| src/coreclr/debug/ee/executioncontrol.h | Defines IExecutionControl interface and InterpreterExecutionControl class for bytecode patching abstraction |
| src/coreclr/debug/ee/executioncontrol.cpp | Implements bytecode patch application/removal by replacing opcodes with INTOP_BREAKPOINT |
| src/coreclr/debug/ee/controller.h | Adds include for execution control header |
| src/coreclr/debug/ee/controller.cpp | Modifies ApplyPatch/UnapplyPatch to delegate to execution control for interpreter code |
| src/coreclr/debug/ee/frameinfo.cpp | Filters out interpreter frames from debugger stack walks |
| src/coreclr/debug/ee/CMakeLists.txt | Adds new execution control source files to build |
| src/coreclr/vm/codeman.h | Adds virtual GetExecutionControl() method to IJitManager and overrides for InterpreterJitManager |
| src/coreclr/vm/codeman.cpp | Implements GetExecutionControl() and includes execution control header |
| src/coreclr/vm/jitinterface.cpp | Temporarily disables JITComplete notification for interpreter code |
| src/coreclr/vm/interpexec.cpp | Implements InterpBreakpoint handler that notifies debugger of breakpoint via exception mechanism |
| src/coreclr/vm/eetwain.cpp | Implements GetFunctionSize for interpreter code manager using GC info decoder |
…kozak/runtime into prototype-interp-user-breakpoints
23ad599 to
4751352
Compare
janvorli
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thank you!
|
Merging, future work is tracked in #120842 |
This PR implements support for setting and handling user breakpoints (
System.Diagnostics.Debugger.Break()) in interpreted code. Regular breakpoints, stepping, etc. are not covered by these changes.Key Changes
Execution Control Abstraction (
executioncontrol.h/cpp)IExecutionControlinterface to abstract breakpoint operations across different execution strategies. Currently just for interpreter but will be extended to other codegens.InterpreterExecutionControlclass for interpreter-specific bytecode patchingApplyPatch(): Replaces bytecode instruction withINTOP_BREAKPOINTopcodeUnapplyPatch(): Restores original bytecode instructionPatch Mechanism:
INTOP_BREAKPOINTinstructionBreakpoint Flow:
INTOP_BREAKPOINTopcodeFirstChanceNativeException()Notes
Testing
Future work