https://github.com/matthewbastien created 
https://github.com/llvm/llvm-project/pull/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.

>From 830a56acf776046d65dada631b54c74ed2aa5f87 Mon Sep 17 00:00:00 2001
From: Matthew Bastien <matthew_bast...@apple.com>
Date: Tue, 11 Feb 2025 16:38:43 -0500
Subject: [PATCH] add `debugAdapterExecutable` property to launch configuration

---
 lldb/tools/lldb-dap/package.json                    | 6 +++++-
 lldb/tools/lldb-dap/src-ts/debug-adapter-factory.ts | 9 +++++++--
 2 files changed, 12 insertions(+), 3 deletions(-)

diff --git a/lldb/tools/lldb-dap/package.json b/lldb/tools/lldb-dap/package.json
index e866af0602d70..fb4a828795041 100644
--- a/lldb/tools/lldb-dap/package.json
+++ b/lldb/tools/lldb-dap/package.json
@@ -86,7 +86,7 @@
           "default": {},
           "description": "The environment of the lldb-dap process.",
           "additionalProperties": {
-             "type": "string"
+            "type": "string"
           }
         }
       }
@@ -152,6 +152,10 @@
               "program"
             ],
             "properties": {
+              "debugAdapterExecutable": {
+                "type": "string",
+                "markdownDescription": "The LLDB debug adapter executable to 
use. Either an absolute path or the name of a debug adapter executable 
available on the `PATH`."
+              },
               "program": {
                 "type": "string",
                 "description": "Path to the program to debug."
diff --git a/lldb/tools/lldb-dap/src-ts/debug-adapter-factory.ts 
b/lldb/tools/lldb-dap/src-ts/debug-adapter-factory.ts
index 55c2f3e9f7deb..e1c6bd4fd4300 100644
--- a/lldb/tools/lldb-dap/src-ts/debug-adapter-factory.ts
+++ b/lldb/tools/lldb-dap/src-ts/debug-adapter-factory.ts
@@ -67,12 +67,17 @@ async function findDAPExecutable(): Promise<string | 
undefined> {
 async function getDAPExecutable(
   session: vscode.DebugSession,
 ): Promise<string | undefined> {
+  // Check if the executable was provided in the launch configuration.
+  const launchConfigPath = session.configuration["debugAdapterExecutable"];
+  if (typeof launchConfigPath === "string" && launchConfigPath.length !== 0) {
+    return launchConfigPath;
+  }
+
+  // Check if the executable was provided in the extension's configuration.
   const config = vscode.workspace.getConfiguration(
     "lldb-dap",
     session.workspaceFolder,
   );
-
-  // Prefer the explicitly specified path in the extension's configuration.
   const configPath = config.get<string>("executable-path");
   if (configPath && configPath.length !== 0) {
     return configPath;

_______________________________________________
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to