首页 > 解决方案 > 错误:无法开始调试。来自命令“-exec-run”的意外 GDB 输出。找不到进程 ID 1401 的 Mach 任务端口

问题描述

我正在尝试使用 GDB 在 C++ 项目中的 VSCode 中运行调试器,但在运行调试器时我不断收到此错误。我已经设置了证书和所有内容,但它仍然给我这个错误(我正在运行 macOS Catalina 版本 10.15.4)。

这是我的 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}/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
                }
            ]
        }
    ]
}

这是我的 tasks.json 文件

{
    // 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"
            },
        }
    ]
}

此外,我看到了一些关于制作 .gdbinit 文件的内容,我在我的根目录中完成了该文件,并在其中放置了以下命令:

set startup-with-shell off

对此问题的任何帮助将不胜感激。

标签: c++debuggingvisual-studio-codecmakegdb

解决方案


我也有同样的问题。或多或少是这样的:

错误:无法开始调试。来自命令“-exec-run”的意外 GDB 输出。创建进程 /usr/bin/ 时出错,(错误 2)。

要修复,请尝试使用较低版本的 gcc / g++(v_9 左右),特别是较低版本的 gdb(v_10,安装的实验版本是问题,更改为 9.3 并确定)。


推荐阅读