From aad77258686e4f47cab7deb028739d8ea541a0e8 Mon Sep 17 00:00:00 2001 From: Andrew Wang Date: Wed, 13 Jan 2021 16:32:17 -0800 Subject: [PATCH 1/5] Add new "console" launch config for vsdbg This PR adds new console support for the cppvsdbg debug type. This removes the legacy 'externalConsole' flag with 'console'. Console has four enums: - internalConsole: Output to the VS Code Debug Console. This doesn't support reading console input (ex:Console.ReadLine) - integratedTerminal: VS Code's integrated terminal - externalTerminal: External terminal that can be configured via user settings - newExternalWindow: Console applications will be launched in their own external console window which will end when the application stops. Non-console applications will run without a terminal, and stdout/stderr will be ignored. --- Extension/package.json | 24 ++++++++++++++----- Extension/package.nls.json | 6 ++++- .../src/Debugger/configurationProvider.ts | 8 ++++++- Extension/src/Debugger/configurations.ts | 2 +- Extension/tools/OptionsSchema.json | 20 ++++++++++++---- 5 files changed, 47 insertions(+), 13 deletions(-) diff --git a/Extension/package.json b/Extension/package.json index 8e67ba22a1..9d097a9bc2 100644 --- a/Extension/package.json +++ b/Extension/package.json @@ -1984,10 +1984,22 @@ "description": "%c_cpp.debuggers.cppvsdbg.visualizerFile.description%", "default": "" }, - "externalConsole": { - "type": "boolean", - "description": "%c_cpp.debuggers.cppvsdbg.externalConsole.description%", - "default": false + "console": { + "type": "string", + "enum": [ + "internalConsole", + "integratedTerminal", + "externalTerminal", + "newExternalWindow" + ], + "enumDescriptions": [ + "%c_cpp.debuggers.cppvsdbg.console.internalConsole.description%", + "%c_cpp.debuggers.cppvsdbg.console.integratedTerminal.description%", + "%c_cpp.debuggers.cppvsdbg.console.externalTerminal.description%", + "%c_cpp.debuggers.cppvsdbg.console.newExternalWindow.description%" + ], + "description": "%c_cpp.debuggers.cppvsdbg.console.description%", + "default": "internalConsole" }, "sourceFileMap": { "type": "object", @@ -2730,7 +2742,7 @@ }, { "description": "Visual Studio Windows Debugger", - "url": "https://go.microsoft.com/fwlink/?linkid=2152353", + "url": "https://go.microsoft.com/fwlink/?linkid=2153010", "platforms": [ "win32" ], @@ -2741,7 +2753,7 @@ "binaries": [ "./debugAdapters/vsdbg/bin/vsdbg.exe" ], - "integrity": "8299A112D1260C2CEA53AC74D18FA73DE8533C058AAAB254571B503FBAC37297" + "integrity": "52C4234976D527A7BF02EB2E8844F3C605DC4BD1D3847F83C8675CD23967BAB3" } ] } diff --git a/Extension/package.nls.json b/Extension/package.nls.json index 6e155b04d3..d1a1db824e 100644 --- a/Extension/package.nls.json +++ b/Extension/package.nls.json @@ -213,7 +213,11 @@ "c_cpp.debuggers.serverLaunchTimeout.description": "Optional time, in milliseconds, for the debugger to wait for the debugServer to start up. Default is 10000.", "c_cpp.debuggers.coreDumpPath.description": "Optional full path to a core dump file for the specified program. Defaults to null.", "c_cpp.debuggers.cppdbg.externalConsole.description": "If true, a console is launched for the debuggee. If false, on Linux and Windows, it will appear in the Integrated Console.", - "c_cpp.debuggers.cppvsdbg.externalConsole.description": "If true, a console is launched for the debuggee. If false, no console is launched.", + "c_cpp.debuggers.cppvsdbg.console.description": "Where to launch the debug target.", + "c_cpp.debuggers.cppvsdbg.console.internalConsole.description": "Output to the VS Code Debug Console. This doesn't support reading console input (ex:Console.ReadLine)", + "c_cpp.debuggers.cppvsdbg.console.integratedTerminal.description": "VS Code's integrated terminal", + "c_cpp.debuggers.cppvsdbg.console.externalTerminal.description": "External terminal that can be configured via user settings", + "c_cpp.debuggers.cppvsdbg.console.newExternalWindow.description": "Console applications will be launched in their own external console window which will end when the application stops. Non-console applications will run without a terminal, and stdout/stderr will be ignored.", "c_cpp.debuggers.avoidWindowsConsoleRedirection.description": "If true, disables debuggee console redirection that is required for Integrated Terminal support.", "c_cpp.debuggers.sourceFileMap.description": "Optional source file mappings passed to the debug engine. Example: '{ \"/original/source/path\":\"/current/source/path\" }'", "c_cpp.debuggers.processId.anyOf.description": "Optional process id to attach the debugger to. Use \"${command:pickProcess}\" to get a list of local running processes to attach to. Note that some platforms require administrator privileges in order to attach to a process.", diff --git a/Extension/src/Debugger/configurationProvider.ts b/Extension/src/Debugger/configurationProvider.ts index 0c0eef308a..e1a20d7059 100644 --- a/Extension/src/Debugger/configurationProvider.ts +++ b/Extension/src/Debugger/configurationProvider.ts @@ -182,7 +182,7 @@ class CppConfigurationProvider implements vscode.DebugConfigurationProvider { newConfig.name = compilerName + buildAndDebugActiveFileStr(); newConfig.preLaunchTask = task.name; - newConfig.externalConsole = false; + newConfig.console = "internalConsole" const exeName: string = path.join("${fileDirname}", "${fileBasenameNoExtension}"); const isWindows: boolean = platform === 'win32'; newConfig.program = isWindows ? exeName + ".exe" : exeName; @@ -246,6 +246,12 @@ class CppConfigurationProvider implements vscode.DebugConfigurationProvider { } if (config.type === 'cppvsdbg') { + // Handle legacy 'externalConsole' bool and convert to console: "externalTerminal" + if (config.externalConsole && !config.console) + { + config.console = "externalTerminal" + } + // Fail if cppvsdbg type is running on non-Windows if (os.platform() !== 'win32') { logger.getOutputChannelLogger().showWarningMessage(localize("debugger.not.available", "Debugger of type: '{0}' is only available on Windows. Use type: '{1}' on the current OS platform.", "cppvsdbg", "cppdbg")); diff --git a/Extension/src/Debugger/configurations.ts b/Extension/src/Debugger/configurations.ts index 5ed3a0c17a..ef26979bf7 100644 --- a/Extension/src/Debugger/configurations.ts +++ b/Extension/src/Debugger/configurations.ts @@ -44,7 +44,7 @@ function createLaunchString(name: string, type: string, executable: string): str "stopAtEntry": false, "cwd": "$\{workspaceFolder\}", "environment": [], -"externalConsole": false +"console": "internalConsole" `; } diff --git a/Extension/tools/OptionsSchema.json b/Extension/tools/OptionsSchema.json index 1cee13b3ef..16dab90641 100644 --- a/Extension/tools/OptionsSchema.json +++ b/Extension/tools/OptionsSchema.json @@ -541,10 +541,22 @@ "description": "%c_cpp.debuggers.cppvsdbg.visualizerFile.description%", "default": "" }, - "externalConsole": { - "type": "boolean", - "description": "%c_cpp.debuggers.cppvsdbg.externalConsole.description%", - "default": false + "console": { + "type": "string", + "enum": [ + "internalConsole", + "integratedTerminal", + "externalTerminal", + "newExternalWindow" + ], + "enumDescriptions": [ + "%c_cpp.debuggers.cppvsdbg.console.internalConsole.description%", + "%c_cpp.debuggers.cppvsdbg.console.integratedTerminal.description%", + "%c_cpp.debuggers.cppvsdbg.console.externalTerminal.description%", + "%c_cpp.debuggers.cppvsdbg.console.newExternalWindow.description%" + ], + "description": "%c_cpp.debuggers.cppvsdbg.console.description%", + "default": "internalConsole" }, "sourceFileMap": { "type": "object", From ac98f7800933830d0cb88918b8ca941e08dd5d33 Mon Sep 17 00:00:00 2001 From: Andrew Wang Date: Fri, 15 Jan 2021 13:48:59 -0800 Subject: [PATCH 2/5] Fix linter errors --- Extension/src/Debugger/configurationProvider.ts | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/Extension/src/Debugger/configurationProvider.ts b/Extension/src/Debugger/configurationProvider.ts index e1a20d7059..4e09423daa 100644 --- a/Extension/src/Debugger/configurationProvider.ts +++ b/Extension/src/Debugger/configurationProvider.ts @@ -182,7 +182,7 @@ class CppConfigurationProvider implements vscode.DebugConfigurationProvider { newConfig.name = compilerName + buildAndDebugActiveFileStr(); newConfig.preLaunchTask = task.name; - newConfig.console = "internalConsole" + newConfig.console = "internalConsole"; const exeName: string = path.join("${fileDirname}", "${fileBasenameNoExtension}"); const isWindows: boolean = platform === 'win32'; newConfig.program = isWindows ? exeName + ".exe" : exeName; @@ -247,9 +247,8 @@ class CppConfigurationProvider implements vscode.DebugConfigurationProvider { if (config.type === 'cppvsdbg') { // Handle legacy 'externalConsole' bool and convert to console: "externalTerminal" - if (config.externalConsole && !config.console) - { - config.console = "externalTerminal" + if (config.externalConsole && !config.console) { + config.console = "externalTerminal"; } // Fail if cppvsdbg type is running on non-Windows From 33b8b921491891b2b2c260f4fd74104c4c1da077 Mon Sep 17 00:00:00 2001 From: Andrew Wang Date: Fri, 15 Jan 2021 15:32:17 -0800 Subject: [PATCH 3/5] Re-add "externalConsole" --- Extension/package.json | 5 +++++ Extension/package.nls.json | 1 + Extension/src/Debugger/configurationProvider.ts | 8 ++++++-- Extension/tools/OptionsSchema.json | 5 +++++ 4 files changed, 17 insertions(+), 2 deletions(-) diff --git a/Extension/package.json b/Extension/package.json index 9d097a9bc2..7946aa5450 100644 --- a/Extension/package.json +++ b/Extension/package.json @@ -1984,6 +1984,11 @@ "description": "%c_cpp.debuggers.cppvsdbg.visualizerFile.description%", "default": "" }, + "externalConsole": { + "type": "boolean", + "description": "%c_cpp.debuggers.cppvsdbg.externalConsole.description%", + "default": false + }, "console": { "type": "string", "enum": [ diff --git a/Extension/package.nls.json b/Extension/package.nls.json index d1a1db824e..e1a898bd82 100644 --- a/Extension/package.nls.json +++ b/Extension/package.nls.json @@ -213,6 +213,7 @@ "c_cpp.debuggers.serverLaunchTimeout.description": "Optional time, in milliseconds, for the debugger to wait for the debugServer to start up. Default is 10000.", "c_cpp.debuggers.coreDumpPath.description": "Optional full path to a core dump file for the specified program. Defaults to null.", "c_cpp.debuggers.cppdbg.externalConsole.description": "If true, a console is launched for the debuggee. If false, on Linux and Windows, it will appear in the Integrated Console.", + "c_cpp.debuggers.cppvsdbg.externalConsole.description": "[Deprecated by 'console'] If true, a console is launched for the debuggee. If false, no console is launched.", "c_cpp.debuggers.cppvsdbg.console.description": "Where to launch the debug target.", "c_cpp.debuggers.cppvsdbg.console.internalConsole.description": "Output to the VS Code Debug Console. This doesn't support reading console input (ex:Console.ReadLine)", "c_cpp.debuggers.cppvsdbg.console.integratedTerminal.description": "VS Code's integrated terminal", diff --git a/Extension/src/Debugger/configurationProvider.ts b/Extension/src/Debugger/configurationProvider.ts index 4e09423daa..da8eb13e37 100644 --- a/Extension/src/Debugger/configurationProvider.ts +++ b/Extension/src/Debugger/configurationProvider.ts @@ -247,8 +247,12 @@ class CppConfigurationProvider implements vscode.DebugConfigurationProvider { if (config.type === 'cppvsdbg') { // Handle legacy 'externalConsole' bool and convert to console: "externalTerminal" - if (config.externalConsole && !config.console) { - config.console = "externalTerminal"; + if (config.hasOwnProperty("externalConsole")) { + logger.getOutputChannelLogger().showWarningMessage(localize("debugger.deprecated.config", "The key '{0}' is deprecated. Please use '{1}' instead.", "externalConsole", "console")); + if (config.externalConsole && !config.console) { + config.console = "externalTerminal"; + } + delete config.externalConsole; } // Fail if cppvsdbg type is running on non-Windows diff --git a/Extension/tools/OptionsSchema.json b/Extension/tools/OptionsSchema.json index 16dab90641..8b4290e74f 100644 --- a/Extension/tools/OptionsSchema.json +++ b/Extension/tools/OptionsSchema.json @@ -541,6 +541,11 @@ "description": "%c_cpp.debuggers.cppvsdbg.visualizerFile.description%", "default": "" }, + "externalConsole": { + "type": "boolean", + "description": "%c_cpp.debuggers.cppvsdbg.externalConsole.description%", + "default": false + }, "console": { "type": "string", "enum": [ From f7aa5e67f035d46165397203ff3d70f1ceadf55f Mon Sep 17 00:00:00 2001 From: Andrew Wang Date: Fri, 15 Jan 2021 15:38:22 -0800 Subject: [PATCH 4/5] Updating example --- Extension/package.nls.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Extension/package.nls.json b/Extension/package.nls.json index e1a898bd82..434d8ca51e 100644 --- a/Extension/package.nls.json +++ b/Extension/package.nls.json @@ -215,7 +215,7 @@ "c_cpp.debuggers.cppdbg.externalConsole.description": "If true, a console is launched for the debuggee. If false, on Linux and Windows, it will appear in the Integrated Console.", "c_cpp.debuggers.cppvsdbg.externalConsole.description": "[Deprecated by 'console'] If true, a console is launched for the debuggee. If false, no console is launched.", "c_cpp.debuggers.cppvsdbg.console.description": "Where to launch the debug target.", - "c_cpp.debuggers.cppvsdbg.console.internalConsole.description": "Output to the VS Code Debug Console. This doesn't support reading console input (ex:Console.ReadLine)", + "c_cpp.debuggers.cppvsdbg.console.internalConsole.description": "Output to the VS Code Debug Console. This doesn't support reading console input (ex:'std::cin' or 'scanf')", "c_cpp.debuggers.cppvsdbg.console.integratedTerminal.description": "VS Code's integrated terminal", "c_cpp.debuggers.cppvsdbg.console.externalTerminal.description": "External terminal that can be configured via user settings", "c_cpp.debuggers.cppvsdbg.console.newExternalWindow.description": "Console applications will be launched in their own external console window which will end when the application stops. Non-console applications will run without a terminal, and stdout/stderr will be ignored.", From a70b4434d2b16b3e4fac847a39f0543f3bfcbbe8 Mon Sep 17 00:00:00 2001 From: Andrew Wang Date: Fri, 15 Jan 2021 16:59:55 -0800 Subject: [PATCH 5/5] More PR comments --- Extension/package.json | 2 +- Extension/package.nls.json | 4 ++-- Extension/src/Debugger/configurationProvider.ts | 2 +- Extension/src/Debugger/configurations.ts | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Extension/package.json b/Extension/package.json index 7946aa5450..2113acea6c 100644 --- a/Extension/package.json +++ b/Extension/package.json @@ -2004,7 +2004,7 @@ "%c_cpp.debuggers.cppvsdbg.console.newExternalWindow.description%" ], "description": "%c_cpp.debuggers.cppvsdbg.console.description%", - "default": "internalConsole" + "default": "externalTerminal" }, "sourceFileMap": { "type": "object", diff --git a/Extension/package.nls.json b/Extension/package.nls.json index 434d8ca51e..22479404bd 100644 --- a/Extension/package.nls.json +++ b/Extension/package.nls.json @@ -214,10 +214,10 @@ "c_cpp.debuggers.coreDumpPath.description": "Optional full path to a core dump file for the specified program. Defaults to null.", "c_cpp.debuggers.cppdbg.externalConsole.description": "If true, a console is launched for the debuggee. If false, on Linux and Windows, it will appear in the Integrated Console.", "c_cpp.debuggers.cppvsdbg.externalConsole.description": "[Deprecated by 'console'] If true, a console is launched for the debuggee. If false, no console is launched.", - "c_cpp.debuggers.cppvsdbg.console.description": "Where to launch the debug target.", + "c_cpp.debuggers.cppvsdbg.console.description": "Where to launch the debug target. Defaults to 'internalConsole' if not defined.", "c_cpp.debuggers.cppvsdbg.console.internalConsole.description": "Output to the VS Code Debug Console. This doesn't support reading console input (ex:'std::cin' or 'scanf')", "c_cpp.debuggers.cppvsdbg.console.integratedTerminal.description": "VS Code's integrated terminal", - "c_cpp.debuggers.cppvsdbg.console.externalTerminal.description": "External terminal that can be configured via user settings", + "c_cpp.debuggers.cppvsdbg.console.externalTerminal.description": "Console applications will be launched in an external terminal window. The window will be reused in relaunch scenarios, and will not automatically disappear when the application exits.", "c_cpp.debuggers.cppvsdbg.console.newExternalWindow.description": "Console applications will be launched in their own external console window which will end when the application stops. Non-console applications will run without a terminal, and stdout/stderr will be ignored.", "c_cpp.debuggers.avoidWindowsConsoleRedirection.description": "If true, disables debuggee console redirection that is required for Integrated Terminal support.", "c_cpp.debuggers.sourceFileMap.description": "Optional source file mappings passed to the debug engine. Example: '{ \"/original/source/path\":\"/current/source/path\" }'", diff --git a/Extension/src/Debugger/configurationProvider.ts b/Extension/src/Debugger/configurationProvider.ts index da8eb13e37..ab532ef057 100644 --- a/Extension/src/Debugger/configurationProvider.ts +++ b/Extension/src/Debugger/configurationProvider.ts @@ -182,7 +182,7 @@ class CppConfigurationProvider implements vscode.DebugConfigurationProvider { newConfig.name = compilerName + buildAndDebugActiveFileStr(); newConfig.preLaunchTask = task.name; - newConfig.console = "internalConsole"; + newConfig.console = "externalTerminal"; const exeName: string = path.join("${fileDirname}", "${fileBasenameNoExtension}"); const isWindows: boolean = platform === 'win32'; newConfig.program = isWindows ? exeName + ".exe" : exeName; diff --git a/Extension/src/Debugger/configurations.ts b/Extension/src/Debugger/configurations.ts index ef26979bf7..4a4908ff7d 100644 --- a/Extension/src/Debugger/configurations.ts +++ b/Extension/src/Debugger/configurations.ts @@ -44,7 +44,7 @@ function createLaunchString(name: string, type: string, executable: string): str "stopAtEntry": false, "cwd": "$\{workspaceFolder\}", "environment": [], -"console": "internalConsole" +"console": "externalTerminal" `; }