Vscode-cpptools: [OS X] Open external terminal launch/debug with correct Terminal

Created on 7 Dec 2016  Â·  16Comments  Â·  Source: microsoft/vscode-cpptools

  • VSCode Version: 1.7.2 - 7ba55c5
  • OS Verson: macOS Sierra 10.12.1
  • C/C++ for VIsual Studio Code Verison: 0.9.2

When debugging/launching your code, VSC doesn't use your external terminal preference set in settings.json. The same issues was opened under vscode repo and in the discussion, we clarified that the launch.json and the expected behavior is related to the specific debugger rather than the vscode itself.

Steps to Reproduce:

  1. In your settings.json, set your terminal to a different one. e.g. for OSX, use:
    // Customizes which terminal application to run on OS X.
   "terminal.external.osxExec": "iTerm.app"
  1. In launch.json, set an action with "externalConsole": true

  2. Start debugging/running your application

Your application will run in the default Terminal.app

Expected behavior:

The last step should respect your preferences

The Node debugger already deprecated the externalConsole replaced with console. I think the C++ debugger should consider the preferences before launching the external console.

Link to OP

Feature Request debugger

Most helpful comment

never fixed

All 16 comments

@Evilcat325 We will look into this for a future release.

This may be similar to #35

@pieandcakes if you set externalConsole to false in the launch.json the std out/err will be print out in the Debug Console Debugger View in the Vscode. I already tested it out. It would more flexible to deprecated a boolean value in favor of a string to provide more functionality.

I am still looking into how the Node Debugger handles the launch of the console app, and why this behavior is different across different debugger but the same launch.json. It is kinda confusing to me and I do not find a good resource to discover how to use the launch.json and it seems that the vscode repo already have an issue opened for adding usability to the launch.json file

Investigate into 'launch.json' usability improvements

@Evilcat325 The debugger redirects stdin/stdout through the console. Different console apps behave differently and different debuggers on different platforms behave differently. We currently have different solutions for gdb on Linux and lldb on OS X. We have been asked to support different console apps on Linux also and it is on our radar for a future release.

@pieandcakes Thanks for fast response, I am looking forward to this feature to be added. If possible could we also add a support for the debugger to redirects the stdin/stdout into the integrated console within the vscode? Sometimes for a small application or just an algorithm for a Leetcode question, it would be nice to have the source code, variable/breakpoints/call stack and the terminal output within the same window.

@Evilcat325 That is also in our backlog

never fixed

Does anybody know the status of this change? Because when I compile and build a C++ application and try to run/debug it, it still starts the native macOS terminal.
In my settings.json I changed the osxExec and the exploreKind.

settings.json

{
    "terminal.external.osxExec": "iTerm.app",
    "terminal.explorerKind": "external"
}

For reference, these are my tasks.json and launch.json

tasks.json

{
    "version": "2.0.0",
    "tasks": [
        {
            "label": "My redacted C++ application",
            "type": "shell",
            "command": "clang++",
            "args": [
                "-std=c++11",
                "-g", "main.cpp",
                "-o", "builds/main.out"
            ],
            "group": {
                "kind": "build",
                "isDefault": true
            },
            "presentation": {
                "reveal": "always",
                "panel": "new"
            }
        }
    ]
}

launch.json

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "(lldb) Launch",
            "type": "cppdbg",
            "request": "launch",
            "program": "${workspaceFolder}/builds/main.out",
            "args": [],
            "stopAtEntry": false,
            "cwd": "${workspaceFolder}",
            "environment": [],
            "externalConsole": true,
            "MIMode": "lldb"
        }
    ]
}

@bmeulmeester Sorry about the late reply. Due to a limitation of the version of lldb we use, there isn't currently a way to utilize the integrated terminal.

Due to a limitation of the version of lldb we use, there isn't currently a way to utilize the integrated terminal.

That's fine, but is it possible to use the terminal set in terminal.external.osxExec, instead of the default macOS terminal app?

@mbikovitsky Not at this time. This is because our version of lldb includes a module that was part of original lldb called darwin-debug that itself spawns the macOS terminal application.

Ah, that explains it, thank you.

Would like for printf()/scanf() to use either integrated terminal or use iTerm.app terminal in OS X.
Any progress on this issue?

@WardenGnaw

If anyone wants to debug with the Integrated Terminal you can try out https://github.com/vadimcn/vscode-lldb

Was this page helpful?
0 / 5 - 0 ratings