c++ - 启动调试 session 时 MacOS 上的 VSCode LLDB 错误

标签 c++ visual-studio-code lldb vscode-debugger

我正在尝试配置 VSCode 以在 MacOS 上编译/调试 C++ 程序。我正在使用以下 launch.json 文件:
enter image description here
当我尝试启动调试 session 时,出现以下错误:

Warning: Debuggee TargetArchitecture not detected, assuming x86_64.
ERROR: Unable to start debugging. Unexpected LLDB output from command "-exec-run". process 
exited with status -1 (attach failed ((os/kern) invalid argument))
The program '/path/to/Development/C++/helloworld/main' has exited with code 42 
(0x0000002a).
值得一提的是,我使用的是 M1 Macbook,所以 x86_64 不是正确的架构。我假设这是错误的原因。
我似乎在网上的任何地方都找不到对此错误的任何引用,有谁知道我该如何解决这个问题?
编辑:添加“targetArchitecture”:“ARM64”删除了警告,但没有修复错误。

最佳答案

我遇到了同样的问题,我发现 VScode 还不支持 ARM64 二进制文件的调试器。这是问题link .
但是,如果您使用其他扩展名,它会起作用。安装 代码LLDB 并设置 "type": "lldb"在 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": "clang++ - Build and debug active file",
        "type": "lldb",
        "request": "launch",
        "program": "${fileDirname}/${fileBasenameNoExtension}",
        "args": [],
        "cwd": "${workspaceFolder}",
        "preLaunchTask": "clang++ build active file"
      }
    ]
  }
您可以查看 quick start vscode-lldb 存储库指南。
请注意,preLaunchTask 的值应与 task.json 中标签的值相同。

关于c++ - 启动调试 session 时 MacOS 上的 VSCode LLDB 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/67270447/

相关文章:

c++ - 不使用 <algorithm> 从 2 个 vector (或列表)中删除相似元素

npm - 如何在 VS 代码中运行 2 个监视任务?

c++ - lldb 调试器无法打印结构内容

c++ - 模板函数参数中的自动模板特化

c++ - 使用宏在本地禁用 qDebug 输出

c++ - std::function 类似委托(delegate)模板类

python - Visual Studio 代码 pylint : Unable to import 'protorpc'

regex - VSCode Regex 在文件中查找/替换 : can't get a numbered capturing group followed by numbers to work out

python - 使用 Python 脚本时 Xcode lldb 调试器中的空 lldb.frame 变量

debugging - 如何找出 Xcode 4/lldb 中的对象(或简单变量)发生了什么变化?