Skip to content

Commit f62e168

Browse files
authored
[lldb-dap] Validate server mode support prior to invoking lldb-dap. (#130855)
This should ensure the extension only uses server mode if the binary supports the feature, otherwise it will fallback to the existing behavior. Fixes #130854
1 parent caf3018 commit f62e168

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

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

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,11 @@ async function getDAPExecutable(
9393
return undefined;
9494
}
9595

96+
async function isServerModeSupported(exe: string): Promise<boolean> {
97+
const { stdout } = await exec(exe, ['--help']);
98+
return /--connection/.test(stdout);
99+
}
100+
96101
/**
97102
* This class defines a factory used to find the lldb-dap binary to use
98103
* depending on the session configuration.
@@ -145,7 +150,7 @@ export class LLDBDapDescriptorFactory
145150
const dbgArgs = executable?.args ?? [];
146151

147152
const serverMode = config.get<boolean>('serverMode', false);
148-
if (serverMode) {
153+
if (serverMode && await isServerModeSupported(dapPath)) {
149154
const { host, port } = await this.startServer(dapPath, dbgArgs, dbgOptions);
150155
return new vscode.DebugAdapterServer(port, host);
151156
}

0 commit comments

Comments
 (0)