https://github.com/matthewbastien updated https://github.com/llvm/llvm-project/pull/129262
>From 8926756d800b9ecd171b6d645a459b01342e9458 Mon Sep 17 00:00:00 2001 From: Matthew Bastien <matthew_bast...@apple.com> Date: Fri, 28 Feb 2025 11:08:25 -0500 Subject: [PATCH 1/2] allow providing debug adapter arguments --- lldb/tools/lldb-dap/package.json | 23 +++++++++ .../lldb-dap/src-ts/debug-adapter-factory.ts | 48 +++++++++++-------- 2 files changed, 50 insertions(+), 21 deletions(-) diff --git a/lldb/tools/lldb-dap/package.json b/lldb/tools/lldb-dap/package.json index 31d808eda4c35..0859b6e388a4e 100644 --- a/lldb/tools/lldb-dap/package.json +++ b/lldb/tools/lldb-dap/package.json @@ -75,6 +75,15 @@ "type": "string", "description": "The path to the lldb-dap binary." }, + "lldb-dap.arguments": { + "scope": "resource", + "type": "array", + "default": [], + "items": { + "type": "string" + }, + "description": "The arguments provided to the lldb-dap process." + }, "lldb-dap.log-path": { "scope": "resource", "type": "string", @@ -156,6 +165,13 @@ "type": "string", "markdownDescription": "The absolute path to the LLDB debug adapter executable to use." }, + "debugAdapterArgs": { + "type": "array", + "items": { + "type": "string" + }, + "markdownDescription": "The list of arguments used to launch the debug adapter executable." + }, "program": { "type": "string", "description": "Path to the program to debug." @@ -346,6 +362,13 @@ "type": "string", "markdownDescription": "The absolute path to the LLDB debug adapter executable to use." }, + "debugAdapterArgs": { + "type": "array", + "items": { + "type": "string" + }, + "markdownDescription": "The list of arguments used to launch the debug adapter executable." + }, "program": { "type": "string", "description": "Path to the program to attach to." 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 36107336ebc4d..ea7b4ce97ac1d 100644 --- a/lldb/tools/lldb-dap/src-ts/debug-adapter-factory.ts +++ b/lldb/tools/lldb-dap/src-ts/debug-adapter-factory.ts @@ -92,6 +92,21 @@ async function getDAPExecutable( return undefined; } +function getDAPArguments(session: vscode.DebugSession): string[] { + // Check the debug configuration for arguments first + const debugConfigArgs = session.configuration.debugAdapterArgs; + if ( + Array.isArray(debugConfigArgs) && + debugConfigArgs.findIndex((entry) => typeof entry !== "string") === -1 + ) { + return debugConfigArgs; + } + // Fall back on the workspace configuration + return vscode.workspace + .getConfiguration("lldb-dap") + .get<string[]>("arguments", []); +} + /** * This class defines a factory used to find the lldb-dap binary to use * depending on the session configuration. @@ -101,7 +116,7 @@ export class LLDBDapDescriptorFactory { async createDebugAdapterDescriptor( session: vscode.DebugSession, - executable: vscode.DebugAdapterExecutable | undefined, + _executable: vscode.DebugAdapterExecutable | undefined, ): Promise<vscode.DebugAdapterDescriptor | undefined> { const config = vscode.workspace.getConfiguration( "lldb-dap", @@ -116,40 +131,31 @@ export class LLDBDapDescriptorFactory const configEnvironment = config.get<{ [key: string]: string }>("environment") || {}; const dapPath = await getDAPExecutable(session); + const dapArgs = getDAPArguments(session); const dbgOptions = { env: { - ...executable?.options?.env, ...configEnvironment, ...env, }, }; - if (dapPath) { - if (!(await isExecutable(dapPath))) { - LLDBDapDescriptorFactory.showLLDBDapNotFoundMessage(dapPath); - return undefined; - } - return new vscode.DebugAdapterExecutable(dapPath, [], dbgOptions); - } else if (executable) { - if (!(await isExecutable(executable.command))) { - LLDBDapDescriptorFactory.showLLDBDapNotFoundMessage(executable.command); - return undefined; - } - return new vscode.DebugAdapterExecutable( - executable.command, - executable.args, - dbgOptions, - ); + if (dapPath === undefined || !(await isExecutable(dapPath))) { + LLDBDapDescriptorFactory.showLLDBDapNotFoundMessage(dapPath); + return undefined; } - return undefined; + return new vscode.DebugAdapterExecutable(dapPath, dapArgs, dbgOptions); } /** * Shows a message box when the debug adapter's path is not found */ - static async showLLDBDapNotFoundMessage(path: string) { + static async showLLDBDapNotFoundMessage(path: string | undefined) { const openSettingsAction = "Open Settings"; + const message = + path === undefined + ? "Unable to find the LLDB debug adapter executable." + : `Debug adapter path: ${path} is not a valid file`; const callbackValue = await vscode.window.showErrorMessage( - `Debug adapter path: ${path} is not a valid file`, + message, openSettingsAction, ); >From 75350dbd95b5f76fa37a425da418616efa23baa5 Mon Sep 17 00:00:00 2001 From: Matthew Bastien <matthew_bast...@apple.com> Date: Fri, 28 Feb 2025 11:22:41 -0500 Subject: [PATCH 2/2] update wording --- lldb/tools/lldb-dap/package.json | 6 +++--- lldb/tools/lldb-dap/src-ts/debug-adapter-factory.ts | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lldb/tools/lldb-dap/package.json b/lldb/tools/lldb-dap/package.json index 0859b6e388a4e..eb00b7b5f00da 100644 --- a/lldb/tools/lldb-dap/package.json +++ b/lldb/tools/lldb-dap/package.json @@ -82,7 +82,7 @@ "items": { "type": "string" }, - "description": "The arguments provided to the lldb-dap process." + "description": "the list of additional arguments used to launch the debug adapter executable." }, "lldb-dap.log-path": { "scope": "resource", @@ -170,7 +170,7 @@ "items": { "type": "string" }, - "markdownDescription": "The list of arguments used to launch the debug adapter executable." + "markdownDescription": "the list of additional arguments used to launch the debug adapter executable." }, "program": { "type": "string", @@ -367,7 +367,7 @@ "items": { "type": "string" }, - "markdownDescription": "The list of arguments used to launch the debug adapter executable." + "markdownDescription": "the list of additional arguments used to launch the debug adapter executable." }, "program": { "type": "string", 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 ea7b4ce97ac1d..5219aa3a27fa5 100644 --- a/lldb/tools/lldb-dap/src-ts/debug-adapter-factory.ts +++ b/lldb/tools/lldb-dap/src-ts/debug-adapter-factory.ts @@ -152,8 +152,8 @@ export class LLDBDapDescriptorFactory const openSettingsAction = "Open Settings"; const message = path === undefined - ? "Unable to find the LLDB debug adapter executable." - : `Debug adapter path: ${path} is not a valid file`; + ? "Unable to find the path to the LLDB debug adapter executable." + : `Debug adapter path: ${path} is not a valid file.`; const callbackValue = await vscode.window.showErrorMessage( message, openSettingsAction, _______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits