Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hide underlying debug adapter from the user #1024

Merged
merged 13 commits into from
Sep 13, 2024

Conversation

matthewbastien
Copy link
Member

@matthewbastien matthewbastien commented Aug 22, 2024

Users should not have to know which debug adapter is being used (CodeLLDB vs lldb-dap). The Swift extension will now always create a swift-lldb launch config for each executable that it finds in the workspace. When launched these configurations will either delegate to CodeLLDB or launch lldb-dap depending on which Swift toolchain version is currently being used. I've added a setting to force the usage of CodeLLDB when desired.

Issue: #1013

Additionally, the program path in the launch configuration will always use POSIX style paths regardless of the platform. This allows the launch.json to be shared between users of different platforms.

Issue: #958

@adam-fowler
Copy link
Contributor

Does this still give the user the option to use CodeLLDB when running Swift 6.
What are the test plans for lldb-dap vs CodeLLDB?

@matthewbastien
Copy link
Member Author

Does this still give the user the option to use CodeLLDB when running Swift 6.

Yup! I renamed the old setting that governed this to swift.debugger.useCodeLLDB which, when enabled, will force the extension to always use CodeLLDB regardless of the Swift toolchain version. The behaviour is largely the same as it used to be, but the generated launch config will always be of the type swift-lldb. This has the added benefit that we no longer need to watch for settings changes to update the generated launch configs.

What are the test plans for lldb-dap vs CodeLLDB?

Thanks for reminding me: I'll create a new issue to add tests for the debug adapter. A simple UI test to ensure that the debugger launches and hits breakpoints for each supported swift version should suffice (I'm not sure there's a good integration test for this and anything more than a simple UI test would be overkill and brittle in my experience). I'd also like to add unit tests for the creation of the launch config, but mocking the WorkspaceContext/FolderContext is too difficult at the moment. There'll probably need to be some changes to how the code is structured (potentially by adding DI) to make this easier. The overall testing plan for the extension right now is to add builds for macOS and Windows to cover all platforms.

@award999
Copy link
Contributor

I'm not sure there's a good integration test for this and anything more than a simple UI test would be overkill and brittle in my experience

https://www.npmjs.com/package/@vscode/debugadapter-testsupport may be an option if we connected on a port instead of starting it up https://github.com/microsoft/vscode-debugadapter-node/blob/main/testSupport/src/debugClient.ts#L88. IDK how feasible though

Copy link
Contributor

@award999 award999 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looking great

return swiftVersion.isLessThan(new Version(6, 0, 0)) ? "lldb-vscode" : "lldb-dap";
public static getDebugAdapterType(swiftVersion: Version): "lldb-vscode" | "lldb-dap" {
return configuration.debugger.useCodeLLDB
? "lldb-vscode"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

question: does CodeLLDB even allow specifying a debug adapter?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion: assuming it is to make other code work below then maybe we should just adjust that logic

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, CodeLLDB does not allow specifying a debug adapter. This is used in other places to determine which debug adapter we're using.

package.json Outdated
@@ -1276,4 +1276,4 @@
"vscode-languageclient": "^9.0.1",
"xml2js": "^0.6.2"
}
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: each PR keeps changing this. Think there is an NPMRC setting to set consistent line ending

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will create a separate pull request to enforce this behaviour.

@plemarquand
Copy link
Contributor

@swift-server-bot test this please

@matthewbastien
Copy link
Member Author

I've reverted back to using CodeLLDB by default for this patch until we can verify that lldb-dap has feature parity with CodeLLDB.

@matthewbastien matthewbastien merged commit 335739b into swiftlang:main Sep 13, 2024
8 checks passed
@matthewbastien matthewbastien deleted the swift-lldb branch September 25, 2024 18:35
plemarquand added a commit to plemarquand/vscode-swift that referenced this pull request Sep 26, 2024
The CodeLLDB extension expects the debug adapter to be called `lldb`. If
we are using it and we don't call `registerDebugAdapterTrackerFactory`
with `lldb` as the adapter name then we fail to get logs in the
debugSessionCallback when running tests. This prevents XCTests results
from being parsed, and hides the swift-testing outout.

Revert a portion of swiftlang#1024 that always set the debug adapter name to
`swift-lldb` and use `lldb` when we're using CodeLLDB as the debug
adapter.

Issue swiftlang#1100
plemarquand added a commit that referenced this pull request Sep 26, 2024
The CodeLLDB extension expects the debug adapter to be called `lldb`. If
we are using it and we don't call `registerDebugAdapterTrackerFactory`
with `lldb` as the adapter name then we fail to get logs in the
debugSessionCallback when running tests. This prevents XCTests results
from being parsed, and hides the swift-testing outout.

Revert a portion of #1024 that always set the debug adapter name to
`swift-lldb` and use `lldb` when we're using CodeLLDB as the debug
adapter.

Issue #1100
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants