about summary refs log tree commit diff
diff options
context:
space:
mode:
authorkouhe3 <25522053+kouhe3@users.noreply.github.com>2024-10-08 17:41:20 +0800
committerkouhe3 <25522053+kouhe3@users.noreply.github.com>2024-10-08 17:43:02 +0800
commit63b0e270fbeedd34b073cc668977f8fea4d3378b (patch)
tree9b682b42873772a2b9d59de95f857350c611b4f2
parent90e3c8885cc53cc0c5be5b27612d82ac5c7c5b38 (diff)
downloadrust-63b0e270fbeedd34b073cc668977f8fea4d3378b.tar.gz
rust-63b0e270fbeedd34b073cc668977f8fea4d3378b.zip
fix array sourceMap
-rw-r--r--src/tools/rust-analyzer/editors/code/src/debug.ts28
1 files changed, 19 insertions, 9 deletions
diff --git a/src/tools/rust-analyzer/editors/code/src/debug.ts b/src/tools/rust-analyzer/editors/code/src/debug.ts
index 933a8c56b21..8966bdf36db 100644
--- a/src/tools/rust-analyzer/editors/code/src/debug.ts
+++ b/src/tools/rust-analyzer/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">;