[Lldb-commits] [lldb] [lldb-dap] Allow providing debug adapter arguments in the extension (PR #129262)
Adrian Vogelsgesang via lldb-commits
lldb-commits at lists.llvm.org
Fri Feb 28 18:57:48 PST 2025
================
@@ -137,53 +157,59 @@ export class LLDBDapDescriptorFactory
const dbgOptions = {
env: {
- ...executable?.options?.env,
...configEnvironment,
...env,
},
};
- const dbgArgs = executable?.args ?? [];
+ const dbgArgs = getDAPArguments(session);
- const serverMode = config.get<boolean>('serverMode', false);
+ const serverMode = config.get<boolean>("serverMode", false);
if (serverMode) {
- const { host, port } = await this.startServer(dapPath, dbgArgs, dbgOptions);
+ const { host, port } = await this.startServer(
+ dapPath,
+ dbgArgs,
+ dbgOptions,
+ );
return new vscode.DebugAdapterServer(port, host);
}
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;
+ startServer(
+ dapPath: string,
+ args: string[],
+ options: child_process.CommonSpawnOptions,
+ ): Promise<{ host: string; port: number }> {
+ if (this.server) {
+ return this.server;
+ }
- this.server = new Promise(resolve => {
- args.push(
- '--connection',
- 'connect://localhost:0'
- );
+ this.server = new Promise((resolve) => {
+ args.push("--connection", "connect://localhost:0");
const server = child_process.spawn(dapPath, args, options);
- server.stdout!.setEncoding('utf8').once('data', (data: string) => {
+ server.stdout!.setEncoding("utf8").once("data", (data: string) => {
const connection = /connection:\/\/\[([^\]]+)\]:(\d+)/.exec(data);
if (connection) {
const host = connection[1];
const port = Number(connection[2]);
resolve({ process: server, host, port });
}
});
- server.on('exit', () => {
+ server.on("exit", () => {
this.server = undefined;
- })
+ });
});
return this.server;
}
/**
* Shows a message box when the debug adapter's path is not found
*/
- static async showLLDBDapNotFoundMessage(path?: string) {
+ static async showLLDBDapNotFoundMessage(path?: string | undefined) {
----------------
vogelsgesang wrote:
Afaict, the `?` already marks `path` as potentially `undefined`? Why add the `| undefined` in addition?
https://github.com/llvm/llvm-project/pull/129262
More information about the lldb-commits
mailing list