microsoft / vscode-cpptools

Official repository for the Microsoft C/C++ extension for VS Code.
Other
5.52k stars 1.55k forks source link

Unable to launch external console on MacOS when using GDB #3652

Open machstriking opened 5 years ago

machstriking commented 5 years ago

Type: Debugger

Describe the bug

When trying to debug on macOS using gdb instead of lldb external console is not started, even when "externalConsole": true is set in launch.json.

To Reproduce Please include a code sample and launch.json configuration. Steps to reproduce the behavior:

  1. Create simple hello world program like one below:
    
    #include <iostream>
    #include <string>
    using namespace std;

int main() { string name; cin >> name; cout << "Hello " + name << endl; return 0; }

2. Create launch.json like the one here:
{
    "name": "(gdb) Launch Mac",
    "type": "cppdbg",
    "request": "launch",
    "program": "${fileDirname}/${fileBasenameNoExtension}.out",
    "args": [],
    "stopAtEntry": false,
    "cwd": "${fileDirname}",
    "environment": [],
    "externalConsole": true,
    "MIMode": "gdb",
    "setupCommands": [
        {
            "description": "Enable pretty-printing for gdb",
            "text": "-enable-pretty-printing",
            "ignoreFailures": true
        }
    ]
}


3. Launch debugger. 
4. No external input console is started, disabling user to enter `name` when debugging.
WardenGnaw commented 5 years ago

We have noted this in our documentation, but external console does not work with MacOS because of the limitations of lldb-mi.

peza8 commented 4 years ago

Any update on this? Is there an alternative to the MacOS native terminal app that VSCode can connect to? @WardenGnaw

I have the same issue even using lldb - debugger launches a terminal, but the program does not execute.

PreciseAsteroid commented 4 years ago

I get similar behavior. no terminal is launched.

{
    // Use IntelliSense to learn about possible attributes.
    // Hover to view descriptions of existing attributes.
    // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": [
        {
            "name": "(lldb) Launch",
            "type": "cppdbg",
            "request": "launch",
            "program": "${workspaceFolder}/build/OSM_A_star_search",
            "args": [],
            "stopAtEntry": true,
            "cwd": "${workspaceFolder}",
            "environment": [],
            "externalConsole": false,
            "MIMode": "lldb",            
            "miDebuggerPath": "/Users/a1/.vscode/extensions/ms-vscode.cpptools-0.27.0/debugAdapters/lldb/bin/lldb-mi",
            "logging": {
                "trace": true
            }

        }
    ]
}
WardenGnaw commented 4 years ago

Looks like there was an issue with VS Code not having permissions to launch Terminal.

Can you try the workaround in https://github.com/microsoft/vscode-cpptools/issues/5079 and see if that resolves your issue?