5 Commits

Author SHA1 Message Date
royitaqi
0e0ea714f3
[vscode-lldb] Add VS Code commands for high level debug workflow (#151827)
This allows other debugger extensions to leverage the `lldb-dap`
extension's settings and logic (e.g. "Server Mode").

Other debugger extensions can invoke these commands to resolve
configuration, create adapter descriptor, and get the `lldb-dap` process
for state tracking, additional interaction, and telemetry.

VS Code commands added:
* `lldb-dap.resolveDebugConfiguration`
* `lldb-dap.resolveDebugConfigurationWithSubstitutedVariables`
* `lldb-dap.createDebugAdapterDescriptor`
* `lldb-dap.getServerProcess`
2025-08-06 11:42:21 -07:00
royitaqi
bb2642fab7
[vscode-lldb] Fix race condition when changing lldb-dap arguments (#151828)
# Problem

When the user changes lldb-dap's arguments (e.g. path), there is a race
condition, where the new lldb-dap process could be started first and
have set the extension's `serverProcess` and `serverInfo` according to
the new process, while the old lldb-dap process exits later and wipes
out these two fields.

Consequences:
1. This causes `getServerProcess()` to return `undefined` when it should
return the new process.
2. This also causes wrong behavior when starting the next debug session
that a new lldb-dap process will be started and the old not reused nor
killed.

# Fix

When wiping the two fields, check if `serverProcess` equals to the
process captured by the handler. If they equal, wipe the fields. If not,
then the fields have already been updated (either new process has
started, or the fields were already wiped out by another handler), and
so the wiping should be skipped.
2025-08-06 10:24:09 -07:00
royitaqi
cd834449a6
[vscode-lldb] Fix format (#151829)
Generated by running the formatter:
```
royshi-mac-home ~/public_llvm/llvm-project/lldb/tools/lldb-dap % yarn format
yarn run v1.22.22
warning package.json: License should be a valid SPDX license expression
warning lldb-dap@0.2.15: The engine "vscode" appears to be invalid.
$ npx prettier './src-ts/' --write
src-ts/debug-adapter-factory.ts 65ms
src-ts/debug-configuration-provider.ts 17ms (unchanged)
src-ts/debug-session-tracker.ts 11ms (unchanged)
src-ts/disposable-context.ts 2ms (unchanged)
src-ts/extension.ts 3ms (unchanged)
src-ts/lldb-dap-server.ts 7ms
src-ts/ui/error-with-notification.ts 4ms (unchanged)
src-ts/ui/modules-data-provider.ts 5ms (unchanged)
src-ts/ui/show-error-message.ts 6ms (unchanged)
src-ts/uri-launch-handler.ts 5ms (unchanged)
  Done in 0.99s.
```
2025-08-04 08:39:06 -07:00
Jonas Devlieghere
4f991cc995
[lldb-dap] Make connection URLs match lldb (#144770)
Use the same scheme as ConnectionFileDescriptor::Connect and use
"listen" and "accept". Addresses feedback from a Pavel in a different PR
[1].

[1] https://github.com/llvm/llvm-project/pull/143628#discussion_r2152225200
2025-06-19 20:48:07 -05:00
Matthew Bastien
0d4f12ee00
[lldb-dap] Allow providing debug adapter arguments in the extension (#129262)
Added a new setting called `lldb-dap.arguments` and a debug
configuration attribute called `debugAdapterArgs` that can be used to
set the arguments used to launch the debug adapter. Right now this is
mostly useful for debugging purposes to add the `--wait-for-debugger`
option to lldb-dap.

Additionally, the extension will now check for a changed lldb-dap
executable or arguments when launching a debug session in server mode. I
had to add a new `DebugConfigurationProvider` to do this because VSCode
will show an unhelpful error modal when the
`DebugAdapterDescriptorFactory` returns `undefined`.

In order to facilitate this, I had to add two new properties to the
launch configuration that are used by the
`DebugAdapterDescriptorFactory` to tell VS Code how to launch the debug
adapter:

- `debugAdapterHostname` - the hostname for an existing lldb-dap server
- `debugAdapterPort` - the port for an existing lldb-dap server

I've also removed the check for the `executable` argument in
`LLDBDapDescriptorFactory.createDebugAdapterDescriptor()`. This argument
is only set by VS Code when the debug adapter executable properties are
set in the `package.json`. The LLDB DAP extension does not currently do
this (and I don't think it ever will). So, this makes the debug adapter
descriptor factory a little easier to read.

The check for whether or not `lldb-dap` exists has been moved into the
new `DebugConfigurationProvider` as well. This way the extension won't
get in the user's way unless they actually try to start a debugging
session. The error will show up as a modal which will also make it more
obvious when something goes wrong, rather than popping up as a warning
at the bottom right of the screen.
2025-03-27 14:09:09 -07:00