From 85caf88b54bfef44a5057abbe4de3631b670ef4e Mon Sep 17 00:00:00 2001 From: kouhe3 <25522053+kouhe3@users.noreply.github.com> Date: Tue, 8 Oct 2024 00:22:58 +0800 Subject: [PATCH 1/5] add knownEngines lldb-dap --- editors/code/src/debug.ts | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/editors/code/src/debug.ts b/editors/code/src/debug.ts index fb7e340e51..8ccc80b2be 100644 --- a/editors/code/src/debug.ts +++ b/editors/code/src/debug.ts @@ -105,9 +105,11 @@ async function getDebugConfiguration( const commandCCpp: string = createCommandLink("ms-vscode.cpptools"); const commandCodeLLDB: string = createCommandLink("vadimcn.vscode-lldb"); const commandNativeDebug: string = createCommandLink("webfreak.debug"); + const commandLLDBDap: string = createCommandLink("llvm-vs-code-extensions.lldb-dap"); await vscode.window.showErrorMessage( `Install [CodeLLDB](command:${commandCodeLLDB} "Open CodeLLDB")` + + `, [lldb-dap](command:${commandLLDBDap} "Open lldb-dap")` + `, [C/C++](command:${commandCCpp} "Open C/C++") ` + `or [Native Debug](command:${commandNativeDebug} "Open Native Debug") for debugging.`, ); @@ -220,10 +222,21 @@ type DebugConfigProvider; "vadimcn.vscode-lldb": DebugConfigProvider<"lldb", CodeLldbDebugConfig>; "ms-vscode.cpptools": DebugConfigProvider<"cppvsdbg" | "cppdbg", CCppDebugConfig>; "webfreak.debug": DebugConfigProvider<"gdb", NativeDebugConfig>; } = { + "llvm-vs-code-extensions.lldb-dap":{ + type: "lldb-dap", + executableProperty: "program", + environmentProperty: (env) => ["env", env], + runnableArgsProperty: (runnableArgs: ra.CargoRunnableArgs) => [ + "args", + runnableArgs.executableArgs, + ], + +}, "vadimcn.vscode-lldb": { type: "lldb", executableProperty: "program", @@ -336,6 +349,13 @@ type CCppDebugConfig = { }; } & BaseDebugConfig<"cppvsdbg" | "cppdbg">; +type LldbDapDebugConfig = { + program: string; + args: string[]; + env: Record; +} & BaseDebugConfig<"lldb-dap">; + + type CodeLldbDebugConfig = { program: string; args: string[]; From 82b114dbf028e74e726efbdc047a3fcd28da70ee Mon Sep 17 00:00:00 2001 From: kouhe3 <25522053+kouhe3@users.noreply.github.com> Date: Tue, 8 Oct 2024 15:11:31 +0800 Subject: [PATCH 2/5] lldbdap env dict to string --- editors/code/src/debug.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/editors/code/src/debug.ts b/editors/code/src/debug.ts index 8ccc80b2be..933a8c56b2 100644 --- a/editors/code/src/debug.ts +++ b/editors/code/src/debug.ts @@ -230,7 +230,7 @@ const knownEngines: { "llvm-vs-code-extensions.lldb-dap":{ type: "lldb-dap", executableProperty: "program", - environmentProperty: (env) => ["env", env], + environmentProperty: (env) => ["env", Object.entries(env).map(([k,v])=>`${k}=${v}`)], runnableArgsProperty: (runnableArgs: ra.CargoRunnableArgs) => [ "args", runnableArgs.executableArgs, @@ -352,7 +352,8 @@ type CCppDebugConfig = { type LldbDapDebugConfig = { program: string; args: string[]; - env: Record; + env: string[]; + sourceMap: [string,string][]; } & BaseDebugConfig<"lldb-dap">; From 64caa6bbf1e13093f1b84deb9bd6b788e8cc4b2d Mon Sep 17 00:00:00 2001 From: kouhe3 <25522053+kouhe3@users.noreply.github.com> Date: Tue, 8 Oct 2024 17:41:20 +0800 Subject: [PATCH 3/5] fix array sourceMap --- editors/code/src/debug.ts | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/editors/code/src/debug.ts b/editors/code/src/debug.ts index 933a8c56b2..8966bdf36d 100644 --- a/editors/code/src/debug.ts +++ b/editors/code/src/debug.ts @@ -6,6 +6,7 @@ import type * as ra from "./lsp_ext"; import { Cargo } from "./toolchain"; import type { Ctx } from "./ctx"; import { createTaskFromRunnable, prepareEnv } from "./run"; +import { execSync } from 'node:child_process' import { execute, isCargoRunnableArgs, unwrapUndefinable } from "./util"; import type { Config } from "./config"; @@ -109,9 +110,9 @@ async function getDebugConfiguration( await vscode.window.showErrorMessage( `Install [CodeLLDB](command:${commandCodeLLDB} "Open CodeLLDB")` + - `, [lldb-dap](command:${commandLLDBDap} "Open lldb-dap")` + - `, [C/C++](command:${commandCCpp} "Open C/C++") ` + - `or [Native Debug](command:${commandNativeDebug} "Open Native Debug") for debugging.`, + `, [lldb-dap](command:${commandLLDBDap} "Open lldb-dap")` + + `, [C/C++](command:${commandCCpp} "Open C/C++") ` + + `or [Native Debug](command:${commandNativeDebug} "Open Native Debug") for debugging.`, ); return; } @@ -129,7 +130,7 @@ async function getDebugConfiguration( !isMultiFolderWorkspace || !runnableArgs.workspaceRoot ? firstWorkspace : workspaceFolders.find((w) => runnableArgs.workspaceRoot?.includes(w.uri.fsPath)) || - firstWorkspace; + firstWorkspace; const workspace = unwrapUndefinable(maybeWorkspace); let wsFolder = path.normalize(workspace.uri.fsPath); @@ -227,16 +228,25 @@ const knownEngines: { "ms-vscode.cpptools": DebugConfigProvider<"cppvsdbg" | "cppdbg", CCppDebugConfig>; "webfreak.debug": DebugConfigProvider<"gdb", NativeDebugConfig>; } = { - "llvm-vs-code-extensions.lldb-dap":{ + "llvm-vs-code-extensions.lldb-dap": { type: "lldb-dap", executableProperty: "program", - environmentProperty: (env) => ["env", Object.entries(env).map(([k,v])=>`${k}=${v}`)], + environmentProperty: (env) => ["env", Object.entries(env).map(([k, v]) => `${k}=${v}`)], runnableArgsProperty: (runnableArgs: ra.CargoRunnableArgs) => [ "args", runnableArgs.executableArgs, ], + additional: { + "sourceMap": [ + [ + `/rustc/${/commit-hash:\s(.*)$/m.exec(execSync("rustc -V -v", {}).toString())?.[1] + }/library`, + "${config:rust-analyzer.cargo.sysroot}/lib/rustlib/src/rust/library" -}, + ] + ] + } + }, "vadimcn.vscode-lldb": { type: "lldb", executableProperty: "program", @@ -353,7 +363,7 @@ type LldbDapDebugConfig = { program: string; args: string[]; env: string[]; - sourceMap: [string,string][]; + sourceMap: [string, string][]; } & BaseDebugConfig<"lldb-dap">; From e9c8a84a35c488de88f41857d9dac4d8a9d9cead Mon Sep 17 00:00:00 2001 From: kouhe3 <25522053+kouhe3@users.noreply.github.com> Date: Tue, 8 Oct 2024 17:47:54 +0800 Subject: [PATCH 4/5] semicolon --- editors/code/src/debug.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/editors/code/src/debug.ts b/editors/code/src/debug.ts index 8966bdf36d..0114edf689 100644 --- a/editors/code/src/debug.ts +++ b/editors/code/src/debug.ts @@ -6,7 +6,7 @@ import type * as ra from "./lsp_ext"; import { Cargo } from "./toolchain"; import type { Ctx } from "./ctx"; import { createTaskFromRunnable, prepareEnv } from "./run"; -import { execSync } from 'node:child_process' +import { execSync } from 'node:child_process'; import { execute, isCargoRunnableArgs, unwrapUndefinable } from "./util"; import type { Config } from "./config"; From 9a207be986ad08ffb01e52511e65671bb7dc7313 Mon Sep 17 00:00:00 2001 From: kouhe3 <25522053+kouhe3@users.noreply.github.com> Date: Tue, 8 Oct 2024 17:50:29 +0800 Subject: [PATCH 5/5] prettier format --- editors/code/src/debug.ts | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/editors/code/src/debug.ts b/editors/code/src/debug.ts index 0114edf689..77ab44f24c 100644 --- a/editors/code/src/debug.ts +++ b/editors/code/src/debug.ts @@ -6,7 +6,7 @@ import type * as ra from "./lsp_ext"; import { Cargo } from "./toolchain"; import type { Ctx } from "./ctx"; import { createTaskFromRunnable, prepareEnv } from "./run"; -import { execSync } from 'node:child_process'; +import { execSync } from "node:child_process"; import { execute, isCargoRunnableArgs, unwrapUndefinable } from "./util"; import type { Config } from "./config"; @@ -110,9 +110,9 @@ async function getDebugConfiguration( await vscode.window.showErrorMessage( `Install [CodeLLDB](command:${commandCodeLLDB} "Open CodeLLDB")` + - `, [lldb-dap](command:${commandLLDBDap} "Open lldb-dap")` + - `, [C/C++](command:${commandCCpp} "Open C/C++") ` + - `or [Native Debug](command:${commandNativeDebug} "Open Native Debug") for debugging.`, + `, [lldb-dap](command:${commandLLDBDap} "Open lldb-dap")` + + `, [C/C++](command:${commandCCpp} "Open C/C++") ` + + `or [Native Debug](command:${commandNativeDebug} "Open Native Debug") for debugging.`, ); return; } @@ -130,7 +130,7 @@ async function getDebugConfiguration( !isMultiFolderWorkspace || !runnableArgs.workspaceRoot ? firstWorkspace : workspaceFolders.find((w) => runnableArgs.workspaceRoot?.includes(w.uri.fsPath)) || - firstWorkspace; + firstWorkspace; const workspace = unwrapUndefinable(maybeWorkspace); let wsFolder = path.normalize(workspace.uri.fsPath); @@ -237,15 +237,15 @@ const knownEngines: { runnableArgs.executableArgs, ], additional: { - "sourceMap": [ + sourceMap: [ [ - `/rustc/${/commit-hash:\s(.*)$/m.exec(execSync("rustc -V -v", {}).toString())?.[1] - }/library`, - "${config:rust-analyzer.cargo.sysroot}/lib/rustlib/src/rust/library" - - ] - ] - } + `/rustc/${/commit-hash:\s(.*)$/m.exec( + execSync("rustc -V -v", {}).toString(), + )?.[1]}/library`, + "${config:rust-analyzer.cargo.sysroot}/lib/rustlib/src/rust/library", + ], + ], + }, }, "vadimcn.vscode-lldb": { type: "lldb", @@ -366,7 +366,6 @@ type LldbDapDebugConfig = { sourceMap: [string, string][]; } & BaseDebugConfig<"lldb-dap">; - type CodeLldbDebugConfig = { program: string; args: string[];