GUI debugger for Swift on Windows?

Hello Everyone,

Is anyone able to accomplish debugging of Swift on Windows 10 with a GUI debugger?
If so, please advise on which tools and versions you are using.

I was hoping to use VS Code, but would be open to other GUI debuggers. Besides looking for a solution, I am also trying to discover whether my lack of success is due to my setup, or if this is a widespread issue that is just not solved yet.

My own not very successful attempts have been with:

  • Swift 5.6.2
    • also 5.6.1 and 5.7-dev
  • using the DWARF format debug info
  • VS Code 1.67.1
  • VS Code extension: Swift 0.6.0
  • VS Code extension: CodeLLDB 1.7.3

Thanks so much for describing your solution.

My Results

With this line in settings.json:
"lldb.library": "C:\Library\Developer\Toolchains\unknown-Asserts-development.xctoolchain\usr\bin\liblldb.dll"
(use the custom LLDB packaged with Swift): in VS Code I can display Swift variables (by hovering), but print() output to stdout does not appear in a new cmd prompt window evidently created for that purpose, and readLine() returns nil because stdin is closed before program execution starts.

If I remove the lldb.library setting (use the LLDB that came packaged with CodeLLDB) then:
in VS Code I am unable to display Swift variables, but print() output to stdout is visible in VS Code's Terminal pane, and readLine() does retrieve text entered into the Terminal pane.

If I switch from VS Code to running the custom LLDB from the Command Prompt (thus abandoning my GUI debugger), then all is well: I can display Swift variables (e.g. via the 'var' command), AND print() output to stdout DOES appear in a new cmd prompt window created for that purpose, and readLine() DOES retrieve text entered into that new window.

If you are curious, a number of investigations and variations are documented here:
Issue #309 On Windows 10, at launch of LLDB, program is unable to access stdout or stdin · Issue #309 · swift-server/vscode-swift · GitHub
with help from @compnerd and @adam-fowler. And a test program is at the top, under 'Test Case'.

Also, @compnerd has said he uses PDB format debug info with WinDbg, but that variable display is not up to par there.

1 Like

It's been 3 months with no replies - perhaps I should restate the question - has anyone having a satisfactory GUI debugger experience with Swift on Windows? Or is the most common solution to use LLDB directly?

Thanks for any suggestions or discussion!

Also please note: I changed my username to langlover.

maybe late. but it works for me atm.

@VolodymyrBoichentsov Glad to hear it! And where are the stdout (print()) and stdin (readline()) appearing for you? Did invoking the debugger from VS Code cause a new command prompt window to appear, and that is where program stdout/stdin appear?

and just to verify, do you have the Swift custom library enabled, via this line in settings.json:
"lldb.library": "C:\Library\Developer\Toolchains\unknown-Asserts-development.xctoolchain\usr\bin\liblldb.dll"

also note that I just added an update for a tolerable workaround to my issue in Issue #309 On Windows 10, at launch of LLDB, program is unable to access stdout or stdin · swift-server/vscode-swift · GitHub.

It just works out of the box for me. I use regular p/print and it prints results. Even functions can be evaluated and it would print result.
One note tho, I have windows 11 and swift 5.9 installed via first approach, winget command.