VSCode,MacOS Catalina - C/C++调试中断点无法停止

6
我正在尝试让在Mac上使用VSCode开发的C代码中的断点正常工作。
我的代码似乎可以编译和运行得很好(顺便提一下,由于'openssl/crypto.h' file not found on vscode),但我无法获得任何断点,甚至无法在启动时使用"stopAtEntry": true或通过连接到运行中的进程来获取。
我的tasks.jsonlaunch.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 code在C++调试中忽略断点以及所有类似的讨论。
我的设置是: MacOS Catalina(10.15,生产环境),同时安装了XCode 11.1、Visual Studio Code 1.39.0和C/C++扩展0.26.0-insiders3。
有人比我运气更好吗?
2个回答

17

显然,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主题提供了两个临时解决方案:

lldb-mi

第一个解决方案是使用捆绑在以前版本的XCode中的 lldb-mi ,通过设置 launch.jsonmiDebuggerPath 属性来实现。

我碰巧有 XCode 10.1,所以我的配置是:

"miDebuggerPath":"/Applications/Xcode 10.1.app/Contents/Developer/usr/bin/lldb-mi",

我成功地实现了基本的调试功能,但需要注意可能存在的兼容性问题。不过这对我的需求来说已经足够好了!

一个替代lldb前端

第二种解决方案是使用VSCode-lldb扩展程序

更新在此处

一旦有永久解决方案,我会在这个文章中保留并更新答案。


5

跟随 @Vaiden 的第二个解决方案,我使用 C++ vscode 调试。我补充了如何在我的调试配置中使用它。

  1. 安装 CodeLLDB vscode 扩展

  2. 修改 launch.json 配置文件

{
  "version": "0.2.0",
  "configurations": [
      {
          //...other configuration
          "type": "lldb", // change this one from cppdbg to lldb
      }
  ]
}
  1. 按下 F5 键启动调试,这应该可以解决 lldm-mi 问题。

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接