[Lldb-commits] [lldb] [vscode-lldb] Support lldb-dap environment in debug configuration (PR #153536)

Roy Shi via lldb-commits lldb-commits at lists.llvm.org
Tue Aug 26 10:31:38 PDT 2025


================
@@ -157,6 +157,61 @@ async function getDAPArguments(
     .get<string[]>("arguments", []);
 }
 
+/**
+ * Retrieves the environment that will be provided to lldb-dap either from settings or the provided
+ * {@link vscode.DebugConfiguration}.
+ *
+ * @param workspaceFolder The {@link vscode.WorkspaceFolder} that the debug session will be launched within
+ * @param configuration The {@link vscode.DebugConfiguration} that will be launched
+ * @throws An {@link ErrorWithNotification} if something went wrong
+ * @returns The environment that will be provided to lldb-dap
+ */
+async function getDAPEnvironment(
+  workspaceFolder: vscode.WorkspaceFolder | undefined,
+  configuration: vscode.DebugConfiguration,
+): Promise<{ [key: string]: string }> {
+  const debugConfigEnv = configuration.debugAdapterEnv;
+  if (debugConfigEnv) {
+    if (
+      (typeof debugConfigEnv !== "object" ||
+
+        Object.values(debugConfigEnv).findIndex(
+          (entry) => typeof entry !== "string",
+        ) !== -1) &&
+      (!Array.isArray(debugConfigEnv) ||
+        debugConfigEnv.findIndex(
+          (entry) =>
+            typeof entry !== "string" || !/^((\\w+=.*)|^\\w+)$/.test(entry),
+        ) !== -1)
+    ) {
+      throw new ErrorWithNotification(
+        "The debugAdapterEnv property must be a dictionary of string keys and values OR an array of string values. Please update your launch configuration",
+        new ConfigureButton(),
+      );
+    }
----------------
royitaqi wrote:

Will move to a helper function. I will probably do the same for the validation logic for adapter args. I see no dedicated source file for util functions, so I'm thinking just put into the same file.

That regex is copied from the package.json. I'm actually not sure what the spec is. E.g. should it accept any/all of the following?
```
A      // set A to empty
A=     // set A to empty
A=B=   // set A to "B="
A=B=C  // set A to "B=C"
```


https://github.com/llvm/llvm-project/pull/153536


More information about the lldb-commits mailing list