Skip to content

Commit 13daa1e

Browse files
authored
[lldb-dap] Add debugAdapterEnv for attach requests & improve regex (#157980)
# Changes #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": [ "", ], ```
1 parent df2a7a9 commit 13daa1e

File tree

2 files changed

+27
-4
lines changed

2 files changed

+27
-4
lines changed

lldb/tools/lldb-dap/package.json

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -409,7 +409,7 @@
409409
"anyOf": [
410410
{
411411
"type": "object",
412-
"markdownDescription": "Additional environment variables to set when launching the debug adapter executable. E.g. `{ \"FOO\": \"1\" }`",
412+
"markdownDescription": "Additional environment variables to set when launching the debug adapter executable. For example `{ \"FOO\": \"1\" }`",
413413
"patternProperties": {
414414
".*": {
415415
"type": "string"
@@ -419,10 +419,10 @@
419419
},
420420
{
421421
"type": "array",
422-
"markdownDescription": "Additional environment variables to set when launching the debug adapter executable. E.g. `[\"FOO=1\", \"BAR\"]`",
422+
"markdownDescription": "Additional environment variables to set when launching the debug adapter executable. For example `[\"FOO=1\", \"BAR\"]`",
423423
"items": {
424424
"type": "string",
425-
"pattern": "^((\\w+=.*)|^\\w+)$"
425+
"pattern": "^\\w+(=.*)?$"
426426
},
427427
"default": []
428428
}
@@ -672,6 +672,29 @@
672672
},
673673
"markdownDescription": "The list of additional arguments used to launch the debug adapter executable. Overrides any user or workspace settings."
674674
},
675+
"debugAdapterEnv": {
676+
"anyOf": [
677+
{
678+
"type": "object",
679+
"markdownDescription": "Additional environment variables to set when launching the debug adapter executable. For example `{ \"FOO\": \"1\" }`",
680+
"patternProperties": {
681+
".*": {
682+
"type": "string"
683+
}
684+
},
685+
"default": {}
686+
},
687+
{
688+
"type": "array",
689+
"markdownDescription": "Additional environment variables to set when launching the debug adapter executable. For example `[\"FOO=1\", \"BAR\"]`",
690+
"items": {
691+
"type": "string",
692+
"pattern": "^\\w+(=.*)?$"
693+
},
694+
"default": []
695+
}
696+
]
697+
},
675698
"program": {
676699
"type": "string",
677700
"description": "Path to the program to attach to."

lldb/tools/lldb-dap/src-ts/debug-adapter-factory.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ function validateDAPEnv(debugConfigEnv: any): boolean {
9292
Array.isArray(debugConfigEnv) &&
9393
debugConfigEnv.findIndex(
9494
(entry) =>
95-
typeof entry !== "string" || !/^((\\w+=.*)|^\\w+)$/.test(entry),
95+
typeof entry !== "string" || !/^\w+(=.*)?$/.test(entry),
9696
) !== -1
9797
) {
9898
return false;

0 commit comments

Comments
 (0)