Skip to content

Adjust interpreter debugger IL mapping#127469

Open
tommcdon wants to merge 2 commits intodotnet:mainfrom
tommcdon:dev/tommcdon/fix_interpreter_debugger_sequence_points
Open

Adjust interpreter debugger IL mapping#127469
tommcdon wants to merge 2 commits intodotnet:mainfrom
tommcdon:dev/tommcdon/fix_interpreter_debugger_sequence_points

Conversation

@tommcdon
Copy link
Copy Markdown
Member

When the debugger walks the stack, interpreter frames sometimes report incorrect source line due to IL -> native mapping differences compared to how the JIT generates mappings. To better align interpreter debug output with how the debugger maps line numbers:

  1. The current model generates more mapping IL->native data than we need. Only emit sequence points on IL stack empty points and nop instructions.
  2. When stackwalking, the return address points to the instruction after the 'call' instruction. The interpreter eliminates certain IL instructions from the input stream, sometimes causing the next IL instruction to be mapped to the next line number. To address this, 1) when the IL code is built in debug mode, and 2) if an IL instruction is eliminated immediately after a call instruction, we will insert a nop IL instruction in its place.

tommcdon and others added 2 commits April 26, 2026 21:20
…calls

- Filter IL-to-native mapping to statement boundaries
- Emit real NOP after call instructions so return address falls within call range
- Add INTOP_NOP handler in interpreter executor

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Gate the post-call NOP emission on CORJIT_FLAG_DEBUG_CODE so that
release/optimized interpreter code does not pay for the extra instruction.
Debug builds need the NOP to preserve the native offset gap between a call
and the next statement for correct debugger stack walk line numbers.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@tommcdon tommcdon added this to the 11.0.0 milestone Apr 27, 2026
@tommcdon tommcdon requested a review from BrzVlad as a code owner April 27, 2026 20:12
Copilot AI review requested due to automatic review settings April 27, 2026 20:12
@tommcdon tommcdon requested review from janvorli and kg as code owners April 27, 2026 20:12
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 adjusts the CoreCLR interpreter’s debug IL→native boundary generation and stackwalk behavior to better match the debugger’s expectations (notably around call return addresses and sequence-point selection), reducing incorrect source line reporting for interpreter frames.

Changes:

  • Restricts IL→native boundary emission to fewer IL offsets (intended to better approximate “sequence point” style mappings).
  • Inserts an executable no-op after calls (in debug-code mode) when the next IL instruction is eliminated, so the call’s resumption IP maps to the expected statement.
  • Adds runtime execution handling for the emitted no-op and clarifies a stack-unwind comment.

Reviewed changes

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

File Description
src/coreclr/vm/interpexec.cpp Adds execution handling for INTOP_NOP in the interpreter dispatch loop.
src/coreclr/vm/eetwain.cpp Adds a clarifying comment about the interpreter frame IP resumption point during unwinding.
src/coreclr/interpreter/compiler.cpp Changes IL→native boundary emission filtering and injects an executable no-op after calls in debug-code mode when encountering eliminated instructions.

Comment thread src/coreclr/interpreter/compiler.cpp
Comment thread src/coreclr/interpreter/compiler.cpp
Comment thread src/coreclr/vm/interpexec.cpp
Comment thread src/coreclr/vm/eetwain.cpp
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