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

1 file changed

Lines changed: 30 additions & 0 deletions

File tree

  • src/tools/rust-analyzer/editors/code/src

‎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
importtype{Ctx}from"./ctx";
88
import{createTaskFromRunnable,prepareEnv}from"./run";
9+
import{execSync}from"node:child_process";
910
import{execute,isCargoRunnableArgs,unwrapUndefinable}from"./util";
1011
importtype{Config}from"./config";
1112

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

109111
awaitvscode.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
typeKnownEnginesType=(typeofknownEngines)[keyoftypeofknownEngines];
222225
constknownEngines: {
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+
typeLldbDapDebugConfig={
363+
program: string;
364+
args: string[];
365+
env: string[];
366+
sourceMap: [string,string][];
367+
}&BaseDebugConfig<"lldb-dap">;
368+
339369
typeCodeLldbDebugConfig={
340370
program: string;
341371
args: string[];

0 commit comments

Comments
 (0)