Skip to content

Conversation

jakobbotsch
Copy link
Member

@jakobbotsch jakobbotsch commented Oct 1, 2025

  • Add new JIT-EE API to report back debug information about the generated state machine and continuations
  • Refactor debug info storage on VM side to be more easily extensible. The new format has either a thin or fat header. The fat header is used when we have either uninstrumented bounds, patchpoint info, rich debug info or async debug info, and stores the blob sizes of all of those components in addition to the bounds and vars. It is indicated by the first field (size of bounds) having value 0, which is an uncommon value for this field.
  • Add new async debug information to the storage on the VM side
  • Set target method desc for async resumption stubs, to be used for mapping from continuations back to the async IL function that it will resume.
  • Implement new format in R2R as well, bump R2R major version (might as well do this now as we expect to need to store async debug info in R2R during .NET 11 anyway)

- Add new JIT-EE API to report back debug information about the
  generated state machine and continuations
- Refactor debug info storage on VM side to be more easily extensible.
  The new format has either a thin or fat header. The fat header is used
  when we have either uninstrumented bounds, patchpoint info, rich debug
  info or async debug info, and stores the blob sizes of all of those
  components in addition to the bounds and vars.
- Add new async debug information to the storage on the VM side
- Set get target method desc for async resumption stubs, to be used for
  mapping from continuations back to the async IL function that it will
  resume.
@github-actions github-actions bot added the area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI label Oct 1, 2025
@jakobbotsch jakobbotsch changed the title Add debug information for runtime async information Add debug information for runtime async methods Oct 1, 2025
Copy link
Contributor

Tagging subscribers to this area: @JulieLeeMSFT, @jakobbotsch
See info in area-owners.md if you want to be subscribed.

Comment on lines +439 to +440
// Offset in continuation's data where this variable is stored
uint32_t Offset;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We probably need to include GCData offset here too, but I expect that we will end up with customized continuation layouts during .NET 11 that gets rid of the Data/GCData split, so I designed some of these types around that expectation. It also should be possible to derive the GCData offset by iterating the vars linearly, so we can probably make do with that for now.

CONTRACTL
{
NOTHROW;
THROWS;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

RestorePatchpointInfo is called from JitPatchpointWorker, which has STANDARD_VM_CONTRACT. I think throwing should be ok, since we only throw here on an internal inconsistency in the compressed data when encountered by NibbleReader. That's consistent with the other Restore routines and saves us having to write separate decoding routines for the patchpoint info.

};

#define DebugInfoBoundsHasInstrumentedBounds 0xFFFFFFFF
#define DebugInfoFat 0
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Switched this to 0 since encoding 0xFFFFFFFF takes up a full 6 bytes, and the value 0 is not a common value for cbBounds (JIT never reports empty bounds over all 1+ million methods in our SPMI collections, I suspect we always have at minimum a prolog bound)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Although I am somewhat worried it is possible to see this from the R2R path. I wonder if we should update R2R major version and teach crossgen2 to produce the fat header if necessary. We'll probably need to encode the debug info in R2R anyway during .NET 11, so I guess we might as well take that update now.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@davidwrighton Any thoughts on this?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updating the R2R major version, and such is the thing to do.

Comment on lines +6548 to +6555
CompressDebugInfo::RestoreRichDebugInfo(
fpNew, pNewData,
pDebugInfo,
ppInlineTree, pNumInlineTree,
ppRichMappings, pNumRichMappings);

return TRUE;
}
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I figured I might as well hook this one up in ReadyToRunJitManager too since the format now technically allows for R2R images that contain the rich debug info, eeven if crossgen2 doesn't produce it.

---
mode: 'agent'
tools: ['githubRepo', 'codebase', 'terminalLastCommand']
tools: ['fetch', 'codebase', 'runCommands', 'usages', 'search', 'think']
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updating these tools based on @EgorBo's instructions (I used the prompt to add the JIT-EE boilerplate, but the agent was not making the changes automatically without allowing it access to these tools)

uint32_t ILOffset;
// Count of AsyncContinuationVarInfo in array of locals starting where
// the previous suspension point's locals end.
uint32_t NumContinuationVars;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just curious, do we expect it will be common that variables stay homed in the same place across multiple suspension points or they are likely to adjust every time? If I understand correctly this current format is reporting a new AsyncContinuationVarInfo for each suspension point where the variable is live.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI runtime-async
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants