C++ code running using WSL Ubuntu, but not able to debug code in VS Code

I am trying to set up my VS code with WSL Ubuntu to run C++ code. I have installed gdb and g++ and able to run code using Ubuntu and VS code terminal. However, when I am trying to debug the code in VS code, I am getting the following error in terminal.

&”warning: GDB: Failed to set controlling terminal: Operation not permitted\n”
[1] + Done “/usr/bin/gdb” –interpreter=mi –tty=${DbgTerm} 0<“/tmp/Microsoft-MIEngine-In-pyvj15od.ucf” 1>”/tmp/Microsoft-MIEngine-Out-sl4nyggt.r1b”

In debug console, I am getting the following error,

ERROR: Unable to start debugging. Unexpected GDB output from command “-exec-run”. Warning:
Cannot insert breakpoint 1.
Cannot access memory at address 0x8001189
Cannot insert breakpoint 2.
Cannot access memory at address 0x8001191

Can anyone help me to fix this? Thanks in advance.

This is the tasks.json file.

{
"tasks": [
    {
        "type": "cppbuild",
        "label": "C/C++: g++-11 build active file",
        "command": "/usr/bin/g++-11",
        "args": [
            "-fdiagnostics-color=always",
            "-g",
            "${file}",
            "-o",
            "${fileDirname}/${fileBasenameNoExtension}"
        ],
        "options": {
            "cwd": "${fileDirname}"
        },
        "problemMatcher": [
            "$gcc"
        ],
        "group": {
            "kind": "build",
            "isDefault": true
        },
        "detail": "Task generated by Debugger."
    }
],
"version": "2.0.0"
 }

The launch.json and settings.json files are not getting generated.

Leave a Comment