启动调试会话时 MacOS 上的 VSCode LLDB 错误

时间:2021-04-26 16:33:07

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

我正在尝试配置 VSCode 以在 MacOS 上编译/调试 C++ 程序。我正在使用以下 launch.json 文件:

enter image description here

当我尝试启动调试会话时,出现以下错误:

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”删除了警告,但没有修复错误。

1 个答案:

答案 0 :(得分:2)

我遇到了同样的问题,我发现 VScode 尚不支持 ARM64 二进制文件的调试器。这是问题 link

但是,如果您使用其他扩展程序,它会起作用。安装 CodeLLDB 并更改 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"
      }
    ]
  }

请注意,preLaunchTask 的值应与 task.json 中标签的值相同。