Skip to content

Commit

Permalink
Add new "console" launch config for vsdbg
Browse files Browse the repository at this point in the history
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 15, 2021
1 parent 02c547b commit 969bde8
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 13 deletions.
24 changes: 18 additions & 6 deletions Extension/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -1978,10 +1978,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",
Expand Down Expand Up @@ -2724,7 +2736,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 @@ -2735,7 +2747,7 @@
"binaries": [
"./debugAdapters/vsdbg/bin/vsdbg.exe"
],
"integrity": "8299A112D1260C2CEA53AC74D18FA73DE8533C058AAAB254571B503FBAC37297"
"integrity": "52C4234976D527A7BF02EB2E8844F3C605DC4BD1D3847F83C8675CD23967BAB3"
}
]
}
6 changes: 5 additions & 1 deletion Extension/package.nls.json
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,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.",
Expand Down
8 changes: 7 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 = "internalConsole"
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,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"));
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": "internalConsole"
`;
}

Expand Down
20 changes: 16 additions & 4 deletions Extension/tools/OptionsSchema.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit 969bde8

Please sign in to comment.