Skip to content

Commit 6c137b7

Browse files
authored
[lldb-dap][docs] Improve documentation for contributors (#110987)
This commit extends the developer docs for `lldb-dap`. It also adds a short "Contributing" section to the user-facing README. Last but not least, it updates the `repository` in the package.json to point to the actual source of truth for the source code, instead of pointing to its mirrored repository. I hope that the VS Code Marketplace properly supports the `directory` property. Unfortunately, I have no way to test this before merging this Pull Request.
1 parent c08d7b3 commit 6c137b7

File tree

3 files changed

+100
-15
lines changed

3 files changed

+100
-15
lines changed

lldb/docs/resources/lldbdap.md

Lines changed: 89 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,95 @@
1-
# LLDB-DAP
2-
3-
The `lldb-dap` tool (formerly `lldb-vscode`) is a command line tool that
4-
implements the [Debug Adapter
5-
Protocol](https://microsoft.github.io/debug-adapter-protocol/). It can be
6-
installed as an extension for Visual Studio Code and other IDEs supporting DAP.
7-
The protocol is easy to run remotely and also can allow other tools and IDEs to
8-
get a full featured debugger with a well defined protocol.
9-
10-
## Local Installation for Visual Studio Code
1+
# Contributing to LLDB-DAP
2+
3+
This guide describes how to extend and contribute to lldb-dap.
4+
For documentation on how to use lldb-dap, see [lldb-dap's README](https://github.com/llvm/llvm-project/blob/main/lldb/tools/lldb-dap/README.md).
5+
6+
lldb-dap and LLDB are developed under the umbrella of the
7+
[LLVM project](https://llvm.org/). As such, the
8+
"[Getting Started with the LLVM System](https://llvm.org/docs/GettingStarted.html)",
9+
"[Contributing to LLVM](https://llvm.org/docs/Contributing.html)" and
10+
"[LLVM coding standard](https://llvm.org/docs/CodingStandards.html)"
11+
guides might also be relevant, if you are a first-time contributor to the LLVM
12+
project.
13+
14+
lldb-dap's source code is [part of the LLVM
15+
repository](https://github.com/llvm/llvm-project/tree/main/lldb/tools/lldb-dap)
16+
on Github. We use Github's [issue
17+
tracker](https://github.com/llvm/llvm-project/tree/main/lldb/tools/lldb-dap)
18+
and patches can be submitted via [pull
19+
requests](https://github.com/llvm/llvm-project/pulls).
20+
21+
## Building `lldb-dap` from soruce
22+
23+
To build lldb-dap from source, first need to [setup a LLDB build](https://lldb.llvm.org/resources/build.html).
24+
After doing so, run `ninja lldb-dap`. To use your freshly built `lldb-dap`
25+
binary, install the VS Code extension and point it to lldb-dap by setting the
26+
`lldb-dap.executable-path` setting.
27+
28+
## Responsibilities of LLDB, lldb-dap and the Visual Studio Code Extension
29+
30+
Under the hood, the UI-based debugging experience is fueled by three separate
31+
components:
32+
33+
* LLDB provides general, IDE-indepedent debugging features, such as:
34+
loading binaries / core dumps, interpreting debug info, setting breakpoints,
35+
pretty-printing variables, etc. The `lldb` binary exposes this functionality
36+
via a command line interface.
37+
* `lldb-dap` exposes LLDB's functionality via the
38+
"[Debug Adapter Protocol](https://microsoft.github.io/debug-adapter-protocol/)",
39+
i.e. a protocol through which various IDEs (VS Code, Emacs, vim, neovim, ...)
40+
can interact with a wide range of debuggers (`lldb-dap` and many others).
41+
* The VS Code extension exposes the lldb-dap binary within VS Code. It acts
42+
as a thin wrapper around the lldb-dap binary, and adds VS-Code-specific UI
43+
integration on top of lldb-dap, such as autocompletion for `launch.json`
44+
configuration files.
45+
46+
Since lldb-dap builds on top of LLDB, all of LLDB's extensibility mechanisms
47+
such as [Variable Pretty-Printing](https://lldb.llvm.org/use/variable.html),
48+
[Frame recognizers](https://lldb.llvm.org/use/python-reference.html#writing-lldb-frame-recognizers-in-python)
49+
and [Python Scripting](https://lldb.llvm.org/use/python.html) are available
50+
also in lldb-dap.
51+
52+
When adding new functionality, you generally want to add it on the lowest
53+
applicable level. I.e., quite frequently you actually want to add functionality
54+
to LLDB's core in order to improve your debugging experience in VS Code.
55+
56+
### The Debug Adapter Protocol
57+
58+
The most relevant resources for the Debug Adapter Protocol are:
59+
* [The overview](https://microsoft.github.io/debug-adapter-protocol/overview)
60+
which provides a high-level introduction,
61+
* the [human-readable specification](https://microsoft.github.io/debug-adapter-protocol/specification), and
62+
* the [JSON-schema specification](https://github.com/microsoft/debug-adapter-protocol/blob/main/debugAdapterProtocol.json).
63+
64+
lldb-dap adds some additional non-standard extensions to the protocol. To take
65+
advantage of those extensions, IDE-specific support code is needed, usually
66+
inside the VS Code extension. When adding a new extension, please first look
67+
through the [issue tracker of the Debug Adapter
68+
Protocol](https://github.com/microsoft/debug-adapter-protocol/issues) to check
69+
if there already is a proposal serving your use case. If so, try to take
70+
inspiration from it. If not, consider opening an upstream issue.
71+
72+
To avoid naming collisions with potential future extensions of the Debug
73+
Adapter protocol, all non-standard extensions should use the prefix
74+
`$__lldb_extension` in their JSON property names.
75+
76+
### Debugging the Debug Adapter Protocol
77+
78+
To debug the Debug Adapter Protocol, point the `LLDBDAP_LOG` environment
79+
variable to a file on your disk. lldb-dap will log all communication received
80+
from / sent to the IDE to the provided path. In the VS Code extension, you
81+
can also set the log path through the `lldb-dap.log-path` VS Code setting.
82+
83+
## Building the VS Code extension from source
1184

1285
Installing the plug-in is very straightforward and involves just a few steps.
1386

87+
In most cases, installing the VS Code extension from the [VS Code
88+
Marketplace](https://marketplace.visualstudio.com/items?itemName=llvm-vs-code-extensions.lldb-dap)
89+
and pointing it to a locally built lldb-dap binary is sufficient. Building
90+
the VS Code extension from source is only necessary if the TypeScript code is
91+
changed.
92+
1493
### Pre-requisites
1594

1695
- Install a modern version of node (e.g. `v20.0.0`).
@@ -33,10 +112,6 @@ And then you are ready!
33112

34113
### Updating the extension
35114

36-
*Note: It's not necessary to update the extension if there has been changes
37-
to `lldb-dap`. The extension needs to be updated only if the TypesScript code
38-
has changed.*
39-
40115
Updating the extension is pretty much the same process as installing it from
41116
scratch. However, VS Code expects the version number of the upgraded extension
42117
to be greater than the previous one, otherwise the installation step might have

lldb/tools/lldb-dap/README.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -286,3 +286,12 @@ is evaluated as a command.
286286
The initial repl-mode can be configured with the cli flag `--repl-mode=<mode>`
287287
and may also be adjusted at runtime using the lldb command
288288
`lldb-dap repl-mode <mode>`.
289+
290+
## Contributing
291+
292+
`lldb-dap` and `lldb` are developed under the umbrella of the [LLVM project](https://llvm.org/).
293+
The source code is [part of the LLVM repository](https://github.com/llvm/llvm-project/tree/main/lldb/tools/lldb-dap) on Github.
294+
We use Github's [issue tracker](https://github.com/llvm/llvm-project/tree/main/lldb/tools/lldb-dap) and patches can be submitted via [pull requests](https://github.com/llvm/llvm-project/pulls).
295+
Furthermore, there is a [LLDB category](https://discourse.llvm.org/c/subprojects/lldb/8) on the LLVM discourse forum.
296+
297+
For instructions on how to get started with development on lldb-dap, see the "[Contributing to lldb-dap](https://lldb.llvm.org/resources/lldbdap.html)"

lldb/tools/lldb-dap/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@
88
"license": "Apache 2.0 License with LLVM exceptions",
99
"repository": {
1010
"type": "git",
11-
"url": "https://github.com/llvm/vscode-lldb.git"
11+
"url": "https://github.com/llvm/llvm-project.git",
12+
"directory": "lldb/tools/lldb-dap/"
1213
},
1314
"bugs": {
1415
"url": "https://github.com/llvm/llvm-project/issues"

0 commit comments

Comments
 (0)