You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* 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.
Copy file name to clipboardExpand all lines: lldb/tools/lldb-dap/README.md
+86-64Lines changed: 86 additions & 64 deletions
Original file line number
Diff line number
Diff line change
@@ -1,71 +1,30 @@
1
1
# LLDB DAP
2
2
3
-
## `lldb-dap`Configurations
3
+
## Procuring the `lldb-dap`binary
4
4
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.
10
7
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
12
12
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.
43
15
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
47
17
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.
49
21
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
65
23
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.
67
26
68
-
####Launching
27
+
### Launching a debugee
69
28
70
29
This will launch `/tmp/a.out` with arguments `one`, `two`, and `three` and
71
30
adds `FOO=1` and `bar` to the environment:
@@ -81,6 +40,14 @@ adds `FOO=1` and `bar` to the environment:
81
40
}
82
41
```
83
42
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
+
84
51
#### Attach using PID
85
52
86
53
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:
126
93
This will work as long as the architecture, vendor and OS supports waiting
127
94
for processes. Currently MacOS is the only platform that supports this.
128
95
129
-
####Loading a Core File
96
+
### Loading a Core File
130
97
131
98
This loads the coredump file `/cores/123.core` associated with the program
132
99
`/tmp/a.out`:
@@ -141,7 +108,7 @@ This loads the coredump file `/cores/123.core` associated with the program
141
108
}
142
109
```
143
110
144
-
####Connect to a Debug Server on the Current Machine
111
+
### Connect to a Debug Server on the Current Machine
145
112
146
113
This connects to a debug server (e.g. `lldb-server`, `gdbserver`) on
147
114
the current machine, that is debugging the program `/tmp/a.out` and listening
@@ -171,7 +138,7 @@ instead of using the custom command `attachCommands`.
171
138
}
172
139
```
173
140
174
-
####Connect to a Debug Server on Another Machine
141
+
### Connect to a Debug Server on Another Machine
175
142
176
143
This connects to a debug server running on another machine with hostname
177
144
`hostnmame`. Which is debugging the program `/tmp/a.out` and listening on
@@ -204,12 +171,67 @@ The default hostname being used `localhost`.
204
171
}
205
172
```
206
173
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
208
230
209
231
The `lldb-dap` tool includes additional custom commands to support the Debug
210
232
Adapter Protocol features.
211
233
212
-
###startDebugging
234
+
#### `lldb-dap.startDebugging`
213
235
214
236
Using the command `lldb-dap startDebugging` it is possible to trigger a
215
237
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.
234
256
}
235
257
```
236
258
237
-
###repl-mode
259
+
#### `lldb-dap repl-mode`
238
260
239
261
Inspect or adjust the behavior of lldb-dap repl evaluation requests. The
240
262
supported modes are `variable`, `command` and `auto`.
0 commit comments