Skip to content

Instantly share code, notes, and snippets.

@dsyme
Last active February 16, 2022 16:56
Show Gist options
  • Save dsyme/ddf12829299f9a0d2c0bd5b6bacd7c14 to your computer and use it in GitHub Desktop.
Save dsyme/ddf12829299f9a0d2c0bd5b6bacd7c14 to your computer and use it in GitHub Desktop.

Some notes on debug stuff

Notes for Kathleen and Vlad.

Two techniques to fix things like 11262

1. Hack the generated IL

e.g. we want y in scope when stopped at x + 1:

let f (x, y) = 
    data |> List.map (fun x -> 
        let (* IL local *) y = y // Hack the IL
        x + 1)

We already do this for the this pointer:

type C() = 
    member x.M() = 
        let (* IL local *) x = this  // Hack the generated IL: Hidden debug codegen (done today) 
        x.ToString()

2. Do it "properly"

Doing it "properly" might mean having extra PDB tables, e.g. to record the name of the this pointer, and having an F#-specific debug engine (or make a mod to the C#/VB engine) know about this data:

type C() = 
    member x.M() = 
        PDB: ARGUMENT SCOPE TABLE: THIS POINTER  --> "x" //Proper:  PDB gen + debug engine  
        x.ToString()    <---  debug engine knows what to do 

Possible sequencing of work to develop capabilities towards a debug engine

----Don's expertise----

  1. Fix what we can fix by hacking the debug IL and PDB (#11262, #3759?) <--- Don's expertise

----Definitely not Don's expertise----

  1. Co-build Roslyn, install into RoslynDev, learn how to debug into Roslyn from Visual Studio F# tools
  2. Make a fix to Roslyn (#12409, #1003?)
  3. Add a no-op debug engine to Visual Studio F#, e.g. empty inherit from C# Roslyn one // VisualFSharpFull.vsix
  4. Experiment with a tiny functionality mod to debug engine
  5. Start to fill out engine capabilities
    • Implement an expression evaluator for some F#-specific case Maybe by translating F# to C# and reusing C# expression evaluator

    • Implement F#-specific binder (unclear what this would fix though) e.g. add a debug table to PDB and use it in F# expression evaluator

    • Implement F#-specific logic for stepping (e.g. for computation expressions)

    • e.g. add a stepping table to indicate where a step-over should be a step-into

    • Implement Autos window (#4271)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment