ERROR: Unable to start debugging. Unexpected GDB output from command "-exec-run". Unable to find Mach task port for process-id 1401

15,317

Solution 1

I had same problem too. More or less this:

ERROR: Unable to start debugging. Unexpected GDB output from command "-exec-run". Error creating process /usr/bin/, (error 2).

To fix please try to use lower versions of gcc / g++ (v_9 or so) and specially lower version of gdb ( v_10, experimental version installed was the problem, changed to 9.3 and Ok).

Solution 2

In my case, this problem seems to be directly related to gdb 10.2-1. Downgrading gdb to 9.2-1 solved the problem instantly.

Solution 3

The "program" parameter in your launch.json should be the path of your debuggable executable.

I'm guessing that you are using g++. Your program will be debuggable if you use the -g switch. Thus your compilation will be

g++ -g path/to/prog.cpp -o a.out

This will make a debuggable executable file as "a.out".

Make sure your "program" parameter is pointing to this file. Considering this file is generated at the root of your workspace, you'll need to have it set as

"program": "${workspaceFolder}/a.out

I hope you are following all there steps.

Share:
15,317
Nathan Anderson
Author by

Nathan Anderson

Updated on June 20, 2022

Comments

  • Nathan Anderson
    Nathan Anderson almost 2 years

    I am trying to use GDB to run the debugger in VSCode in a C++ project, but I keep getting this error when running my debugger. I have set up a cert and everything and it is still giving me this error (I am running macOS Catalina version 10.15.4).

    Here is my launch.json file

    {
       // 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}/build/Assignment8",
                "args": [],
                "stopAtEntry": false,
                "cwd": "${workspaceFolder}",
                "environment": [],
                "externalConsole": false,
                "MIMode": "gdb",
                "setupCommands": [
                    {
                        "description": "Enable pretty-printing for gdb",
                        "text": "-enable-pretty-printing",
                        "ignoreFailures": true
                    }
                ]
            }
        ]
    }
    

    Here is my tasks.json file

    {
        // See https://go.microsoft.com/fwlink/?LinkId=733558
        // for the documentation about the tasks.json format
        "version": "2.0.0",
        "tasks": [
            {
                "label": "echo",
                "type": "shell",
                "command": "make",
                "options": {
                    "cwd": "${workspaceFolder}/build"
                },
            }
        ]
    }
    

    Additionally, I saw something about making a .gdbinit file, which I did in my root directory, and I placed the following command in it:

    set startup-with-shell off
    

    Any help with this issue would be greatly appreciated.