From 48d6e828f1878436bb8633a1e7df02a6383d991a Mon Sep 17 00:00:00 2001 From: vsrs Date: Tue, 28 Apr 2020 17:30:49 +0300 Subject: ms-vscode.cpptools debugger support, initial version. --- editors/code/src/commands/runnables.ts | 47 +++++++++++++++++++++++++--------- 1 file changed, 35 insertions(+), 12 deletions(-) (limited to 'editors/code/src/commands') diff --git a/editors/code/src/commands/runnables.ts b/editors/code/src/commands/runnables.ts index 2635a1440..26db18156 100644 --- a/editors/code/src/commands/runnables.ts +++ b/editors/code/src/commands/runnables.ts @@ -3,6 +3,7 @@ import * as lc from 'vscode-languageclient'; import * as ra from '../rust-analyzer-api'; import { Ctx, Cmd } from '../ctx'; +import { Cargo } from '../cargo'; export function run(ctx: Ctx): Cmd { let prevRunnable: RunnableQuickPick | undefined; @@ -62,25 +63,47 @@ export function runSingle(ctx: Ctx): Cmd { }; } +function getLldbDebugConfig(config: ra.Runnable) : vscode.DebugConfiguration { + return { + type: "lldb", + request: "launch", + name: config.label, + cargo: { + args: config.args, + }, + args: config.extraArgs, + cwd: config.cwd + }; +} + +async function getCppvsDebugConfig(config: ra.Runnable) : Promise { + let cargo = new Cargo(config.cwd || '.'); + let executable = await cargo.executableFromArgs(config.args, config.extraArgs); + + return { + type: "cppvsdbg", + request: "launch", + name: config.label, + program: executable, + args: config.extraArgs, + cwd: config.cwd, + }; +} + export function debugSingle(ctx: Ctx): Cmd { return async (config: ra.Runnable) => { const editor = ctx.activeRustEditor; if (!editor) return; - if (!vscode.extensions.getExtension("vadimcn.vscode-lldb")) { - vscode.window.showErrorMessage("Install `vadimcn.vscode-lldb` extension for debugging"); + + const mscpp = vscode.extensions.getExtension("ms-vscode.cpptools"); + const lldb = vscode.extensions.getExtension("vadimcn.vscode-lldb"); + + if (!(lldb || mscpp)) { + vscode.window.showErrorMessage("Install `vadimcn.vscode-lldb` or `ms-vscode.cpptools` extension for debugging"); return; } - const debugConfig = { - type: "lldb", - request: "launch", - name: config.label, - cargo: { - args: config.args, - }, - args: config.extraArgs, - cwd: config.cwd - }; + const debugConfig = lldb ? getLldbDebugConfig(config) : await getCppvsDebugConfig(config); return vscode.debug.startDebugging(undefined, debugConfig); }; -- cgit v1.2.3 From 042917e6e3bc3cb05e08e487ee8a7d0d4ae3af6b Mon Sep 17 00:00:00 2001 From: vsrs Date: Wed, 29 Apr 2020 13:10:42 +0300 Subject: Configuration settings and source maps support --- editors/code/src/commands/runnables.ts | 33 +++++++++++++++++++++++++-------- 1 file changed, 25 insertions(+), 8 deletions(-) (limited to 'editors/code/src/commands') diff --git a/editors/code/src/commands/runnables.ts b/editors/code/src/commands/runnables.ts index 26db18156..befb8b366 100644 --- a/editors/code/src/commands/runnables.ts +++ b/editors/code/src/commands/runnables.ts @@ -63,7 +63,7 @@ export function runSingle(ctx: Ctx): Cmd { }; } -function getLldbDebugConfig(config: ra.Runnable) : vscode.DebugConfiguration { +function getLldbDebugConfig(config: ra.Runnable, sourceFileMap: Record): vscode.DebugConfiguration { return { type: "lldb", request: "launch", @@ -72,11 +72,12 @@ function getLldbDebugConfig(config: ra.Runnable) : vscode.DebugConfiguration { args: config.args, }, args: config.extraArgs, - cwd: config.cwd + cwd: config.cwd, + sourceMap: sourceFileMap }; } -async function getCppvsDebugConfig(config: ra.Runnable) : Promise { +async function getCppvsDebugConfig(config: ra.Runnable, sourceFileMap: Record): Promise { let cargo = new Cargo(config.cwd || '.'); let executable = await cargo.executableFromArgs(config.args, config.extraArgs); @@ -87,6 +88,7 @@ async function getCppvsDebugConfig(config: ra.Runnable) : Promise Date: Wed, 29 Apr 2020 14:13:57 +0300 Subject: better configuration enum items --- editors/code/src/commands/runnables.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'editors/code/src/commands') diff --git a/editors/code/src/commands/runnables.ts b/editors/code/src/commands/runnables.ts index befb8b366..2238a5a73 100644 --- a/editors/code/src/commands/runnables.ts +++ b/editors/code/src/commands/runnables.ts @@ -102,7 +102,7 @@ export function debugSingle(ctx: Ctx): Cmd { let debugEngineId = ctx.config.debug.engine; let debugEngine = null; - if (!debugEngineId) { + if ( debugEngineId === "auto" ) { debugEngine = vscode.extensions.getExtension(lldbId); if (!debugEngine) { debugEngine = vscode.extensions.getExtension(cpptoolsId); -- cgit v1.2.3 From 73a1947d19b4d3c29aa462e856e3d410d6e1e5dd Mon Sep 17 00:00:00 2001 From: vsrs Date: Wed, 29 Apr 2020 16:52:53 +0300 Subject: MS C++ tools on linux --- editors/code/src/commands/runnables.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'editors/code/src/commands') diff --git a/editors/code/src/commands/runnables.ts b/editors/code/src/commands/runnables.ts index 2238a5a73..9b0780650 100644 --- a/editors/code/src/commands/runnables.ts +++ b/editors/code/src/commands/runnables.ts @@ -1,6 +1,7 @@ import * as vscode from 'vscode'; import * as lc from 'vscode-languageclient'; import * as ra from '../rust-analyzer-api'; +import * as os from "os"; import { Ctx, Cmd } from '../ctx'; import { Cargo } from '../cargo'; @@ -82,7 +83,7 @@ async function getCppvsDebugConfig(config: ra.Runnable, sourceFileMap: Record Date: Thu, 30 Apr 2020 15:25:04 +0300 Subject: pass Cargo errors to the Debug output channel --- editors/code/src/commands/runnables.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'editors/code/src/commands') diff --git a/editors/code/src/commands/runnables.ts b/editors/code/src/commands/runnables.ts index 9b0780650..e8035c7d2 100644 --- a/editors/code/src/commands/runnables.ts +++ b/editors/code/src/commands/runnables.ts @@ -78,10 +78,15 @@ function getLldbDebugConfig(config: ra.Runnable, sourceFileMap: Record): Promise { - let cargo = new Cargo(config.cwd || '.'); + debugOutput.clear(); + + let cargo = new Cargo(config.cwd || '.', debugOutput); let executable = await cargo.executableFromArgs(config.args, config.extraArgs); + // if we are here, there were no compilation errors. return { type: (os.platform() === "win32") ? "cppvsdbg" : 'cppdbg', request: "launch", -- cgit v1.2.3 From 10836543d693675a9a2fd90130b1a816ede90fea Mon Sep 17 00:00:00 2001 From: vsrs Date: Thu, 30 Apr 2020 18:41:48 +0300 Subject: Fixed tsfmt and eslint errors. --- editors/code/src/commands/runnables.ts | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'editors/code/src/commands') diff --git a/editors/code/src/commands/runnables.ts b/editors/code/src/commands/runnables.ts index e8035c7d2..36d309334 100644 --- a/editors/code/src/commands/runnables.ts +++ b/editors/code/src/commands/runnables.ts @@ -82,9 +82,9 @@ const debugOutput = vscode.window.createOutputChannel("Debug"); async function getCppvsDebugConfig(config: ra.Runnable, sourceFileMap: Record): Promise { debugOutput.clear(); - - let cargo = new Cargo(config.cwd || '.', debugOutput); - let executable = await cargo.executableFromArgs(config.args, config.extraArgs); + + const cargo = new Cargo(config.cwd || '.', debugOutput); + const executable = await cargo.executableFromArgs(config.args, config.extraArgs); // if we are here, there were no compilation errors. return { @@ -106,9 +106,9 @@ export function debugSingle(ctx: Ctx): Cmd { const lldbId = "vadimcn.vscode-lldb"; const cpptoolsId = "ms-vscode.cpptools"; - let debugEngineId = ctx.config.debug.engine; + const debugEngineId = ctx.config.debug.engine; let debugEngine = null; - if ( debugEngineId === "auto" ) { + if (debugEngineId === "auto") { debugEngine = vscode.extensions.getExtension(lldbId); if (!debugEngine) { debugEngine = vscode.extensions.getExtension(cpptoolsId); @@ -120,11 +120,11 @@ export function debugSingle(ctx: Ctx): Cmd { if (!debugEngine) { vscode.window.showErrorMessage(`Install [CodeLLDB](https://marketplace.visualstudio.com/items?itemName=${lldbId})` - + ` or [MS C++ tools](https://marketplace.visualstudio.com/items?itemName=${cpptoolsId}) extension for debugging.`); + + ` or [MS C++ tools](https://marketplace.visualstudio.com/items?itemName=${cpptoolsId}) extension for debugging.`); return; } - const debugConfig = lldbId == debugEngine.id + const debugConfig = lldbId === debugEngine.id ? getLldbDebugConfig(config, ctx.config.debug.sourceFileMap) : await getCppvsDebugConfig(config, ctx.config.debug.sourceFileMap); -- cgit v1.2.3 From 11e9e4b1fb48fb24a206c65c43fb374fe57dc26f Mon Sep 17 00:00:00 2001 From: vsrs Date: Thu, 30 Apr 2020 18:53:34 +0300 Subject: Removed unnecessary extraArgs for cargo invocation --- editors/code/src/commands/runnables.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'editors/code/src/commands') diff --git a/editors/code/src/commands/runnables.ts b/editors/code/src/commands/runnables.ts index 36d309334..d77e8188c 100644 --- a/editors/code/src/commands/runnables.ts +++ b/editors/code/src/commands/runnables.ts @@ -84,7 +84,7 @@ async function getCppvsDebugConfig(config: ra.Runnable, sourceFileMap: Record