@@ -6,6 +6,7 @@ import type * as ra from "./lsp_ext";
6
6
import { Cargo } from "./toolchain" ;
7
7
import type { Ctx } from "./ctx" ;
8
8
import { createTaskFromRunnable , prepareEnv } from "./run" ;
9
+ import { execSync } from "node:child_process" ;
9
10
import { execute , isCargoRunnableArgs , unwrapUndefinable } from "./util" ;
10
11
import type { Config } from "./config" ;
11
12
@@ -105,9 +106,11 @@ async function getDebugConfiguration(
105
106
const commandCCpp : string = createCommandLink ( "ms-vscode.cpptools" ) ;
106
107
const commandCodeLLDB : string = createCommandLink ( "vadimcn.vscode-lldb" ) ;
107
108
const commandNativeDebug : string = createCommandLink ( "webfreak.debug" ) ;
109
+ const commandLLDBDap : string = createCommandLink ( "llvm-vs-code-extensions.lldb-dap" ) ;
108
110
109
111
await vscode . window . showErrorMessage (
110
112
`Install [CodeLLDB](command:${ commandCodeLLDB } "Open CodeLLDB")` +
113
+ `, [lldb-dap](command:${ commandLLDBDap } "Open lldb-dap")` +
111
114
`, [C/C++](command:${ commandCCpp } "Open C/C++") ` +
112
115
`or [Native Debug](command:${ commandNativeDebug } "Open Native Debug") for debugging.` ,
113
116
) ;
@@ -220,10 +223,30 @@ type DebugConfigProvider<Type extends string, DebugConfig extends BaseDebugConfi
220
223
221
224
type KnownEnginesType = ( typeof knownEngines ) [ keyof typeof knownEngines ] ;
222
225
const knownEngines : {
226
+ "llvm-vs-code-extensions.lldb-dap" : DebugConfigProvider < "lldb-dap" , LldbDapDebugConfig > ;
223
227
"vadimcn.vscode-lldb" : DebugConfigProvider < "lldb" , CodeLldbDebugConfig > ;
224
228
"ms-vscode.cpptools" : DebugConfigProvider < "cppvsdbg" | "cppdbg" , CCppDebugConfig > ;
225
229
"webfreak.debug" : DebugConfigProvider < "gdb" , NativeDebugConfig > ;
226
230
} = {
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
+ } ,
227
250
"vadimcn.vscode-lldb" : {
228
251
type : "lldb" ,
229
252
executableProperty : "program" ,
@@ -336,6 +359,13 @@ type CCppDebugConfig = {
336
359
} ;
337
360
} & BaseDebugConfig < "cppvsdbg" | "cppdbg" > ;
338
361
362
+ type LldbDapDebugConfig = {
363
+ program : string ;
364
+ args : string [ ] ;
365
+ env : string [ ] ;
366
+ sourceMap : [ string , string ] [ ] ;
367
+ } & BaseDebugConfig < "lldb-dap" > ;
368
+
339
369
type CodeLldbDebugConfig = {
340
370
program : string ;
341
371
args : string [ ] ;
0 commit comments