Skip to content

Commit 39e6e88

Browse files
authored
[lldb-dap] Adding defaults to VSCode settings for user level defaults. (#137694)
This adds support for loading user level defaults in VSCode. The defaults are stored as basic settings that are loaded when the debug configuration is resolved. Not all settings are currently supported, I limited it to settings that would likely apply across multiple launch.json configurations. This should resolve #134564
1 parent 7220fda commit 39e6e88

File tree

3 files changed

+803
-559
lines changed

3 files changed

+803
-559
lines changed

lldb/tools/lldb-dap/README.md

Lines changed: 47 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,13 @@ The extension requires the `lldb-dap` (formerly `lldb-vscode`) binary.
66
This binary is not packaged with the VS Code extension.
77

88
There are multiple ways to obtain this binary:
9-
* Use the binary provided by your toolchain (for example `xcrun -f lldb-dap` on macOS) or contact your toolchain vendor to include it.
10-
* Download one of the relase packages from the [LLVM release page](https://github.com/llvm/llvm-project/releases/). The `LLVM-19.1.0-{operating_system}.tar.xz` packages contain a prebuilt `lldb-dap` binary.
11-
* Build it from source (see [LLDB's build instructions](https://lldb.llvm.org/resources/build.html)).
9+
10+
- Use the binary provided by your toolchain (for example `xcrun -f lldb-dap` on macOS) or contact your toolchain vendor to include it.
11+
- Download one of the release packages from the [LLVM release page](https://github.com/llvm/llvm-project/releases/). The `LLVM-19.1.0-{operating_system}.tar.xz` packages contain a prebuilt `lldb-dap` binary.
12+
- Build it from source (see [LLDB's build instructions](https://lldb.llvm.org/resources/build.html)).
1213

1314
By default, the VS Code extension will expect to find `lldb-dap` in your `PATH`.
14-
Alternatively, you can explictly specify the location of the `lldb-dap` binary using the `lldb-dap.executable-path` setting.
15+
Alternatively, you can explicitly specify the location of the `lldb-dap` binary using the `lldb-dap.executable-path` setting.
1516

1617
### Usage with other IDEs
1718

@@ -144,7 +145,7 @@ instead of using the custom command `attachCommands`.
144145
### Connect to a Debug Server on Another Machine
145146

146147
This connects to a debug server running on another machine with hostname
147-
`hostnmame`. Which is debugging the program `/tmp/a.out` and listening on
148+
`hostname`. Which is debugging the program `/tmp/a.out` and listening on
148149
port `5678` of that other machine.
149150

150151
```javascript
@@ -162,7 +163,6 @@ to send an attach request to a debug server running on a different machine,
162163
instead of custom command `attachCommands`.
163164
The default hostname being used `localhost`.
164165

165-
166166
```javascript
167167
{
168168
"name": "Local Debug Server",
@@ -212,7 +212,7 @@ specific key/value pairs:
212212
| **customThreadFormat** | string | | Same as `customFrameFormat`, but for threads instead of stack frames.
213213
| **displayExtendedBacktrace** | bool | | Enable language specific extended backtraces.
214214
| **enableAutoVariableSummaries** | bool | | Enable auto generated summaries for variables when no summaries exist for a given type. This feature can cause performance delays in large projects when viewing variables.
215-
| **enableSyntheticChildDebugging** | bool | | If a variable is displayed using a synthetic children, also display the actual contents of the variable at the end under a [raw] entry. This is useful when creating sythetic child plug-ins as it lets you see the actual contents of the variable.
215+
| **enableSyntheticChildDebugging** | bool | | If a variable is displayed using a synthetic children, also display the actual contents of the variable at the end under a [raw] entry. This is useful when creating synthetic child plug-ins as it lets you see the actual contents of the variable.
216216
| **initCommands** | [string] | | LLDB commands executed upon debugger startup prior to creating the LLDB target.
217217
| **preRunCommands** | [string] | | LLDB commands executed just before launching/attaching, after the LLDB target has been created.
218218
| **stopCommands** | [string] | | LLDB commands executed just after each stop.
@@ -221,8 +221,9 @@ specific key/value pairs:
221221

222222
All commands and command outputs will be sent to the debugger console when they are executed.
223223
Commands can be prefixed with `?` or `!` to modify their behavior:
224-
* Commands prefixed with `?` are quiet on success, i.e. nothing is written to stdout if the command succeeds.
225-
* Prefixing a command with `!` enables error checking: If a command prefixed with `!` fails, subsequent commands will not be run. This is usefule if one of the commands depends on another, as it will stop the chain of commands.
224+
225+
- Commands prefixed with `?` are quiet on success, i.e. nothing is written to stdout if the command succeeds.
226+
- Prefixing a command with `!` enables error checking: If a command prefixed with `!` fails, subsequent commands will not be run. This is useful if one of the commands depends on another, as it will stop the chain of commands.
226227

227228
For JSON configurations of `"type": "launch"`, the JSON configuration can additionally
228229
contain the following key/value pairs:
@@ -243,10 +244,40 @@ the following `lldb-dap` specific key/value pairs:
243244
| Parameter | Type | Req | |
244245
|-----------------------------------|-------------|:---:|---------|
245246
| **program** | string | | Path to the executable to attach to. This value is optional but can help to resolve breakpoints prior the attaching to the program.
246-
| **pid** | number | | The process id of the process you wish to attach to. If **pid** is omitted, the debugger will attempt to attach to the program by finding a process whose file name matches the file name from **porgram**. Setting this value to `${command:pickMyProcess}` will allow interactive process selection in the IDE.
247+
| **pid** | number | | The process id of the process you wish to attach to. If **pid** is omitted, the debugger will attempt to attach to the program by finding a process whose file name matches the file name from **program**. Setting this value to `${command:pickMyProcess}` will allow interactive process selection in the IDE.
247248
| **waitFor** | boolean | | Wait for the process to launch.
248249
| **attachCommands** | [string] | | LLDB commands that will be executed after **preRunCommands** which take place of the code that normally does the attach. The commands can create a new target and attach or launch it however desired. This allows custom launch and attach configurations. Core files can use `target create --core /path/to/core` to attach to core files.
249250

251+
### Configuring `lldb-dap` defaults
252+
253+
User settings can set the default value for the following supported
254+
`launch.json` configuration keys:
255+
256+
| Parameter | Type | Default |
257+
| --------------------------------- | -------- | :-----: |
258+
| **commandEscapePrefix** | string | ``"`"`` |
259+
| **customFrameFormat** | string | `""` |
260+
| **customThreadFormat** | string | `""` |
261+
| **detachOnError** | boolean | `false` |
262+
| **disableASLR** | boolean | `true` |
263+
| **disableSTDIO** | boolean | `false` |
264+
| **displayExtendedBacktrace** | boolean | `false` |
265+
| **enableAutoVariableSummaries** | boolean | `false` |
266+
| **enableSyntheticChildDebugging** | boolean | `false` |
267+
| **timeout** | number | `30` |
268+
| **targetTriple** | string | `""` |
269+
| **platformName** | string | `""` |
270+
| **initCommands** | [string] | `[]` |
271+
| **preRunCommands** | [string] | `[]` |
272+
| **postRunCommands** | [string] | `[]` |
273+
| **stopCommands** | [string] | `[]` |
274+
| **exitCommands** | [string] | `[]` |
275+
| **terminateCommands** | [string] | `[]` |
276+
277+
To adjust your settings, open the Settings editor via the
278+
`File > Preferences > Settings` menu or press `Ctrl+`, on Windows/Linux and
279+
`Cmd+`, on Mac.
280+
250281
## Debug Console
251282

252283
The Debug Console allows printing variables / expressions and executing lldb commands.
@@ -294,13 +325,13 @@ Inspect or adjust the behavior of lldb-dap repl evaluation requests. The
294325
supported modes are `variable`, `command` and `auto`.
295326

296327
- `variable` - Variable mode expressions are evaluated in the context of the
297-
current frame.
328+
current frame.
298329
- `command` - Command mode expressions are evaluated as lldb commands, as a
299-
result, values printed by lldb are always stringified representations of the
300-
expression output.
330+
result, values printed by lldb are always stringified representations of the
331+
expression output.
301332
- `auto` - Auto mode will attempt to infer if the expression represents an lldb
302-
command or a variable expression. A heuristic is used to infer if the input
303-
represents a variable or a command.
333+
command or a variable expression. A heuristic is used to infer if the input
334+
represents a variable or a command.
304335

305336
In all three modes, you can use the `commandEscapePrefix` to ensure an expression
306337
is evaluated as a command.
@@ -330,7 +361,7 @@ For example you can use a launch configuration hook to trigger custom events lik
330361
"program": "exe",
331362
"stopCommands": [
332363
"lldb-dap send-event MyStopEvent",
333-
"lldb-dap send-event MyStopEvent '{\"key\": 321}",
364+
"lldb-dap send-event MyStopEvent '{\"key\": 321}"
334365
]
335366
}
336367
```

0 commit comments

Comments
 (0)