Skip to content

[clr-interp] Implement interpreter debugging support in CoreCLR #120842

@kotlarmilos

Description

@kotlarmilos

Description

This issue outlines work for debugging support on the CoreCLR interpreter.

Entry points

Tasks:

  • Add a new optimization tier OptimizationTierInterpreted
  • Report this tier through DAC
  • After interpreting a method, call JITComplete to register it with the debugger using the bytecode address instead of native code

Interpreter

Tasks:

  • Implement the INTOP_BREAKPOINT opcode in the interpreter
  • Call the debugger interface and raise a STATUS_BREAKPOINT exception with bytecode IP, frame, stack parameters
  • In the SEH filter, detect STATUS_BREAKPOINT and call FirstChanceNativeException so the debugger is notified
  • Resume normal execution after the debugger handles the breakpoint
  • Implement InterpreterCodeManager::GetFunctionSize() to return the byte length of the interpreted code

Patches

Tasks:

  • Add a new patch kind: PATCH_KIND_NATIVE_INTERPRETER for interpreter breakpoints
  • In ApplyPatch, detect interpreter addresses and and insert an INTOP_BREAKPOINT instruction into the bytecode
  • In UnapplyPatch, restore the original bytecode

IL mapping

Tasks:

  • Update AddBindAndActivateILReplicaPatch to bind breakpoints directly to IL offsets for interpreted methods
  • In MatchPatch and ScanForTriggers, skip comparing bytecode addresses to native IPs
  • In DispatchPatchOrSingleStep, handle interpreter breakpoints separately to avoid false IP-change detection
  • Initialize CodeRegionInfo for interpreted methods using the IL bytecode range (no hot/cold split)
  • Skip native bound initialization in DebuggerJitInfo for interpreted methods

DoD: Hit breakpoint in a sample desktop app via Debugger.Break() and in VSCode. Run debugger tests in the CI.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions