mirror of
https://github.com/intel/llvm.git
synced 2026-01-13 11:02:04 +08:00
[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`
This commit is contained in:
@@ -170,3 +170,26 @@ This is also very simple, just run:
|
||||
```bash
|
||||
npm run format
|
||||
```
|
||||
|
||||
## Working with the VS Code extension from another extension
|
||||
|
||||
The VS Code extension exposes the following [VS Code
|
||||
commands](https://code.visualstudio.com/api/extension-guides/command),
|
||||
which can be invoked by other debugger extensions to leverage this extension's
|
||||
settings and logic. The commands help 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");
|
||||
```
|
||||
|
||||
@@ -217,7 +217,15 @@ export class LLDBDapDescriptorFactory
|
||||
constructor(
|
||||
private readonly logger: vscode.LogOutputChannel,
|
||||
private logFilePath: LogFilePathProvider,
|
||||
) {}
|
||||
) {
|
||||
vscode.commands.registerCommand(
|
||||
"lldb-dap.createDebugAdapterDescriptor",
|
||||
(
|
||||
session: vscode.DebugSession,
|
||||
executable: vscode.DebugAdapterExecutable | undefined,
|
||||
) => this.createDebugAdapterDescriptor(session, executable),
|
||||
);
|
||||
}
|
||||
|
||||
async createDebugAdapterDescriptor(
|
||||
session: vscode.DebugSession,
|
||||
|
||||
@@ -76,7 +76,29 @@ export class LLDBDapConfigurationProvider
|
||||
private readonly server: LLDBDapServer,
|
||||
private readonly logger: vscode.LogOutputChannel,
|
||||
private readonly logFilePath: LogFilePathProvider,
|
||||
) {}
|
||||
) {
|
||||
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,
|
||||
|
||||
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user