-
Notifications
You must be signed in to change notification settings - Fork 5.3k
Add design document for stub target debug data #124035
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
Conversation
Co-authored-by: noahfalk <6243776+noahfalk@users.noreply.github.com>
|
@jkotas - I iterated a little offline with copilot. The design is still incomplete/rough but I think it points in a better direction than the original one did. Getting to a final design that we'd want to implement still seems like more work is required, especially since doing a nice job on the inlining increases the complexity. What I'd like to do is just bank the progress thus far and put this on the shelf until we have a more urgent need to move it forward. I acknowledge right at the top of the doc that the design isn't done to try and avoid anyone else trying to run with it as-is. |
|
|
||
| ## 1. Executive Summary | ||
|
|
||
| This document proposes a rough design for adding debug data to runtime stubs, with an initial focus on stubs compiled from IL. The goal is to enable a simplified stub stepping mechanism in the debugger, reducing complexity and maintenance burden of the current bespoke StubManager prediction logic, while supporting future inlining scenarios where stubs can be inlined into user methods or other stubs. |
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.
where stubs can be inlined into user methods
And vice versa - user code inlined into stubs?
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.
It could be done. At the moment to doc describes control flow from stub to user code using a call instruction that needs to be located. As long as every method in the inlining tree has debug data to annotate 'stub' or 'not stub' + the corresponding native code ranges and parent methods then the debugger should be able model the right stepping behavior even when there is no call instruction.
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
Adds a CoreCLR design document proposing “stub target debug data” as a declarative mechanism to simplify debugger stepping through runtime stubs, aiming to reduce per-stub bespoke prediction logic in StubManager implementations.
Changes:
- Introduces a draft design describing stub target callsite annotation and a proposed compact debug-info chunk (
StubDebugInfo). - Surveys existing stub generation mechanisms and current
StubManagerimplementations, and outlines feasibility by stub type. - Documents a proposed IL-offset-to-native-offset resolution approach during debug info compression.
|
|
||
| When serializing debug info, the IL offsets recorded by stub generators must be resolved to the native call-instruction offsets already emitted by the JIT. | ||
|
|
||
| **Proposed resolution point:** `CompressDebugInfo::Compress` in [src/coreclr/vm/debuginfostore.cpp](src/coreclr/vm/debuginfostore.cpp). |
Copilot
AI
Feb 10, 2026
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.
The markdown link to debuginfostore.cpp is relative to this document’s directory, so it currently points to a non-existent path (it would resolve under docs/design/coreclr/...). Use a repo-root absolute link (e.g. /src/...) or fix the relative path so it resolves correctly on GitHub.
| **Proposed resolution point:** `CompressDebugInfo::Compress` in [src/coreclr/vm/debuginfostore.cpp](src/coreclr/vm/debuginfostore.cpp). | |
| **Proposed resolution point:** `CompressDebugInfo::Compress` in [src/coreclr/vm/debuginfostore.cpp](/src/coreclr/vm/debuginfostore.cpp). |
| - [Virtual Stub Dispatch Design](../botr/virtual-stub-dispatch.md) | ||
| - [Book of the Runtime (BOTR)](../botr/README.md) |
Copilot
AI
Feb 10, 2026
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.
The BOTR reference links use ../botr/..., but this document already lives under docs/design/coreclr/, so the BOTR folder is ./botr/ (or botr/). As written, these links likely won’t resolve.
| - [Virtual Stub Dispatch Design](../botr/virtual-stub-dispatch.md) | |
| - [Book of the Runtime (BOTR)](../botr/README.md) | |
| - [Virtual Stub Dispatch Design](botr/virtual-stub-dispatch.md) | |
| - [Book of the Runtime (BOTR)](botr/README.md) |
| | Stub Type | Generation | Manager | Call Pattern | Feasibility | | ||
| |-----------|-----------|---------|--------------|-------------| | ||
| | PreStub | Assembly | ThePreStubManager | Call to init | Moderate | | ||
| | Precode | Assembly | PrecodeStubManager | Jump to target | High | | ||
| | Delegate Invoke | StubLinker | StubLinkStubManager | Call to target | High | |
Copilot
AI
Feb 10, 2026
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.
Appendix B’s table uses double leading/trailing pipe markers (|| ... ||), which doesn’t render as a standard Markdown table in most viewers. Switch to the conventional single-pipe table syntax so the summary displays correctly.
| At a high level, the stub stepping flow becomes: | ||
| 1. At stub code generation time extra debug data is produced and stored in a similar manner as our existing method debug data. | ||
| 2. At debugging time the stepping code encounters an IP that might belong to one of these stubs. | ||
| 3. The new StubManager looks up the debug data corresponding that IP. The StubManager claims the stub if the appropriate debug data exists and the debug data indicates the IP is inside the range of a stub. For non-inlined cases the range is the whole method. |
Copilot
AI
Feb 10, 2026
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.
Grammar: “corresponding that IP” should be “corresponding to that IP” (or similar).
| 3. The new StubManager looks up the debug data corresponding that IP. The StubManager claims the stub if the appropriate debug data exists and the debug data indicates the IP is inside the range of a stub. For non-inlined cases the range is the whole method. | |
| 3. The new StubManager looks up the debug data corresponding to that IP. The StubManager claims the stub if the appropriate debug data exists and the debug data indicates the IP is inside the range of a stub. For non-inlined cases the range is the whole method. |
|
|
||
| This document proposes a rough design for adding debug data to runtime stubs, with an initial focus on stubs compiled from IL. The goal is to enable a simplified stub stepping mechanism in the debugger, reducing complexity and maintenance burden of the current bespoke StubManager prediction logic, while supporting future inlining scenarios where stubs can be inlined into user methods or other stubs. | ||
|
|
||
| This is an incomplete sketch I drafted quickly with copilot. Nothing here has been implemented in the runtime. I wanted to save the work-in-progress assuming that it will be useful to resume at some point, but it isn't urgent to implement right now and doing a good job on the design needs additional time. Folks are welcome to comment on the PR with suggestions but I'm not planning to spend much time revising the doc further for now. Instead what I'd like to do is check it in as-is with the expectation that anyone who resumes this work in the future should review the PR comments before moving forward with it. |
Copilot
AI
Feb 10, 2026
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.
Product name capitalization: “copilot” should be “Copilot”.
| This is an incomplete sketch I drafted quickly with copilot. Nothing here has been implemented in the runtime. I wanted to save the work-in-progress assuming that it will be useful to resume at some point, but it isn't urgent to implement right now and doing a good job on the design needs additional time. Folks are welcome to comment on the PR with suggestions but I'm not planning to spend much time revising the doc further for now. Instead what I'd like to do is check it in as-is with the expectation that anyone who resumes this work in the future should review the PR comments before moving forward with it. | |
| This is an incomplete sketch I drafted quickly with Copilot. Nothing here has been implemented in the runtime. I wanted to save the work-in-progress assuming that it will be useful to resume at some point, but it isn't urgent to implement right now and doing a good job on the design needs additional time. Folks are welcome to comment on the PR with suggestions but I'm not planning to spend much time revising the doc further for now. Instead what I'd like to do is check it in as-is with the expectation that anyone who resumes this work in the future should review the PR comments before moving forward with it. |
FWIW, I do not think we have any uncommitted draft designs like this checked in into main. They typically live as an issue or draft PR. Earlier example: #97084 |
If you think this type of half-baked doc creates too much noise in our docs (lets say a trend of such docs, not just one in isolation) I'd also be fine closing the PR and letting the PR be the record. |
|
I'll just close it. |
Description
Proposes declarative debug data for stubs to simplify debugger stepping. Current approach requires each StubManager to implement bespoke prediction logic that must understand stub internals and can fail in restricted contexts (locks, GC no-trigger regions).
Changes
Design document at
docs/design/coreclr/stub-target-debug-data-design.mdProposed solution: Store instruction offset of branch/call to target
Stubclass for StubLinker stubs, leverage JIT debug info for ILStubsOpen questions (13 total):
Example of proposed Stub class extension:
Ready for team review and feedback before prototype implementation.
Original prompt
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.