Skip to content

Commit

Permalink
Add new "console" launch config for cppvsdbg (#6794)
Browse files Browse the repository at this point in the history
* 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.
  • Loading branch information
WardenGnaw committed Jan 16, 2021
1 parent e4809d9 commit 51fff8e
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 5 deletions.
21 changes: 19 additions & 2 deletions Extension/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -1989,6 +1989,23 @@
"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": "externalTerminal"
},
"sourceFileMap": {
"type": "object",
"description": "%c_cpp.debuggers.sourceFileMap.description%",
Expand Down Expand Up @@ -2730,7 +2747,7 @@
},
{
"description": "Visual Studio Windows Debugger",
"url": "https://go.microsoft.com/fwlink/?linkid=2152353",
"url": "https://go.microsoft.com/fwlink/?linkid=2153010",
"platforms": [
"win32"
],
Expand All @@ -2741,7 +2758,7 @@
"binaries": [
"./debugAdapters/vsdbg/bin/vsdbg.exe"
],
"integrity": "8299A112D1260C2CEA53AC74D18FA73DE8533C058AAAB254571B503FBAC37297"
"integrity": "52C4234976D527A7BF02EB2E8844F3C605DC4BD1D3847F83C8675CD23967BAB3"
}
]
}
7 changes: 6 additions & 1 deletion Extension/package.nls.json
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,12 @@
"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.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. 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": "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\" }'",
"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.",
Expand Down
11 changes: 10 additions & 1 deletion Extension/src/Debugger/configurationProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ class CppConfigurationProvider implements vscode.DebugConfigurationProvider {

newConfig.name = compilerName + buildAndDebugActiveFileStr();
newConfig.preLaunchTask = task.name;
newConfig.externalConsole = false;
newConfig.console = "externalTerminal";
const exeName: string = path.join("${fileDirname}", "${fileBasenameNoExtension}");
const isWindows: boolean = platform === 'win32';
newConfig.program = isWindows ? exeName + ".exe" : exeName;
Expand Down Expand Up @@ -246,6 +246,15 @@ class CppConfigurationProvider implements vscode.DebugConfigurationProvider {
}

if (config.type === 'cppvsdbg') {
// Handle legacy 'externalConsole' bool and convert to 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
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"));
Expand Down
2 changes: 1 addition & 1 deletion Extension/src/Debugger/configurations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ function createLaunchString(name: string, type: string, executable: string): str
"stopAtEntry": false,
"cwd": "$\{workspaceFolder\}",
"environment": [],
"externalConsole": false
"console": "externalTerminal"
`;
}

Expand Down
17 changes: 17 additions & 0 deletions Extension/tools/OptionsSchema.json
Original file line number Diff line number Diff line change
Expand Up @@ -546,6 +546,23 @@
"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",
"description": "%c_cpp.debuggers.sourceFileMap.description%",
Expand Down

0 comments on commit 51fff8e

Please sign in to comment.