Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Visual Studio Code - C++ Debugger doesn't start

I've been using Visual Studio Code to debug C++ on Linux for a while now.

In a sample project I've got the following launch.json:

{
    "name": "(gdb) Launch",
    "type": "cppdbg",
    "request": "launch",
    "program": "${workspaceFolder}/main",
    "args": [],
    "stopAtEntry": false,
    "cwd": "${workspaceFolder}",
    "environment": [],
    "externalConsole": true,
    "MIMode": "gdb",
    "setupCommands": [
        {
            "description": "Enable pretty-printing for gdb",
            "text": "-enable-pretty-printing",
            "ignoreFailures": true
        }
    ]
}

I've successfully compiled and run main.c, so debugging should work fine.

When I start the debugger, a blue loading bar appears under the arrow and nothing happens. On my laptop, with the exact same configuration, the loading bar would disappear after a couple of seconds and the debugger would start.

Looking at ps aux I can see two new processes:

  1. mono.linux-x86_640 with the command /home/guyyst/.vscode/extensions/ms-vscode.cpptools-0.20.1/debugAdapters/mono.linux-x86_64 --config /home/guyyst/.vscode/extensions/ms-vscode.cpptools-0.20.1/debugAdapters/framework/config.linux /home/guyyst/.vscode/extensions/ms-vscode.cpptools-0.20.1/debugAdapters/bin/OpenDebugAD7.exe

  2. bash with the command bash /home/guyyst/.vscode/extensions/ms-vscode.cpptools-0.20.1/debugAdapters/OpenDebugAD7

Debugging on my laptop spawns the same processes, but they disappear when the debugging actually starts. The two processes on my PC stick around even after closing VSCode. When I first noticed this I had 15+ copies running from previous attempts.

All of this worked fine yesterday, and I don't remember making any changes to my configuration since then.

I've tried reinstalling VSCode several times through either the AUR version visual-studio-code-bin or the open source package code.

Debugging some Python code worked just fine.

like image 943
guyyst Avatar asked Dec 05 '22 10:12

guyyst


1 Answers

Turns out it was as easy as setting externalConsole in launch.json to false. Should've probably thought of trying that before.

I'm constrained to the VSCode console, which isn't that big a deal.

I still can't explain why it won't work with an external console, since that's how I'm still doing it on my laptop and used to do it on my PC too.

like image 62
guyyst Avatar answered Dec 08 '22 01:12

guyyst