[Lldb-commits] [lldb] [vscode-lldb] Add VS Code commands for high level debug workflow (PR #151827)
via lldb-commits
lldb-commits at lists.llvm.org
Tue Aug 5 11:38:04 PDT 2025
https://github.com/royitaqi updated https://github.com/llvm/llvm-project/pull/151827
>From 14c3fc997de307c00199e22e23b2f665147964fc Mon Sep 17 00:00:00 2001
From: Roy Shi <royshi at meta.com>
Date: Sat, 2 Aug 2025 09:04:18 -0700
Subject: [PATCH 1/3] [lldb] [vscode-lldb] Add VS Code commands that can be
leveraged by other debugger extensions
---
.../lldb-dap/src-ts/debug-adapter-factory.ts | 10 ++++++++
.../src-ts/debug-configuration-provider.ts | 24 ++++++++++++++++++-
lldb/tools/lldb-dap/src-ts/lldb-dap-server.ts | 7 ++++++
3 files changed, 40 insertions(+), 1 deletion(-)
diff --git a/lldb/tools/lldb-dap/src-ts/debug-adapter-factory.ts b/lldb/tools/lldb-dap/src-ts/debug-adapter-factory.ts
index b5db45b56d6a6..fb1c928ede5fd 100644
--- a/lldb/tools/lldb-dap/src-ts/debug-adapter-factory.ts
+++ b/lldb/tools/lldb-dap/src-ts/debug-adapter-factory.ts
@@ -198,6 +198,16 @@ export async function createDebugAdapterExecutable(
export class LLDBDapDescriptorFactory
implements vscode.DebugAdapterDescriptorFactory
{
+ constructor() {
+ vscode.commands.registerCommand(
+ "lldb-dap.createDebugAdapterDescriptor",
+ (
+ session: vscode.DebugSession,
+ executable: vscode.DebugAdapterExecutable | undefined,
+ ) => this.createDebugAdapterDescriptor(session, executable),
+ );
+ }
+
async createDebugAdapterDescriptor(
session: vscode.DebugSession,
executable: vscode.DebugAdapterExecutable | undefined,
diff --git a/lldb/tools/lldb-dap/src-ts/debug-configuration-provider.ts b/lldb/tools/lldb-dap/src-ts/debug-configuration-provider.ts
index 316ffaf47c3d2..59d3d3c99e42d 100644
--- a/lldb/tools/lldb-dap/src-ts/debug-configuration-provider.ts
+++ b/lldb/tools/lldb-dap/src-ts/debug-configuration-provider.ts
@@ -71,7 +71,29 @@ const configurations: Record<string, DefaultConfig> = {
export class LLDBDapConfigurationProvider
implements vscode.DebugConfigurationProvider
{
- constructor(private readonly server: LLDBDapServer) {}
+ constructor(private readonly server: LLDBDapServer) {
+ vscode.commands.registerCommand(
+ "lldb-dap.resolveDebugConfiguration",
+ (
+ folder: vscode.WorkspaceFolder | undefined,
+ debugConfiguration: vscode.DebugConfiguration,
+ token?: vscode.CancellationToken,
+ ) => this.resolveDebugConfiguration(folder, debugConfiguration, token),
+ );
+ vscode.commands.registerCommand(
+ "lldb-dap.resolveDebugConfigurationWithSubstitutedVariables",
+ (
+ folder: vscode.WorkspaceFolder | undefined,
+ debugConfiguration: vscode.DebugConfiguration,
+ token?: vscode.CancellationToken,
+ ) =>
+ this.resolveDebugConfigurationWithSubstitutedVariables(
+ folder,
+ debugConfiguration,
+ token,
+ ),
+ );
+ }
async resolveDebugConfiguration(
folder: vscode.WorkspaceFolder | undefined,
diff --git a/lldb/tools/lldb-dap/src-ts/lldb-dap-server.ts b/lldb/tools/lldb-dap/src-ts/lldb-dap-server.ts
index 79573ec7342b1..9ceedeb39b9ed 100644
--- a/lldb/tools/lldb-dap/src-ts/lldb-dap-server.ts
+++ b/lldb/tools/lldb-dap/src-ts/lldb-dap-server.ts
@@ -12,6 +12,13 @@ export class LLDBDapServer implements vscode.Disposable {
private serverProcess?: child_process.ChildProcessWithoutNullStreams;
private serverInfo?: Promise<{ host: string; port: number }>;
+ constructor() {
+ vscode.commands.registerCommand(
+ "lldb-dap.getServerProcess",
+ () => this.serverProcess,
+ );
+ }
+
/**
* Starts the server with the provided options. The server will be restarted or reused as
* necessary.
>From 51b21a43c7c3d958ac11befe23380b04e594fe98 Mon Sep 17 00:00:00 2001
From: Roy Shi <royshi at meta.com>
Date: Tue, 5 Aug 2025 09:44:17 -0700
Subject: [PATCH 2/3] Add text to README.md
---
lldb/tools/lldb-dap/README.md | 21 +++++++++++++++++++++
1 file changed, 21 insertions(+)
diff --git a/lldb/tools/lldb-dap/README.md b/lldb/tools/lldb-dap/README.md
index f88f3ced6f25f..f118366ef9a6a 100644
--- a/lldb/tools/lldb-dap/README.md
+++ b/lldb/tools/lldb-dap/README.md
@@ -372,6 +372,27 @@ for more details on Debug Adapter Protocol events and the VS Code
[debug.onDidReceiveDebugSessionCustomEvent](https://code.visualstudio.com/api/references/vscode-api#debug.onDidReceiveDebugSessionCustomEvent)
API for handling a custom event from an extension.
+## Working with other VS Code debugger extensions
+
+Other VS Code debugger extensions can be used in conjunction with this extension to leverage this extension's settings and logic (e.g. "Server Mode").
+
+When debug sessions are started in other extensions, they can invoke the following VS Code commands to resolve configuration, create adapter descriptor,
+and get the `lldb-dap` process for state tracking, additional interaction, and telemetry.
+
+```
+// Resolve debug configuration
+const resolvedConfiguration = await vscode.commands.executeCommand("lldb-dap.resolveDebugConfiguration", folder, configuration, token);
+
+// Resolve debug configuration with substituted variables
+const resolvedConfigurationWithSubstitutedVariables = await vscode.commands.executeCommand("lldb-dap.resolveDebugConfigurationWithSubstitutedVariables", folder, configuration, token);
+
+// Create debug adapter descriptor
+const adapterDescriptor = await vscode.commands.executeCommand("lldb-dap.createDebugAdapterDescriptor", session, executable);
+
+// Get dap server process
+const process = await vscode.commands.executeCommand("lldb-dap.getServerProcess");
+```
+
## Contributing
`lldb-dap` and `lldb` are developed under the umbrella of the [LLVM project](https://llvm.org/).
>From a105d537d57cd4f69ce28ccee406b4f08c8c2106 Mon Sep 17 00:00:00 2001
From: Roy Shi <royshi at meta.com>
Date: Tue, 5 Aug 2025 11:37:04 -0700
Subject: [PATCH 3/3] Remove the README.md change for now
---
lldb/tools/lldb-dap/README.md | 21 ---------------------
1 file changed, 21 deletions(-)
diff --git a/lldb/tools/lldb-dap/README.md b/lldb/tools/lldb-dap/README.md
index f118366ef9a6a..f88f3ced6f25f 100644
--- a/lldb/tools/lldb-dap/README.md
+++ b/lldb/tools/lldb-dap/README.md
@@ -372,27 +372,6 @@ for more details on Debug Adapter Protocol events and the VS Code
[debug.onDidReceiveDebugSessionCustomEvent](https://code.visualstudio.com/api/references/vscode-api#debug.onDidReceiveDebugSessionCustomEvent)
API for handling a custom event from an extension.
-## Working with other VS Code debugger extensions
-
-Other VS Code debugger extensions can be used in conjunction with this extension to leverage this extension's settings and logic (e.g. "Server Mode").
-
-When debug sessions are started in other extensions, they can invoke the following VS Code commands to resolve configuration, create adapter descriptor,
-and get the `lldb-dap` process for state tracking, additional interaction, and telemetry.
-
-```
-// Resolve debug configuration
-const resolvedConfiguration = await vscode.commands.executeCommand("lldb-dap.resolveDebugConfiguration", folder, configuration, token);
-
-// Resolve debug configuration with substituted variables
-const resolvedConfigurationWithSubstitutedVariables = await vscode.commands.executeCommand("lldb-dap.resolveDebugConfigurationWithSubstitutedVariables", folder, configuration, token);
-
-// Create debug adapter descriptor
-const adapterDescriptor = await vscode.commands.executeCommand("lldb-dap.createDebugAdapterDescriptor", session, executable);
-
-// Get dap server process
-const process = await vscode.commands.executeCommand("lldb-dap.getServerProcess");
-```
-
## Contributing
`lldb-dap` and `lldb` are developed under the umbrella of the [LLVM project](https://llvm.org/).
More information about the lldb-commits
mailing list