================
@@ -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;
+    }
----------------
matthewbastien wrote:

Alright, this took a bit of re-organizing since the 
`DebugAdapterDescriptorFactory` does not gracefully stop the debug session if 
it returns `undefined`. Instead, VS Code shows a modal with an error message 
that suggests that the extension may not have activated properly which is... 
unhelpful in this case.

I've moved the logic for starting the server and prompting the user for input 
to a new `DebugConfigurationProvider` which can stop the session gracefully and 
even open the `launch.json` for editing if something goes wrong.

In order to facilitate this, I had to add two new properties to the launch 
configuration that are used by the `DebugAdapterDescriptorFactory` to tell VS 
Code how to launch the debug adapter:

- `debugAdapterHostname` - the hostname for an existing lldb-dap server
- `debugAdapterPort `- the port for an existing lldb-dap server

This has the added bonus of allowing the user to start their own lldb-dap 
process in server mode if they really wanted to.

https://github.com/llvm/llvm-project/pull/129262
_______________________________________________
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to