Skip to content

Commit 006f7cb

Browse files
committed
[lldb-dap][docs] Improve README
* Document how to procure and configure the `lldb-dap` binary * Improve documentation for `launch.json`: * Show the examples before the reference. Most new users just want to get going, and will only need the reference later on * Deduplicate the list of "launch" and "attach" config settings * Remove the `stopOnEntry` setting from "attach", since this is a launch-only setting * Document the previously undocumented settings `sourcePath`, `commandEscapePrefix`, `custom{Frame,Thread}Format`, `runInTerminal` * Add the settings `debuggerRoot` and `sourceMap` to the common section. So far they were documented as launch-only settings. * Document that the Debug Console prints variables / expressions by default and that LLDB commands need to be escaped.
1 parent 675c748 commit 006f7cb

File tree

1 file changed

+86
-64
lines changed

1 file changed

+86
-64
lines changed

lldb/tools/lldb-dap/README.md

Lines changed: 86 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -1,71 +1,30 @@
11
# LLDB DAP
22

3-
## `lldb-dap` Configurations
3+
## Procuring the `lldb-dap` binary
44

5-
The extension requires the `lldb-dap` (formerly `lldb-vscode`) binary. It is a
6-
command line tool that implements the [Debug Adapter
7-
Protocol](https://microsoft.github.io/debug-adapter-protocol/). It is used to power the Visual Studio Code extension but can also be used with other IDEs and editors that support DAP.
8-
The protocol is easy to run remotely and also can allow other tools and IDEs to
9-
get a full featured debugger with a well defined protocol.
5+
The extension requires the `lldb-dap` (formerly `lldb-vscode`) binary.
6+
This binary is not currently packaged with the VS-Code extension.
107

11-
## Launching & Attaching Configuration
8+
There are multiple ways to obtain this binary:
9+
* build it from source (see [LLDB's build instructions](https://lldb.llvm.org/resources/build.html))
10+
* download it 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+
* contact your toolchain vendor
1212

13-
Launching to attaching require you to create a [launch configuration](https://code.visualstudio.com/Docs/editor/debugging#_launch-configurations).
14-
This file defines arguments that get passed to `lldb-dap` and the configuration settings control how the launch or attach happens.
15-
16-
### Launch Configuration Settings
17-
18-
When you launch a program with Visual Studio Code you will need to create a [launch.json](https://code.visualstudio.com/Docs/editor/debugging#_launch-configurations)
19-
file that defines how your program will be run. The JSON configuration file can contain the following `lldb-dap` specific launch key/value pairs:
20-
21-
|parameter |type|req | |
22-
|-------------------|----|:--:|---------|
23-
|**name** |string|Y| A configuration name that will be displayed in the IDE.
24-
|**type** |string|Y| Must be "lldb-dap".
25-
|**request** |string|Y| Must be "launch".
26-
|**program** |string|Y| Path to the executable to launch.
27-
|**args** |[string]|| An array of command line argument strings to be passed to the program being launched.
28-
|**cwd** |string| | The program working directory.
29-
|**env** |dictionary| | Environment variables to set when launching the program. The format of each environment variable string is "VAR=VALUE" for environment variables with values or just "VAR" for environment variables with no values.
30-
|**stopOnEntry** |boolean| | Whether to stop program immediately after launching.
31-
|**initCommands** |[string]| | LLDB commands executed upon debugger startup prior to creating the LLDB target. Commands and command output will be sent to the debugger console when they are executed.
32-
|**preRunCommands** |[string]| | LLDB commands executed just before launching after the LLDB target has been created. Commands and command output will be sent to the debugger console when they are executed.
33-
|**stopCommands** |[string]| | LLDB commands executed just after each stop. Commands and command output will be sent to the debugger console when they are executed.
34-
|**launchCommands** |[string]| | LLDB commands executed to launch the program. Commands and command output will be sent to the debugger console when they are executed.
35-
|**exitCommands** |[string]| | LLDB commands executed when the program exits. Commands and command output will be sent to the debugger console when they are executed.
36-
|**terminateCommands** |[string]| | LLDB commands executed when the debugging session ends. Commands and command output will be sent to the debugger console when they are executed.
37-
|**sourceMap** |[string[2]]| | Specify an array of path re-mappings. Each element in the array must be a two element array containing a source and destination pathname.
38-
|**debuggerRoot** | string| |Specify a working directory to use when launching lldb-dap. If the debug information in your executable contains relative paths, this option can be used so that `lldb-dap` can find source files and object files that have relative paths.
39-
40-
### Attaching Settings
41-
42-
When attaching to a process using LLDB you can attach in a few ways
13+
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.
4315

44-
1. Attach to an existing process using the process ID
45-
2. Attach to an existing process by name
46-
3. Attach by name by waiting for the next instance of a process to launch
16+
### Usage with other editors
4717

48-
The JSON configuration file can contain the following `lldb-dap` specific launch key/value pairs:
18+
The `lldb-dap` binary is a command line tool that implements the [Debug Adapter Protocol](https://microsoft.github.io/debug-adapter-protocol/).
19+
It is used to power the Visual Studio Code extension but can also be used with other IDEs and editors that support DAP.
20+
The protocol is easy to run remotely and also can allow other tools and IDEs to get a full featured debugger with a well defined protocol.
4921

50-
|parameter |type |req | |
51-
|-------------------|--------|:--:|---------|
52-
|**name** |string |Y| A configuration name that will be displayed in the IDE.
53-
|**type** |string |Y| Must be "lldb-dap".
54-
|**request** |string |Y| Must be "attach".
55-
|**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.
56-
|**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.
57-
|**stopOnEntry** |boolean| | Whether to stop program immediately after launching.
58-
|**waitFor** |boolean | | Wait for the process to launch.
59-
|**initCommands** |[string]| | LLDB commands executed upon debugger startup prior to creating the LLDB target. Commands and command output will be sent to the debugger console when they are executed.
60-
|**preRunCommands** |[string]| | LLDB commands executed just before launching after the LLDB target has been created. Commands and command output will be sent to the debugger console when they are executed.
61-
|**stopCommands** |[string]| | LLDB commands executed just after each stop. Commands and command output will be sent to the debugger console when they are executed.
62-
|**exitCommands** |[string]| | LLDB commands executed when the program exits. Commands and command output will be sent to the debugger console when they are executed.
63-
|**terminateCommands** |[string]| | LLDB commands executed when the debugging session ends. Commands and command output will be sent to the debugger console when they are executed.
64-
|**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.
22+
## Launching & Attaching to a debugee
6523

66-
### Example configurations
24+
Launching or attaching a debugee require you to create a [launch configuration](https://code.visualstudio.com/Docs/editor/debugging#_launch-configurations).
25+
This file defines arguments that get passed to `lldb-dap` and the configuration settings control how the launch or attach happens.
6726

68-
#### Launching
27+
### Launching a debugee
6928

7029
This will launch `/tmp/a.out` with arguments `one`, `two`, and `three` and
7130
adds `FOO=1` and `bar` to the environment:
@@ -81,6 +40,14 @@ adds `FOO=1` and `bar` to the environment:
8140
}
8241
```
8342

43+
### Attaching to a process
44+
45+
When attaching to a process using LLDB you can attach in a few ways
46+
47+
1. Attach to an existing process using the process ID
48+
2. Attach to an existing process by name
49+
3. Attach by name by waiting for the next instance of a process to launch
50+
8451
#### Attach using PID
8552

8653
This will attach to a process `a.out` whose process ID is 123:
@@ -126,7 +93,7 @@ to be launched you can add the "waitFor" key value pair:
12693
This will work as long as the architecture, vendor and OS supports waiting
12794
for processes. Currently MacOS is the only platform that supports this.
12895

129-
#### Loading a Core File
96+
### Loading a Core File
13097

13198
This loads the coredump file `/cores/123.core` associated with the program
13299
`/tmp/a.out`:
@@ -141,7 +108,7 @@ This loads the coredump file `/cores/123.core` associated with the program
141108
}
142109
```
143110

144-
#### Connect to a Debug Server on the Current Machine
111+
### Connect to a Debug Server on the Current Machine
145112

146113
This connects to a debug server (e.g. `lldb-server`, `gdbserver`) on
147114
the current machine, that is debugging the program `/tmp/a.out` and listening
@@ -171,7 +138,7 @@ instead of using the custom command `attachCommands`.
171138
}
172139
```
173140

174-
#### Connect to a Debug Server on Another Machine
141+
### Connect to a Debug Server on Another Machine
175142

176143
This connects to a debug server running on another machine with hostname
177144
`hostnmame`. Which is debugging the program `/tmp/a.out` and listening on
@@ -204,12 +171,67 @@ The default hostname being used `localhost`.
204171
}
205172
```
206173

207-
## Custom debugger commands
174+
### Configuration Settings Reference
175+
176+
For both launch and attach configurations, lldb-dap accepts the following `lldb-dap`
177+
specific key/value pairs:
178+
179+
|parameter |type|req | |
180+
|-------------------|----|:--:|---------|
181+
|**name** |string|Y| A configuration name that will be displayed in the IDE.
182+
|**type** |string|Y| Must be "lldb-dap".
183+
|**request** |string|Y| Must be "launch" or "attach".
184+
|**program** |string|Y| Path to the executable to launch.
185+
|**sourcePath** |string| | Specify a source path to remap \"./\" to allow full paths to be used when setting breakpoints in binaries that have relative source paths.
186+
|**sourceMap** |[string[2]]| | Specify an array of path re-mappings. Each element in the array must be a two element array containing a source and destination pathname. Overrides sourcePath.
187+
|**debuggerRoot** | string| |Specify a working directory to use when launching lldb-dap. If the debug information in your executable contains relative paths, this option can be used so that `lldb-dap` can find source files and object files that have relative paths.
188+
|**commandEscapePrefix** | string | | The escape prefix to use for executing regular LLDB commands in the Debug Console, instead of printing variables. Defaults to a back-tick (`\``). If it's an empty string, then all expression in the Debug Console are treated as regular LLDB commands.
189+
|**customFrameFormat** | string | | If non-empty, stack frames will have descriptions generated based on the provided format. See https://lldb.llvm.org/use/formatting.html for an explanation on format strings for frames. If the format string contains errors, an error message will be displayed on the Debug Console and the default frame names will be used. This might come with a performance cost because debug information might need to be processed to generate the description.
190+
|**customThreadFormat** | string | | Same as `customFrameFormat`, but for threads instead of stack frames.
191+
|**initCommands** |[string]| | LLDB commands executed upon debugger startup prior to creating the LLDB target.
192+
|**preRunCommands** |[string]| | LLDB commands executed just before launching/attaching, after the LLDB target has been created.
193+
|**stopCommands** |[string]| | LLDB commands executed just after each stop.
194+
|**exitCommands** |[string]| | LLDB commands executed when the program exits.
195+
|**terminateCommands** |[string]| | LLDB commands executed when the debugging session ends.
196+
197+
All commands and command outputs will be sent to the debugger console when they are executed.
198+
199+
For JSON configurations of `"type": "launch"`, the JSON configuration can additionally
200+
contain the following key/value pairs:
201+
202+
|parameter |type|req | |
203+
|-------------------|----|:--:|---------|
204+
|**program** |string|Y| Path to the executable to launch.
205+
|**args** |[string]|| An array of command line argument strings to be passed to the program being launched.
206+
|**cwd** |string| | The program working directory.
207+
|**env** |dictionary| | Environment variables to set when launching the program. The format of each environment variable string is "VAR=VALUE" for environment variables with values or just "VAR" for environment variables with no values.
208+
|**stopOnEntry** |boolean| | Whether to stop program immediately after launching.
209+
|**runInTerminal** |boolean| | Launch the program inside an integrated terminal in the IDE. Useful for debugging interactive command line programs.
210+
|**launchCommands** |[string]| | LLDB commands executed to launch the program.
211+
212+
For JSON configurations of `"type": "attach"`, the JSON configuration can contain
213+
the following `lldb-dap` specific key/value pairs:
214+
215+
|parameter |type |req | |
216+
|-------------------|--------|:--:|---------|
217+
|**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.
218+
|**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.
219+
|**waitFor** |boolean | | Wait for the process to launch.
220+
|**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.
221+
222+
## Debug Console
223+
224+
The debug console allows printing variables / expressions and executing lldb commands.
225+
By default, all provided commands are interpreteted as variable names / expressions whose values will be printed to the Debug Console.
226+
To execute regular LLDB commands, prefix them with the `\`` character.
227+
The escape character can be changed via the `commandEscapePrefix` configuration option.
228+
229+
### lldb-dap specific commands
208230

209231
The `lldb-dap` tool includes additional custom commands to support the Debug
210232
Adapter Protocol features.
211233

212-
### startDebugging
234+
#### `lldb-dap.startDebugging`
213235

214236
Using the command `lldb-dap startDebugging` it is possible to trigger a
215237
reverse request to the client requesting a child debug session with the
@@ -234,7 +256,7 @@ This will launch a server and then request a child debug session for a client.
234256
}
235257
```
236258

237-
### repl-mode
259+
#### `lldb-dap repl-mode`
238260

239261
Inspect or adjust the behavior of lldb-dap repl evaluation requests. The
240262
supported modes are `variable`, `command` and `auto`.

0 commit comments

Comments
 (0)