简体   繁体   中英

C/C++ Debugger does not work in VSC despite correct config

If I try to run a debugging session on Visual Studio Code with C++ I get this error .

This is my config, I want the debugging session to launch in the VSC terminal using WSL.

    "version": "0.2.0",
    "configurations": [
        {
            "name": "(gdb) Launch",
            "type": "cppdbg",
            "request": "launch",
            "program": "${fileDirname}/${fileBasenameNoExtension}",
            "args": [],
            "stopAtEntry": false,
            "cwd": "${fileDirname}",
            "environment": [],
            "externalConsole": false,
            "MIMode": "gdb",
            "miDebuggerPath": "/usr/bin/gdb", //here :(
            "setupCommands": [
                {
                    "description": "Enable pretty-printing for gdb",
                    "text": "-enable-pretty-printing",
                    "ignoreFailures": true
                }
            ]
        }
      

    ]
}

G++ and GDB are both installed locally and WSL .I tried using all these directories for the "miDebuggerPath" path; did not work.

You need to change the miDebuggerPath to the path where gdb is installed in your WSL-environment.

So you have to set miDebuggerPath to:

"miDebuggerPath": "/usr/share/gdb",

when you wanto to run gd in a WSL-Environment. Change it to

"miDebuggerPath": "C:/MinGW/bin/gdb.exe",

when you want to debug in Windows.

Install C/C++ extension on WSL Remote Subsystem even if you have it locally installed.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM