gpt4 book ai didi

c++ - 错误:无法开始调试。命令 “-exec-run”的意外GDB输出。找不到进程ID 1401的Mach任务端口

转载 作者:行者123 更新时间:2023-12-02 10:34:39 24 4
gpt4 key购买 nike

我正在尝试使用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

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

最佳答案

launch.json中的“program”参数应为可调试可执行文件的路径。

我猜您正在使用g++。如果使用-g开关,则您的程序将是可调试的。因此,您的编译将是

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

这将使可调试的可执行文件为“a.out”。

确保您的“程序”参数指向此文件。考虑到此文件是在工作空间的根目录下生成的,因此需要将其设置为
"program": "${workspaceFolder}/a.out

希望您能遵循所有步骤。

关于c++ - 错误:无法开始调试。命令 “-exec-run”的意外GDB输出。找不到进程ID 1401的Mach任务端口,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60923232/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com