调试器可执行文件
/usr/local/bin/gdb
未签名。因此,在 macOS Catalina 10.15.6 中的 vscode 中调试可能无法正常工作。
我提供launch.json文件供参考。
{
"version": "0.2.0",
"configurations": [
{
"name": "(lldb) Launch",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceRoot}/build/ghermite.mod",
"miDebuggerPath": "/usr/local/bin/gdb",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceRoot}",
"externalConsole": false,
"preLaunchTask": "build"
}
]
}
我也有同样的问题。我可以通过安装 CodeLLDB 扩展来解决这个问题。
我遇到了这个问题,MacOS 对于调试器有一些策略。然而,即使在运行以下步骤后,我仍然无法让 gdb 扩展正常运行:https://www.owsiak.org/running-gdb-in-macos-sierra/(尽管
gdb
本身似乎是开始)。
为我解决问题的方法是将调试器扩展更改为 https://marketplace.visualstudio.com/items?itemName=vadimcn.vscode-lldb
安装此扩展后,您需要将调试类型从
cppdbg
更改为 lldb
并调整其他设置以匹配 CodeLLDB 文档中的设置:https://github.com/vadimcn/codelldb/blob/v1.10.0/手册.md
对我来说,是将
stopAtEntry
重命名为 stopOnEntry
执行这些步骤后,C++ 应用程序应该像您期望的那样进行调试。