[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 13:58:53 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:
@walter-erquinigo I have moved the logic into a util function `validateDAPEnv()`. See commit 0f91d37.
For the above, I have validated that it can catch non-string key inputs like the following:
```
"debugAdapterEnv": {
999: 888,
},
```
--
Waiting to learn more about your thoughts regarding the regex (see my prev comment).
https://github.com/llvm/llvm-project/pull/153536
More information about the lldb-commits
mailing list