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.