-
-
Notifications
You must be signed in to change notification settings - Fork 285
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
Can Ionide debug fsx scripts? #1309
Comments
Hey @ktodyruik 👋, Thank you for opening an issue. We will get back to you as https://opencollective.com/ionide
|
No, we don't support debugging fsx scripts at the moment |
Do you think we can request support for script debugging? Would it be helpful in the script context and data/python/like context? cc @Krzysztof-Cieslak |
Wouldn't be opposed to taking a PR for this. As a workaround for now you can do something like: open System.Diagnostics
let waitForDebuggerAttached (programName) =
if not (System.Diagnostics.Debugger.IsAttached) then
printfn
"Please attach a debugger for %s, PID: %d"
programName
(System.Diagnostics.Process.GetCurrentProcess().Id)
while not (System.Diagnostics.Debugger.IsAttached) do
System.Threading.Thread.Sleep(100)
let breakPoint () =
Debugger.Break ()
let main () =
printfn "doing something"
waitForDebuggerAttached "playground.fsx"
let foo = "42"
printfn "%A" fsi.CommandLineArgs
breakPoint ()
failwith "fail"
()
main () and having {
"version": "0.2.0",
"configurations": [
{
"name": ".NET Core Attach",
"type": "coreclr",
"request": "attach",
"requireExactSource" : false,
"justMyCode": false
}
]
} |
Alternative - debugging a script in that way introduces new sources, could a |
I think I remember from awhile ago, the issue is the fsx code gets run in another process so I don't think you end up debugging the right thing. |
Oh that's right - {
"version": "0.2.0",
"configurations": [
{
"name": "Launch FSI",
"request": "launch",
"type": "coreclr",
"program": "C:\\Program Files\\dotnet\\sdk\\8.0.100-preview.5.23303.2\\FSharp\\fsi.dll",
"args": ["${workspaceFolder}\\tryMakeTfmHashes.fsx", "--debug+", "--debug:portable", "--optimize-"],
"justMyCode": false
}
]
} We should consider auto-creating this configuration when an FSI file is launched for debugging. There are caveats here though - locals/watches seem to not work at all in this case. I've tried adding debugging flags to make the experience better but I'm not sure I've got the right combination. Locals inside loops/bindings/etc work, but once you're outside of that scope there's just nothing. |
@baronfel tested the last approach it works, but indeed no watch or scope variables during debug!
here was my github codespace config for {
"version": "0.2.0",
"configurations": [
{
"name": "Launch FSI",
"request": "launch",
"type": "coreclr",
"program": "/home/codespace/.dotnet/sdk/7.0.302/FSharp/fsi.dll",
"args": ["${workspaceFolder}/program.fsx", "--debug+", "--debug:portable", "--optimize-"],
"justMyCode": false
}
]
} is there a way to autodetect SDK version also, maybe with a ENV variable like ${workspaceFolder}, something like ${dotnetSdkVersion}, maybe exists... ![]() |
I started a conversation with @vlza on the FSSF slack that had some pointers - private thread link is https://fsharp.slack.com/archives/C04AUG3RBGE/p1689174015344819?thread_ts=1689174015.344819&cid=C04AUG3RBGE for posterity. A couple things to try:
If we can dig into what's going on here and get locals to show up, then Ionide/FSAC could generate the appropriate launch config for the user and we wouldn't need the SDK placeholder variables like @jkone27 was mentioning. |
ah i see dotnet fsi debugging was implemented here - dotnet/fsharp#12722 added C#/dotnet debugger log
in vscode launch.json and I see this msg
|
@jkone27 you should be able to set '--debug:portable' to generate portable symbols for the FSI session. That may also need '--multiemit' (which IIRC is the default) to emit each interaction as a separate assembly... I tried these options a bit locally and still didn't get locals (but I may not have updated my initial comment here) |
with --multiemit got this one instead :) seems related to Saturn lib
|
in my latest test run i cannot debug anymore, cannot open pdb files..
|
Unfortunately I don't think this is related to anything we control. This is probably an issue in fsi or the debugger for vscode itself. |
Possibly relevant: dotnet/fsharp#15820 |
Hi,
This is just a question. Can Ionide debug fsx scripts?
The text was updated successfully, but these errors were encountered: