Skip to content

Commit a4df972

Browse files
committed
Auto merge of #18265 - kouhe3:master, r=Veykril
Add support for LLDB-DAP
2 parents b85026b + a2304ba commit a4df972

File tree

1 file changed

+30
-0
lines changed
  • src/tools/rust-analyzer/editors/code/src

1 file changed

+30
-0
lines changed

src/tools/rust-analyzer/editors/code/src/debug.ts

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import type * as ra from "./lsp_ext";
66
import { Cargo } from "./toolchain";
77
import type { Ctx } from "./ctx";
88
import { createTaskFromRunnable, prepareEnv } from "./run";
9+
import { execSync } from "node:child_process";
910
import { execute, isCargoRunnableArgs, unwrapUndefinable } from "./util";
1011
import type { Config } from "./config";
1112

@@ -105,9 +106,11 @@ async function getDebugConfiguration(
105106
const commandCCpp: string = createCommandLink("ms-vscode.cpptools");
106107
const commandCodeLLDB: string = createCommandLink("vadimcn.vscode-lldb");
107108
const commandNativeDebug: string = createCommandLink("webfreak.debug");
109+
const commandLLDBDap: string = createCommandLink("llvm-vs-code-extensions.lldb-dap");
108110

109111
await vscode.window.showErrorMessage(
110112
`Install [CodeLLDB](command:${commandCodeLLDB} "Open CodeLLDB")` +
113+
`, [lldb-dap](command:${commandLLDBDap} "Open lldb-dap")` +
111114
`, [C/C++](command:${commandCCpp} "Open C/C++") ` +
112115
`or [Native Debug](command:${commandNativeDebug} "Open Native Debug") for debugging.`,
113116
);
@@ -220,10 +223,30 @@ type DebugConfigProvider<Type extends string, DebugConfig extends BaseDebugConfi
220223

221224
type KnownEnginesType = (typeof knownEngines)[keyof typeof knownEngines];
222225
const knownEngines: {
226+
"llvm-vs-code-extensions.lldb-dap": DebugConfigProvider<"lldb-dap", LldbDapDebugConfig>;
223227
"vadimcn.vscode-lldb": DebugConfigProvider<"lldb", CodeLldbDebugConfig>;
224228
"ms-vscode.cpptools": DebugConfigProvider<"cppvsdbg" | "cppdbg", CCppDebugConfig>;
225229
"webfreak.debug": DebugConfigProvider<"gdb", NativeDebugConfig>;
226230
} = {
231+
"llvm-vs-code-extensions.lldb-dap": {
232+
type: "lldb-dap",
233+
executableProperty: "program",
234+
environmentProperty: (env) => ["env", Object.entries(env).map(([k, v]) => `${k}=${v}`)],
235+
runnableArgsProperty: (runnableArgs: ra.CargoRunnableArgs) => [
236+
"args",
237+
runnableArgs.executableArgs,
238+
],
239+
additional: {
240+
sourceMap: [
241+
[
242+
`/rustc/${/commit-hash:\s(.*)$/m.exec(
243+
execSync("rustc -V -v", {}).toString(),
244+
)?.[1]}/library`,
245+
"${config:rust-analyzer.cargo.sysroot}/lib/rustlib/src/rust/library",
246+
],
247+
],
248+
},
249+
},
227250
"vadimcn.vscode-lldb": {
228251
type: "lldb",
229252
executableProperty: "program",
@@ -336,6 +359,13 @@ type CCppDebugConfig = {
336359
};
337360
} & BaseDebugConfig<"cppvsdbg" | "cppdbg">;
338361

362+
type LldbDapDebugConfig = {
363+
program: string;
364+
args: string[];
365+
env: string[];
366+
sourceMap: [string, string][];
367+
} & BaseDebugConfig<"lldb-dap">;
368+
339369
type CodeLldbDebugConfig = {
340370
program: string;
341371
args: string[];

0 commit comments

Comments
 (0)