Skip to content

Commit c2862d6

Browse files
committed
Add extension setting
1 parent b185ae3 commit c2862d6

File tree

3 files changed

+24
-1
lines changed

3 files changed

+24
-1
lines changed

lldb/tools/lldb-dap/package.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,13 @@
106106
"markdownDescription": "Run lldb-dap in server mode.\n\nWhen enabled, lldb-dap will start a background server that will be reused between debug sessions. This allows caching of debug symbols between sessions and improves launch performance.",
107107
"default": false
108108
},
109+
"lldb-dap.connectionTimeout": {
110+
"order": 0,
111+
"scope": "resource",
112+
"type": "number",
113+
"markdownDescription": "When running lldb-dap in server mode, the time in seconds to wait for new connections after the server has started and after all clients have disconnected. Each new connection will reset the timeout. When the timeout is reached, the server will be closed and the process will exit. Specifying non-positive values will cause the server to wait for new connections indefinitely.",
114+
"default": 0
115+
},
109116
"lldb-dap.arguments": {
110117
"scope": "resource",
111118
"type": "array",

lldb/tools/lldb-dap/src-ts/debug-configuration-provider.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,10 +207,15 @@ export class LLDBDapConfigurationProvider
207207
config.get<boolean>("serverMode", false) &&
208208
(await isServerModeSupported(executable.command))
209209
) {
210+
const connectionTimeoutSeconds = config.get<number | undefined>(
211+
"connectionTimeout",
212+
undefined,
213+
);
210214
const serverInfo = await this.server.start(
211215
executable.command,
212216
executable.args,
213217
executable.options,
218+
connectionTimeoutSeconds,
214219
);
215220
if (!serverInfo) {
216221
return undefined;

lldb/tools/lldb-dap/src-ts/lldb-dap-server.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,19 @@ export class LLDBDapServer implements vscode.Disposable {
3333
dapPath: string,
3434
args: string[],
3535
options?: child_process.SpawnOptionsWithoutStdio,
36+
connectionTimeoutSeconds?: number,
3637
): Promise<{ host: string; port: number } | undefined> {
37-
const dapArgs = [...args, "--connection", "listen://localhost:0"];
38+
// Both the --connection and --connection-timeout arguments are subject to the shouldContinueStartup() check.
39+
const connectionTimeoutArgs =
40+
connectionTimeoutSeconds && connectionTimeoutSeconds > 0
41+
? ["--connection-timeout", `${connectionTimeoutSeconds}`]
42+
: [];
43+
const dapArgs = [
44+
...args,
45+
"--connection",
46+
"listen://localhost:0",
47+
...connectionTimeoutArgs,
48+
];
3849
if (!(await this.shouldContinueStartup(dapPath, dapArgs, options?.env))) {
3950
return undefined;
4051
}

0 commit comments

Comments
 (0)