Unable to debug C on VS Code using gdb on Windows Subsystem for Linux

Viewed 5210

I am using VS Code to debug 'C' code using Windows Subsystem for linux. I basically want to compile the 'C' code using a linux based compiler for a Operating System's course. I have set the default terminal to 'WSL' on Visual Studio Code. On clicking the debug button I am getting the below error 'Unable to start debugging. The value of miDebuggerPath is invalid' I verified that 'gdb' is installed in the Windows Subsystem for Linux and its executable (ELF File) is present in '/usr/bin/gdb' location

This is m launch.json

{
    // 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": "(gdb) Launch",
            "type": "cppdbg",
            "request": "launch",
            "program": "${workspaceFolder}/temp",
            "args": [],
            "stopAtEntry": false,
            "cwd": "${workspaceFolder}",
            "environment": [],
            "externalConsole": true,
            "MIMode": "gdb",
            "miDebuggerPath": "/usr/bin/gdb",
            "setupCommands": [
                {
                    "description": "Enable pretty-printing for gdb",
                    "text": "-enable-pretty-printing",
                    "ignoreFailures": true
                }
            ],
            //"preLaunchTask": "Compile C Ubuntu"
        }
    ]
}

Any direction will be helpful :)

1 Answers

The issue you are running into is the missing remoting call using bash.exe that is needed to call the debugger on the WSL site. You will need to add a section called "pipeTransport": and configure it. For more information, there is a how-to document located here.

You can find additional information on our extension's GitHub site at https://github.com/microsoft/vscode-cpptools.

Related