[Lldb-commits] [lldb] [lldb-dap] Allow providing debug adapter arguments in the extension (PR #129262)
Matthew Bastien via lldb-commits
lldb-commits at lists.llvm.org
Fri Feb 28 08:22:54 PST 2025
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_bastien at 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 a200efbe9bf316113865db7edc59fc5628c62b59 Mon Sep 17 00:00:00 2001
From: Matthew Bastien <matthew_bastien at apple.com>
Date: Fri, 28 Feb 2025 11:22:41 -0500
Subject: [PATCH 2/2] update wording
---
lldb/tools/lldb-dap/package.json | 2 +-
lldb/tools/lldb-dap/src-ts/debug-adapter-factory.ts | 4 ++--
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/lldb/tools/lldb-dap/package.json b/lldb/tools/lldb-dap/package.json
index 0859b6e388a4e..a0633311e3b6f 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 arguments used to launch the debug adapter executable."
},
"lldb-dap.log-path": {
"scope": "resource",
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,
More information about the lldb-commits
mailing list