[Lldb-commits] [lldb] [lldb-dap] Adding server mode support to lldb-dap VSCode extension. (PR #128957)
Adrian Vogelsgesang via lldb-commits
lldb-commits at lists.llvm.org
Fri Feb 28 18:38:05 PST 2025
================
@@ -115,41 +123,71 @@ export class LLDBDapDescriptorFactory
}
const configEnvironment =
config.get<{ [key: string]: string }>("environment") || {};
- const dapPath = await getDAPExecutable(session);
+ const dapPath = (await getDAPExecutable(session)) ?? executable?.command;
+
+ if (!dapPath) {
+ LLDBDapDescriptorFactory.showLLDBDapNotFoundMessage();
+ return undefined;
+ }
+
+ if (!(await isExecutable(dapPath))) {
+ LLDBDapDescriptorFactory.showLLDBDapNotFoundMessage(dapPath);
+ return;
+ }
+
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,
- );
+ const dbgArgs = executable?.args ?? [];
+
+ const serverMode = config.get<boolean>('serverMode', false);
+ if (serverMode) {
+ const { host, port } = await this.startServer(dapPath, dbgArgs, dbgOptions);
+ return new vscode.DebugAdapterServer(port, host);
}
- return undefined;
+
+ return new vscode.DebugAdapterExecutable(dapPath, dbgArgs, dbgOptions);
+ }
+
+ startServer(dapPath: string, args: string[], options: child_process.CommonSpawnOptions): Promise<{ host: string, port: number }> {
+ if (this.server) return this.server;
----------------
vogelsgesang wrote:
afaict, this does not work correctly in combination with #126803. We might end up reusing the wrong lldb-dap binary
Not sure what this means for us, though... We also can't just kill the old server when we receive a different lldb-dap path, because we could have two separate debugging sessions running at the same time, each one using a different server binary. I guess the most robust solution would be to use a `Map` to associate each lldb-dap path with its own `Promise<{ process: child_process.ChildProcess, host: string, port: number }>`?
https://github.com/llvm/llvm-project/pull/128957
More information about the lldb-commits
mailing list