Skip to content

Commit 8926756

Browse files
allow providing debug adapter arguments
1 parent a955426 commit 8926756

File tree

2 files changed

+50
-21
lines changed

2 files changed

+50
-21
lines changed

lldb/tools/lldb-dap/package.json

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,15 @@
7575
"type": "string",
7676
"description": "The path to the lldb-dap binary."
7777
},
78+
"lldb-dap.arguments": {
79+
"scope": "resource",
80+
"type": "array",
81+
"default": [],
82+
"items": {
83+
"type": "string"
84+
},
85+
"description": "The arguments provided to the lldb-dap process."
86+
},
7887
"lldb-dap.log-path": {
7988
"scope": "resource",
8089
"type": "string",
@@ -156,6 +165,13 @@
156165
"type": "string",
157166
"markdownDescription": "The absolute path to the LLDB debug adapter executable to use."
158167
},
168+
"debugAdapterArgs": {
169+
"type": "array",
170+
"items": {
171+
"type": "string"
172+
},
173+
"markdownDescription": "The list of arguments used to launch the debug adapter executable."
174+
},
159175
"program": {
160176
"type": "string",
161177
"description": "Path to the program to debug."
@@ -346,6 +362,13 @@
346362
"type": "string",
347363
"markdownDescription": "The absolute path to the LLDB debug adapter executable to use."
348364
},
365+
"debugAdapterArgs": {
366+
"type": "array",
367+
"items": {
368+
"type": "string"
369+
},
370+
"markdownDescription": "The list of arguments used to launch the debug adapter executable."
371+
},
349372
"program": {
350373
"type": "string",
351374
"description": "Path to the program to attach to."

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

Lines changed: 27 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,21 @@ async function getDAPExecutable(
9292
return undefined;
9393
}
9494

95+
function getDAPArguments(session: vscode.DebugSession): string[] {
96+
// Check the debug configuration for arguments first
97+
const debugConfigArgs = session.configuration.debugAdapterArgs;
98+
if (
99+
Array.isArray(debugConfigArgs) &&
100+
debugConfigArgs.findIndex((entry) => typeof entry !== "string") === -1
101+
) {
102+
return debugConfigArgs;
103+
}
104+
// Fall back on the workspace configuration
105+
return vscode.workspace
106+
.getConfiguration("lldb-dap")
107+
.get<string[]>("arguments", []);
108+
}
109+
95110
/**
96111
* This class defines a factory used to find the lldb-dap binary to use
97112
* depending on the session configuration.
@@ -101,7 +116,7 @@ export class LLDBDapDescriptorFactory
101116
{
102117
async createDebugAdapterDescriptor(
103118
session: vscode.DebugSession,
104-
executable: vscode.DebugAdapterExecutable | undefined,
119+
_executable: vscode.DebugAdapterExecutable | undefined,
105120
): Promise<vscode.DebugAdapterDescriptor | undefined> {
106121
const config = vscode.workspace.getConfiguration(
107122
"lldb-dap",
@@ -116,40 +131,31 @@ export class LLDBDapDescriptorFactory
116131
const configEnvironment =
117132
config.get<{ [key: string]: string }>("environment") || {};
118133
const dapPath = await getDAPExecutable(session);
134+
const dapArgs = getDAPArguments(session);
119135
const dbgOptions = {
120136
env: {
121-
...executable?.options?.env,
122137
...configEnvironment,
123138
...env,
124139
},
125140
};
126-
if (dapPath) {
127-
if (!(await isExecutable(dapPath))) {
128-
LLDBDapDescriptorFactory.showLLDBDapNotFoundMessage(dapPath);
129-
return undefined;
130-
}
131-
return new vscode.DebugAdapterExecutable(dapPath, [], dbgOptions);
132-
} else if (executable) {
133-
if (!(await isExecutable(executable.command))) {
134-
LLDBDapDescriptorFactory.showLLDBDapNotFoundMessage(executable.command);
135-
return undefined;
136-
}
137-
return new vscode.DebugAdapterExecutable(
138-
executable.command,
139-
executable.args,
140-
dbgOptions,
141-
);
141+
if (dapPath === undefined || !(await isExecutable(dapPath))) {
142+
LLDBDapDescriptorFactory.showLLDBDapNotFoundMessage(dapPath);
143+
return undefined;
142144
}
143-
return undefined;
145+
return new vscode.DebugAdapterExecutable(dapPath, dapArgs, dbgOptions);
144146
}
145147

146148
/**
147149
* Shows a message box when the debug adapter's path is not found
148150
*/
149-
static async showLLDBDapNotFoundMessage(path: string) {
151+
static async showLLDBDapNotFoundMessage(path: string | undefined) {
150152
const openSettingsAction = "Open Settings";
153+
const message =
154+
path === undefined
155+
? "Unable to find the LLDB debug adapter executable."
156+
: `Debug adapter path: ${path} is not a valid file`;
151157
const callbackValue = await vscode.window.showErrorMessage(
152-
`Debug adapter path: ${path} is not a valid file`,
158+
message,
153159
openSettingsAction,
154160
);
155161

0 commit comments

Comments
 (0)