Problem using Swift on Windows with Visual Studio Code and CodeLLDB

I'm trying to use Swift (swift-5.4-DEVELOPMENT-SNAPSHOT-2021-03-03-a-windows10) with Visual Studio Code, Maintained Swift Development Environment and CodeLLDB. It works fine except for debugger. I created settings.json to point CodeLLDB to the right library.

{
    "lldb.library": "c:\\Library\\Developer\\Toolchains\\unknown-Asserts-development.xctoolchain\\usr\\bin\\liblldb.dll",
    "lldb.verboseLogging": true
}

However, when I try to use debugger I get the error:

liblldb: c:\Library\Developer\Toolchains\unknown-Asserts-development.xctoolchain\usr\bin\liblldb.dll
environment: {}
params: { evaluateForHovers: true, commandCompletions: true }
Error: "Could not load \"c:\\\\Library\\\\Developer\\\\Toolchains\\\\unknown-Asserts-development.xctoolchain\\\\usr\\\\bin\\\\liblldb.dll\" (err=0000007E)"
Error: The debugger exited without completing startup handshake.

Any advice on using LLDB to debug Swift on Windows?

Error code = 0x7e. That is Windows error 126, ERROR_MOD_NOT_FOUND. I suspect that this is the result of VSCode or CodeLLDB not setting up the environment properly.

FWIW, I've previously heard of issues with CodeLLDB and a custom LLDB (which is required for debugging Swift code) with random crashes.

My usage of it has been limited to directly using lldb to debug via the console. Given what I've previous heard about CodeLLDB, my thoughts would be that you may need to consider debugging CodeLLDB itself.

1 Like

I was able to find the cause. It was missing Python 3.7. Now I have another error

[2021-03-07T15:21:33Z DEBUG codelldb] New debug session
Fatal Python error: initfsencoding: unable to load the file system codec
ModuleNotFoundError: No module named 'encodings'

I set PYTHONHOME and PYTHONPATH environment variables and that fixed the issue when using Python from terminal, but it does not affect CodeLLDB it seems.

I found that I have several lldb libs, i think in settings had beed set path to wrong lib. I updated to "c:\Users\\.vscode\extensions\vadimcn.vscode-lldb-1.9.2\lldb\bin\liblldb.dll" and it had worked for me