Skip to content

Emit StateMachineMethod and StateMachineHoistedLocalScopes into portable PDB format #12000

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

Open
4 tasks
Tracked by #12812
dsyme opened this issue Aug 20, 2021 · 1 comment
Open
4 tasks
Tracked by #12812
Labels
Area-Debug stepping, debug points, stacks and more Feature Improvement
Milestone

Comments

@dsyme
Copy link
Contributor

dsyme commented Aug 20, 2021

Roslyn has a capability to emit special debug information for C#/VB async methods.

F# doesn't emit this information. This means we must, in some way, be missing out on a debug capability supported by .NET debugging.

  • clarify the user-facing experience this supports and verify it is not supported by F#
  • collect the information in the compiler as we generate resumable code
  • implement the code to emit this information
  • see if it is useful beyond F# tasks.

Portable PDB spec is here: https://github.com/dotnet/runtime/blob/main/docs/design/specs/PortablePdb-Metadata.md

Also aplies to "StateMachine Local Scopes"
https://github.com/dotnet/roslyn/blob/3d8acbd585a75e9cdb3509623bf6c39ceb46b2c2/src/Compilers/Core/Portable/PEWriter/MetadataWriter.PortablePdb.cs

Here's an example of what they emit: https://github.com/dotnet/roslyn/blob/3d8acbd585a75e9cdb3509623bf6c39ceb46b2c2/src/Compilers/Core/Portable/PEWriter/MetadataWriter.PortablePdb.cs

       private void SerializeAsyncMethodSteppingInfo(AsyncMoveNextBodyDebugInfo asyncInfo, MethodDefinitionHandle moveNextMethod, int aggregateMethodDefRid)
        {
            Debug.Assert(asyncInfo.ResumeOffsets.Length == asyncInfo.YieldOffsets.Length);
            Debug.Assert(asyncInfo.CatchHandlerOffset >= -1);

            var writer = new BlobBuilder();

            writer.WriteUInt32((uint)((long)asyncInfo.CatchHandlerOffset + 1));

            for (int i = 0; i < asyncInfo.ResumeOffsets.Length; i++)
            {
                writer.WriteUInt32((uint)asyncInfo.YieldOffsets[i]);
                writer.WriteUInt32((uint)asyncInfo.ResumeOffsets[i]);
                writer.WriteCompressedInteger(aggregateMethodDefRid);
            }

            _debugMetadataOpt.AddCustomDebugInformation(
                parent: moveNextMethod,
                kind: _debugMetadataOpt.GetOrAddGuid(PortableCustomDebugInfoKinds.AsyncMethodSteppingInformationBlob),
                value: _debugMetadataOpt.GetOrAddBlob(writer));
        }
@dsyme dsyme added the Area-Debug stepping, debug points, stacks and more label Aug 20, 2021
@dsyme dsyme changed the title Emit async debug info into portable PDB format Emit StateMachineMethod and StateMachineHoistedLocalScopes into portable PDB format Aug 23, 2021
@dsyme
Copy link
Contributor Author

dsyme commented Aug 23, 2021

My understanding is that, among other things, this means there will not be a false double-stepping point when moving into a function that returns task { ... } , becaus it makes the debugging step directly into the MoveNext

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-Debug stepping, debug points, stacks and more Feature Improvement
Projects
Status: New
Development

No branches or pull requests

2 participants