@@ -6,6 +6,7 @@ import type * as ra from "./lsp_ext";
66import { Cargo } from "./toolchain" ;
77import type { Ctx } from "./ctx" ;
88import { createTaskFromRunnable , prepareEnv } from "./run" ;
9+ import { execSync } from "node:child_process" ;
910import { execute , isCargoRunnableArgs , unwrapUndefinable } from "./util" ;
1011import 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
221224type KnownEnginesType = ( typeof knownEngines ) [ keyof typeof knownEngines ] ;
222225const 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/${ / c o m m i t - h a s h : \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+
339369type CodeLldbDebugConfig = {
340370 program : string ;
341371 args : string [ ] ;
0 commit comments