Skip to content

Commit 105b3a9

Browse files
[lldb-dap] add debugAdapterExecutable property to launch configuration (llvm#126803)
The Swift extension for VS Code requires that the `lldb-dap` executable come from the Swift toolchain which may or may not be configured in `PATH`. At the moment, this can be configured via LLDB DAP's extension settings, but experience has shown that modifying other extensions' settings on behalf of the user (especially those subject to change whenever a new toolchain is selected) causes issues. Instead, it would be easier to have this configurable in the launch configuration and let the Swift extension (or any other extension that wanted to, really) configure the path to `lldb-dap` that way. This allows the Swift extension to have its own launch configuration type that delegates to the LLDB DAP extension in order to provide a more seamless debugging experience for Swift executables. This PR adds a new property to the launch configuration object called `debugAdapterExecutable` which allows overriding the `lldb-dap` executable path for a specific debug session.
1 parent bcba311 commit 105b3a9

File tree

2 files changed

+16
-3
lines changed

2 files changed

+16
-3
lines changed

lldb/tools/lldb-dap/package.json

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@
8686
"default": {},
8787
"description": "The environment of the lldb-dap process.",
8888
"additionalProperties": {
89-
"type": "string"
89+
"type": "string"
9090
}
9191
}
9292
}
@@ -152,6 +152,10 @@
152152
"program"
153153
],
154154
"properties": {
155+
"debugAdapterExecutable": {
156+
"type": "string",
157+
"markdownDescription": "The absolute path to the LLDB debug adapter executable to use."
158+
},
155159
"program": {
156160
"type": "string",
157161
"description": "Path to the program to debug."
@@ -338,6 +342,10 @@
338342
},
339343
"attach": {
340344
"properties": {
345+
"debugAdapterExecutable": {
346+
"type": "string",
347+
"markdownDescription": "The absolute path to the LLDB debug adapter executable to use."
348+
},
341349
"program": {
342350
"type": "string",
343351
"description": "Path to the program to attach to."

lldb/tools/lldb-dap/src-ts/debug-adapter-factory.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,12 +67,17 @@ async function findDAPExecutable(): Promise<string | undefined> {
6767
async function getDAPExecutable(
6868
session: vscode.DebugSession,
6969
): Promise<string | undefined> {
70+
// Check if the executable was provided in the launch configuration.
71+
const launchConfigPath = session.configuration["debugAdapterExecutable"];
72+
if (typeof launchConfigPath === "string" && launchConfigPath.length !== 0) {
73+
return launchConfigPath;
74+
}
75+
76+
// Check if the executable was provided in the extension's configuration.
7077
const config = vscode.workspace.getConfiguration(
7178
"lldb-dap",
7279
session.workspaceFolder,
7380
);
74-
75-
// Prefer the explicitly specified path in the extension's configuration.
7681
const configPath = config.get<string>("executable-path");
7782
if (configPath && configPath.length !== 0) {
7883
return configPath;

0 commit comments

Comments
 (0)