Skip to content

Generating Debug Info for interpreted bytecode #114139

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

Merged
merged 3 commits into from
Apr 3, 2025

Conversation

cshung
Copy link
Contributor

@cshung cshung commented Apr 2, 2025

This change produces the debug info for interpreted byte code.

Changes:

On the compiler:

  1. Changes the offset allocator so that variable are all associated with the first and last instruction when it is alive, and all instructions associated with the nativeOffset, so we have the liveness of all variables and the nativeOffset for all instruction.
  2. Report, for all 1st instruction that has an IL offset, to the debugger a mapping between its ILOffset and IROffset
  3. Report, for all IL variables, their liveness and their offset from the virtualized stack pointer.

On the stack walker:

  1. Whenever we set SP to pFrame, we also set FP to pFrame->pStack, that is because the offset of the variables are relative to pFrame->pStack, and so the debugger needs to know about it, and we chose to report that value through the FP.

On the debugger:

  1. It turns out REGNUM_FP is not defined for AMD64 and is causing problem, just define it there.

The change is tested under SOS so that if we set a breakpoint inside the interpreter routine and do a !clrstack -i -a, we will be able to see the argument and local variables values.

@janvorli
@BrzVlad
@kg
@dotnet/dotnet-diag

@Copilot Copilot AI review requested due to automatic review settings April 2, 2025 05:36
Copy link
Contributor

@Copilot 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 wasn't able to review any files in this pull request.

Files not reviewed (7)
  • src/coreclr/inc/cordebuginfo.h: Language not supported
  • src/coreclr/interpreter/compiler.cpp: Language not supported
  • src/coreclr/interpreter/compiler.h: Language not supported
  • src/coreclr/interpreter/compileropt.cpp: Language not supported
  • src/coreclr/vm/eetwain.cpp: Language not supported
  • src/coreclr/vm/interpexec.cpp: Language not supported
  • src/coreclr/vm/stackwalk.cpp: Language not supported

@cshung cshung force-pushed the public/interpreter-debug-info branch 2 times, most recently from 96e8854 to 37b61a8 Compare April 2, 2025 20:16
@cshung cshung force-pushed the public/interpreter-debug-info branch from 37b61a8 to 48a953d Compare April 2, 2025 20:42
@cshung cshung force-pushed the public/interpreter-debug-info branch from 98bb9c4 to d908781 Compare April 3, 2025 15:02
@cshung cshung merged commit 76093e0 into dotnet:main Apr 3, 2025
97 of 99 checks passed
@cshung cshung deleted the public/interpreter-debug-info branch April 3, 2025 17:51
@janvorli
Copy link
Member

janvorli commented Apr 3, 2025

@cshung I don't actually see the rename from m_pLastIns to m_pLastNewIns as necessary for clarity. And it may also make porting the remaining stuff from Mono a bit more difficult, as it changes the naming convention used there globally. I would prefer sticking to the old name instead.

@janvorli
Copy link
Member

janvorli commented Apr 3, 2025

Also, if we wanted to make a rename like this, it should be done in a separate PR to not to obscure the real change here.

@github-actions github-actions bot locked and limited conversation to collaborators May 4, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants