Unable to debug on Windows

Environment
Visual Studio Code: 1.82.2
Swift: v1.5.2
CodeLLDB: v1.10.0
Swift Toolchain: swift-5.9-RELEASE
Windows 10 22h2

Steps:

  1. Create folder
  2. Run swift package init --type=executable
  3. Open folder in VS Code
  4. Set breakpoint on print statement
  5. Press F5

Result:
Debug session has started. Console is in 'commands' mode, prefix expressions with '?'. message in Debug Console. The program does not run. It seems like nothing happens.

LLDB output:

Initial debug configuration: {
  type: 'lldb',
  request: 'launch',
  sourceLanguages: [ 'swift' ],
  name: 'Debug Demo',
  program: '${workspaceFolder:Demo}\\.build/debug/Demo',
  args: [],
  cwd: '${workspaceFolder:Demo}',
  preLaunchTask: 'swift: Build Debug Demo',
  __configurationTarget: 6
}
Resolved debug configuration: {
  type: 'lldb',
  request: 'launch',
  sourceLanguages: [ 'swift' ],
  name: 'Debug Demo',
  program: '${workspaceFolder:Demo}\\.build/debug/Demo',
  args: [],
  cwd: '${workspaceFolder:Demo}',
  preLaunchTask: 'swift: Build Debug Demo',
  __configurationTarget: 6,
  relativePathBase: 'g:\\Projects\\Demo',
  _adapterSettings: {
    displayFormat: 'auto',
    showDisassembly: 'auto',
    dereferencePointers: true,
    suppressMissingSourceFiles: true,
    evaluationTimeout: 5,
    consoleMode: 'commands',
    sourceLanguages: null,
    terminalPromptClear: null,
    evaluateForHovers: true,
    commandCompletions: true,
    reproducer: false
  }
}

I am maybe not the right person to help you, but I would suggest you check if the Python version (which is needed for debugging) is the exact version as documented in the installation guide.

It's Python 3.10.11 as in the Installation Guide.

Can you get the full log for the DAP? I would suggest that you first try running lldb from the console and see if that works. Once we know that it works, we know that this is limited to VSCode rather than debugging in general.

What is DAP? When I tried to run lldb from a console I got error about python39.dll not found on the system.

Update: downgrading Python to 3.9 solved the problem. Maybe Installation Guide should be corrected?

DAP is the debugger adapter protocol (the debugger equivalent to the LSP).

Updating the website sounds like the right thing; could you open a PR against apple/swift-org-website for that?

PR: Update _winget.md by HeMet · Pull Request #417 · apple/swift-org-website · GitHub

1 Like

This turned out to be far from enough. The Python dependency was such a mess (and is still now) that even a newer patch release can have an older Python requirement.

I've ended up scanning all the releases and set up a "knowledge base" for people to know what's in different Windows toolchains, and LLDB dependency becomes the first topic. Welcome to the Swift Windows Toolchain Analysis repository!

As a response to the investigation result, I've sent a series of PRs to update all existing WinGet manifests. After they're merged, I'd like to revise the installation guide, remove explicit dependency installation steps for WinGet and add notice about the situation for other installation methods.

1 Like