Answer a question

I've just setup VSCode to work from home with my remote SSH that runs Gentoo x64. Everything works fine apart from the GCC debugger which we usually use. It throws me the error in the title.

Here's my launch.json:

{
"version": "0.2.0",
"configurations": [
    {
        "name": "gcc - Build and debug active file",
        "type": "cppdbg",
        "request": "launch",
        "program": "${fileDirname}/${fileBasenameNoExtension}",
        "args": [],
        "stopAtEntry": false,
        "cwd": "${workspaceFolder}",
        "environment": [],
        "externalConsole": false,
        "MIMode": "gdb",
        "setupCommands": [
            {
                "description": "Enable pretty-printing for gdb",
                "text": "-enable-pretty-printing",
                "ignoreFailures": true
            }
        ],
        "preLaunchTask": "gcc build active file",
        "miDebuggerPath": "/usr/bin/gdb"
    }
]
}

and my tasks.json:

{
"version": "2.0.0",
"tasks": [
    {
        "type": "shell",
        "label": "C/C++: gcc build active file",
        "command": "/usr/bin/gcc",
        "args": [
            "-g",
            "${file}",
            "-o",
            "${fileDirname}/${fileBasenameNoExtension}"
        ],
        "options": {
            "cwd": "/usr/bin"
        },
        "problemMatcher": [
            "$gcc"
        ],
        "group": "build"
    }
]
}

And yes, I do compile with the -g flag. Any ideas on how to fix this?

Answers

You will need to add gdb configuration:

In the debug menu, left side, click the debug icon, in the top you have a drop down menu where you have you default config "gcc build active file", you will need to click that and select "add configuration", select (gdb) Launch, this will add to the launch.json something along the lines of:

    "version": "0.2.0",
    "configurations": [
        {
            "name": "(gdb) Launch",
            "type": "cppdbg",
            "request": "launch",
            "program": "${workspaceFolder}/a.exe",
            "args": [],
            "stopAtEntry": false,
            "cwd": "${workspaceFolder}",
            "environment": [],
            "externalConsole": false,
            "MIMode": "gdb",
            "miDebuggerPath": "C:\\TDM-GCC-64\\bin\\gdb.exe",
            "setupCommands": [
                {
                    "description": "Enable pretty-printing for gdb",
                    "text": "-enable-pretty-printing",
                    "ignoreFailures": true
                }
            ]
        }
    ]

Of course mine is windows so yours will be different.

You might have to configure the name of the executable, working folder, gdb location, etc.

Then in the same dropdown menu select (gdb) Launch

Logo

开发云社区提供前沿行业资讯和优质的学习知识,同时提供优质稳定、价格优惠的云主机、数据库、网络、云储存等云服务产品

更多推荐