sweetpad-dev / sweetpad

Develop Swift/iOS projects using VSCode
https://marketplace.visualstudio.com/items?itemName=sweetpad.sweetpad
MIT License
619 stars 20 forks source link

Debugging with lldb-dap #63

Closed kaishin closed 2 weeks ago

kaishin commented 1 month ago

I have the Use Debug Adapter From Toolchain config option turned on for the Swift extension, which uses lldb-dap. My attempts to debug with Sweetpad have all failed as the debug session never starts.

Is this a known limitation? I haven't found any references to it in issues or the roadmap.

hyzyla commented 3 weeks ago

Unfortunately, in most aspects, how debugging works in VSCode is still a bit of a mystery to me. In my extension, I rely heavily on codelldb, simply passing parameters through to the lldb debugger:

  async resolveDebugConfigurationWithSubstitutedVariables(
    folder: vscode.WorkspaceFolder | undefined,
    config: vscode.DebugConfiguration,
    token?: vscode.CancellationToken | undefined,
  ): Promise<vscode.DebugConfiguration> {
    config.type = "lldb";
    config.waitFor = true;
    config.request = "attach";

    if (!config.program) {
      const appPath = this.context.getWorkspaceState("build.lastLaunchedAppPath");
      if (!appPath) {
        throw new Error("No last launched app path found, please launch the app first using the extension");
      }
      config.program = appPath;
    }

Could you provide more details to help me reproduce the problem? Specifically, I’m interested in knowing which extensions related to LLDB or Swift you have installed, what your launch.json file looks like, and any special settings related to debugging or Swift in your settings.json file. Any details could be helpfull

kaishin commented 2 weeks ago

Could you provide more details to help me reproduce the problem? Specifically, I’m interested in knowing which extensions related to LLDB or Swift you have installed, what your launch.json file looks like, and any special settings related to debugging or Swift in your settings.json file. Any details could be helpfull

I only have the official swift extension and CodeLLDB v1.11.1 installed. I also have swift.debugger.useDebugAdapterFromToolchain set to on.

After further testing I conclude that the flakiness isn't tied to lldb-dap at all. Perhaps I was missing some step when rebuilding/re-attaching, but I am unable to reproduce the issue on a brand new test project.