-
Notifications
You must be signed in to change notification settings - Fork 15.1k
[lldb-dap] Add debugAdapterEnv for attach requests & improve regex
#157980
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
@llvm/pr-subscribers-lldb Author: Roy Shi (royitaqi) ChangesChanges#153536 added a new debug configuration field called This patch also improves the regex used in this field, i.e. shortens it and fixed the double backslashes ( TestManually tested the following field values with Full diff: https://github.com/llvm/llvm-project/pull/157980.diff 2 Files Affected:
diff --git a/lldb/tools/lldb-dap/package.json b/lldb/tools/lldb-dap/package.json
index 9cc653cee405b..3d8b18bed0108 100644
--- a/lldb/tools/lldb-dap/package.json
+++ b/lldb/tools/lldb-dap/package.json
@@ -422,7 +422,7 @@
"markdownDescription": "Additional environment variables to set when launching the debug adapter executable. E.g. `[\"FOO=1\", \"BAR\"]`",
"items": {
"type": "string",
- "pattern": "^((\\w+=.*)|^\\w+)$"
+ "pattern": "^\\w+(=.*)?$"
},
"default": []
}
@@ -672,6 +672,29 @@
},
"markdownDescription": "The list of additional arguments used to launch the debug adapter executable. Overrides any user or workspace settings."
},
+ "debugAdapterEnv": {
+ "anyOf": [
+ {
+ "type": "object",
+ "markdownDescription": "Additional environment variables to set when launching the debug adapter executable. E.g. `{ \"FOO\": \"1\" }`",
+ "patternProperties": {
+ ".*": {
+ "type": "string"
+ }
+ },
+ "default": {}
+ },
+ {
+ "type": "array",
+ "markdownDescription": "Additional environment variables to set when launching the debug adapter executable. E.g. `[\"FOO=1\", \"BAR\"]`",
+ "items": {
+ "type": "string",
+ "pattern": "^\\w+(=.*)?$"
+ },
+ "default": []
+ }
+ ]
+ },
"program": {
"type": "string",
"description": "Path to the program to attach to."
diff --git a/lldb/tools/lldb-dap/src-ts/debug-adapter-factory.ts b/lldb/tools/lldb-dap/src-ts/debug-adapter-factory.ts
index f7e92ee95ca32..7060638a94864 100644
--- a/lldb/tools/lldb-dap/src-ts/debug-adapter-factory.ts
+++ b/lldb/tools/lldb-dap/src-ts/debug-adapter-factory.ts
@@ -92,7 +92,7 @@ function validateDAPEnv(debugConfigEnv: any): boolean {
Array.isArray(debugConfigEnv) &&
debugConfigEnv.findIndex(
(entry) =>
- typeof entry !== "string" || !/^((\\w+=.*)|^\\w+)$/.test(entry),
+ typeof entry !== "string" || !/^\w+(=.*)?$/.test(entry),
) !== -1
) {
return false;
|
debugAdapterEnv debug configuration field for attach requests, and improve regexdebugAdapterEnv for attach requests & improve regex
|
@JDevlieghere / @walter-erquinigo: I will appreciate a quick review/stamp when you gentlemen have the time. Hopefully this doesn't cost more than 5 minutes. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
eb85d54 to
68fdd63
Compare
llvm#157980) # Changes llvm#153536 added a new debug configuration field called `debugAdapterEnv` and enabled it in `launch.json` **for `launch` requests**. This patch enables the same for **`attach` requests**. This patch also improves the regex used in this field, i.e. shortens it and fixes the double backslashes (`\\`) in `debug-adapter-factory.ts` (note: the ones in `package.json` need the double backslashes). # Test Manually tested the following values in `attach` requests (so that we are testing both changes at the same time): ``` // Accepted "debugAdapterEnv": [ "AAA=BBB", ], "debugAdapterEnv": [ "AAA=", ], "debugAdapterEnv": [ "AAA", ], // Rejected "debugAdapterEnv": [ "=AAA", ], "debugAdapterEnv": [ "=", ], "debugAdapterEnv": [ "", ], ``` (cherry picked from commit 13daa1e)
Changes
#153536 added a new debug configuration field called
debugAdapterEnvand enabled it inlaunch.jsonforlaunchrequests. This patch enables the same forattachrequests.This patch also improves the regex used in this field, i.e. shortens it and fixes the double backslashes (
\\) indebug-adapter-factory.ts(note: the ones inpackage.jsonneed the double backslashes).Test
Manually tested the following values in
attachrequests (so that we are testing both changes at the same time):