diff --git a/lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/launch/TestVSCode_launch.py b/lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/launch/TestVSCode_launch.py --- a/lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/launch/TestVSCode_launch.py +++ b/lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/launch/TestVSCode_launch.py @@ -17,7 +17,6 @@ mydir = TestBase.compute_mydir(__file__) @skipIfWindows - @skipIfDarwin # Flaky def test_default(self): ''' Tests the default launch of a simple program. No arguments, @@ -53,6 +52,19 @@ reason != 'breakpoint', 'verify stop isn\'t "main" breakpoint') + @skipIfWindows + def test_externalConsole(self): + ''' + Tests the default launch of a simple program that launches in a + new TTY. + ''' + program = self.getBuildArtifact("a.out") + self.build_and_launch(program, externalConsole=True) + self.continue_to_exit() + # Now get the STDOUT and verify we connected it to another TTY + output = self.get_stdout() + self.assertEqual(output, None, "Program output goes TTY") + @skipIfWindows def test_cwd(self): ''' diff --git a/lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/lldbvscode_testcase.py b/lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/lldbvscode_testcase.py --- a/lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/lldbvscode_testcase.py +++ b/lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/lldbvscode_testcase.py @@ -265,7 +265,7 @@ disableSTDIO=False, shellExpandArguments=False, trace=False, initCommands=None, preRunCommands=None, stopCommands=None, exitCommands=None,sourcePath= None, - debuggerRoot=None, launchCommands=None): + debuggerRoot=None, launchCommands=None, **kwargs): '''Sending launch request to vscode ''' @@ -296,7 +296,8 @@ exitCommands=exitCommands, sourcePath=sourcePath, debuggerRoot=debuggerRoot, - launchCommands=launchCommands) + launchCommands=launchCommands, + **kwargs) if not (response and response['success']): self.assertTrue(response['success'], 'launch failed (%s)' % (response['message'])) @@ -306,7 +307,8 @@ disableSTDIO=False, shellExpandArguments=False, trace=False, initCommands=None, preRunCommands=None, stopCommands=None, exitCommands=None, - sourcePath=None, debuggerRoot=None): + sourcePath=None, debuggerRoot=None, + **kwargs): '''Build the default Makefile target, create the VSCode debug adaptor, and launch the process. ''' @@ -316,4 +318,4 @@ self.launch(program, args, cwd, env, stopOnEntry, disableASLR, disableSTDIO, shellExpandArguments, trace, initCommands, preRunCommands, stopCommands, exitCommands, - sourcePath, debuggerRoot) + sourcePath, debuggerRoot, **kwargs) diff --git a/lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/vscode.py b/lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/vscode.py --- a/lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/vscode.py +++ b/lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/vscode.py @@ -562,7 +562,7 @@ disableSTDIO=False, shellExpandArguments=False, trace=False, initCommands=None, preRunCommands=None, stopCommands=None, exitCommands=None, sourcePath=None, - debuggerRoot=None, launchCommands=None): + debuggerRoot=None, launchCommands=None, **kwargs): args_dict = { 'program': program } @@ -597,6 +597,8 @@ args_dict['debuggerRoot'] = debuggerRoot if launchCommands: args_dict['launchCommands'] = launchCommands + args_dict.update(kwargs) + command_dict = { 'command': 'launch', 'type': 'request', diff --git a/lldb/tools/lldb-vscode/README.md b/lldb/tools/lldb-vscode/README.md --- a/lldb/tools/lldb-vscode/README.md +++ b/lldb/tools/lldb-vscode/README.md @@ -88,6 +88,7 @@ |**exitCommands** |[string]| | LLDB commands executed when the program exits. Commands and command output will be sent to the debugger console when they are executed. |**sourceMap** |[string[2]]| | Specify an array of path re-mappings. Each element in the array must be a two element array containing a source and destination pathname. |**debuggerRoot** | string| |Specify a working directory to use when launching lldb-vscode. If the debug information in your executable contains relative paths, this option can be used so that `lldb-vscode` can find source files and object files that have relative paths. +| **externalConsole** |boolean| | Set to TRUE to start the application in a new terminal. Useful for testing console applications. ## Attaching Settings diff --git a/lldb/tools/lldb-vscode/lldb-vscode.cpp b/lldb/tools/lldb-vscode/lldb-vscode.cpp --- a/lldb/tools/lldb-vscode/lldb-vscode.cpp +++ b/lldb/tools/lldb-vscode/lldb-vscode.cpp @@ -1395,6 +1395,8 @@ flags |= lldb::eLaunchFlagDisableSTDIO; if (GetBoolean(arguments, "shellExpandArguments", false)) flags |= lldb::eLaunchFlagShellExpandArguments; + if (GetBoolean(arguments, "externalConsole", false )) + flags |= lldb::eLaunchFlagLaunchInTTY | lldb::eLaunchFlagCloseTTYOnExit; const bool detatchOnError = GetBoolean(arguments, "detachOnError", false); g_vsc.launch_info.SetDetachOnError(detatchOnError); g_vsc.launch_info.SetLaunchFlags(flags | lldb::eLaunchFlagDebug | diff --git a/lldb/tools/lldb-vscode/package.json b/lldb/tools/lldb-vscode/package.json --- a/lldb/tools/lldb-vscode/package.json +++ b/lldb/tools/lldb-vscode/package.json @@ -89,6 +89,11 @@ "description": "Automatically stop after launch.", "default": false }, + "externalConsole": { + "type": "boolean", + "description": "Launch the program in a new terminal", + "default": false + }, "disableASLR": { "type": "boolean", "description": "Enable or disable Address space layout randomization if the debugger supports it.",