diff options
| author | Roy Shi <royitaqi@users.noreply.github.com> | 2025-09-11 22:17:21 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-09-11 22:17:21 -0700 |
| commit | 13daa1e6efdbdc322265fda7ad8f5b265d2ab4aa (patch) | |
| tree | 3b3ec0f465fb6a5f240091ef289e8da8b65dfbab /lldb/tools | |
| parent | df2a7a9ec9afbcc2d1ab87cdcb55059fc2a0aaa8 (diff) | |
| download | llvm-13daa1e6efdbdc322265fda7ad8f5b265d2ab4aa.tar.gz llvm-13daa1e6efdbdc322265fda7ad8f5b265d2ab4aa.tar.bz2 llvm-13daa1e6efdbdc322265fda7ad8f5b265d2ab4aa.zip | |
[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": [
"",
],
```
Diffstat (limited to 'lldb/tools')
| -rw-r--r-- | lldb/tools/lldb-dap/package.json | 29 | ||||
| -rw-r--r-- | lldb/tools/lldb-dap/src-ts/debug-adapter-factory.ts | 2 |
2 files changed, 27 insertions, 4 deletions
diff --git a/lldb/tools/lldb-dap/package.json b/lldb/tools/lldb-dap/package.json index 9cc653cee405..0290a5f18f80 100644 --- a/lldb/tools/lldb-dap/package.json +++ b/lldb/tools/lldb-dap/package.json @@ -409,7 +409,7 @@ "anyOf": [ { "type": "object", - "markdownDescription": "Additional environment variables to set when launching the debug adapter executable. E.g. `{ \"FOO\": \"1\" }`", + "markdownDescription": "Additional environment variables to set when launching the debug adapter executable. For example `{ \"FOO\": \"1\" }`", "patternProperties": { ".*": { "type": "string" @@ -419,10 +419,10 @@ }, { "type": "array", - "markdownDescription": "Additional environment variables to set when launching the debug adapter executable. E.g. `[\"FOO=1\", \"BAR\"]`", + "markdownDescription": "Additional environment variables to set when launching the debug adapter executable. For example `[\"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. For example `{ \"FOO\": \"1\" }`", + "patternProperties": { + ".*": { + "type": "string" + } + }, + "default": {} + }, + { + "type": "array", + "markdownDescription": "Additional environment variables to set when launching the debug adapter executable. For example `[\"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 f7e92ee95ca3..7060638a9486 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; |
