c - VSCode,MacOS Catalina - 不会在 C/C++ 调试的断点处停止
问题描述
我正在尝试在 Mac 上使用 VSCode 开发的 C 代码上设置断点。
我的代码似乎编译和运行得很好(感谢在 vscode BTW 上找不到“openssl/crypto.h”文件),但我没有得到任何断点,甚至在开始使用"stopAtEntry": true
或附加到正在运行的进程时也没有。
我的tasks.json
和launch.json
非常标准:
{
"tasks": [
{
"type": "shell",
"label": "clang build active file",
"command": "/usr/bin/clang",
"args": [
"-g",
"${file}",
"-o",
"${fileDirname}/${fileBasenameNoExtension}",
"-I/usr/local/opt/openssl/include",
"-L/usr/local/opt/openssl/lib",
"-lssl",
"-lcrypto"
],
"options": {
"cwd": "/usr/bin"
}
}
],
"version": "2.0.0"
}
和:
{
"version": "0.2.0",
"configurations": [
{
"name": "(lldb) Attach",
"type": "cppdbg",
"request": "attach",
"program": "${workspaceFolder}/test2",
"processId": "${command:pickProcess}",
"MIMode": "lldb"
},
{
"name": "clang build and debug active file",
"type": "cppdbg",
"request": "launch",
"program": "${fileDirname}/${fileBasenameNoExtension}",
"args": [],
"stopAtEntry": true,
"cwd": "${workspaceFolder}",
"environment": [],
"externalConsole": false,
"MIMode": "lldb",
"preLaunchTask": "clang build active file",
"logging": {
"trace": false,
"traceResponse": false,
"engineLogging": false
}
}
]
}
我知道VS 代码忽略了 c++ 调试中的断点以及此处的所有类似讨论。
我的设置是:MacOS Catalina(10.15,生产)以及 XCode 11.1、Visual Studio Code 1.39.0 和 C/C++ 扩展 0.26.0-insiders3。
有没有人比我运气好?
解决方案
所以显然这是 Catalina 和 XCode 11.x 支持的一个已知问题:https ://github.com/microsoft/vscode-cpptools/issues/3829由lldb-mi
.
lldb-mi
是位于 IDE 和 lldb API 本身之间的驱动程序。
lldb-mi
与插件捆绑在一起的版本似乎与 Catalina 不兼容,并且 XCode 11.x 不再兼容lldb-mi
。
github 线程提供了 2 个临时解决方案:
lldb-mi
第一个解决方案是通过lldb-mi
设置miDebuggerPath
.launch.json
我碰巧有 XCode 10.1,所以我的配置是:
"miDebuggerPath":"/Applications/Xcode 10.1.app/Contents/Developer/usr/bin/lldb-mi",
我设法使基本调试工作正常,但会出现兼容性问题。然而,事实证明这足以满足我的需求(耶!)。
替换 lldb 前端
第二种解决方案是使用VSCode-lldb 扩展。
更新在这里
一旦出现,我将保留此答案,并使用永久解决方案更新此帖子。
推荐阅读
- java - Java 应用程序中的 Axon - 对事件处理程序错误作出反应
- python - 是否可以混合 pydantic BaseModels 和 Starlette Request?
- swift - 在 TableViewCell 中执行 UIDocumentPickerView
- xero-api - Xero API,以“草稿”状态为 PayRun 创建工资单
- javascript - 重新渲染行数 React
- api - 我无法使用 Postman 或 cURL 获取问题令牌
- html - 按钮标题不相邻
- assembly - ARM汇编代码理解与转换
- azure - 学习微软 Azure 云
- php - QuickBooks Web 连接器问题