Skip to content

[lldb-dap] Validate server mode support prior to invoking lldb-dap. #130855

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 12, 2025

Conversation

ashgti
Copy link
Contributor

@ashgti ashgti commented Mar 11, 2025

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

This should ensure the extension only uses server mode if the binary supports the feature, otherwise it will fallback to the existing behavior.
@llvmbot
Copy link
Member

llvmbot commented Mar 11, 2025

@llvm/pr-subscribers-lldb

Author: John Harrison (ashgti)

Changes

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


Full diff: https://github.com/llvm/llvm-project/pull/130855.diff

1 Files Affected:

  • (modified) lldb/tools/lldb-dap/src-ts/debug-adapter-factory.ts (+6-1)
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 1f76fe31b00ad..c2244dcbde8f2 100644
--- a/lldb/tools/lldb-dap/src-ts/debug-adapter-factory.ts
+++ b/lldb/tools/lldb-dap/src-ts/debug-adapter-factory.ts
@@ -93,6 +93,11 @@ async function getDAPExecutable(
   return undefined;
 }
 
+async function isServerModeSupported(exe: string): Promise<boolean> {
+  const { stdout } = await exec(exe, ['--help']);
+  return /--connection/.test(stdout);
+}
+
 /**
  * This class defines a factory used to find the lldb-dap binary to use
  * depending on the session configuration.
@@ -145,7 +150,7 @@ export class LLDBDapDescriptorFactory
     const dbgArgs = executable?.args ?? [];
 
     const serverMode = config.get<boolean>('serverMode', false);
-    if (serverMode) {
+    if (serverMode && await isServerModeSupported(dapPath)) {
       const { host, port } = await this.startServer(dapPath, dbgArgs, dbgOptions);
       return new vscode.DebugAdapterServer(port, host);
     }

@ashgti ashgti merged commit f62e168 into llvm:main Mar 12, 2025
13 checks passed
frederik-h pushed a commit to frederik-h/llvm-project that referenced this pull request Mar 18, 2025
…lvm#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 llvm#130854
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Validate lldb-dap supports server mode
4 participants