【问题标题】:VSCode LLDB on MacOS error when starting debugging session开始调试会话时,MacOS 上的 VSCode LLDB 错误
【发布时间】:2021-07-20 01:14:48
【问题描述】:

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

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

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

【问题讨论】:

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


    【解决方案1】:

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

    但是,如果您使用其他扩展程序,它会起作用。安装 CodeLLDB 并在 launch.json 上设置"type": "lldb",如下所示。

    {
        // 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 中标签的值相同。

    【讨论】:

      【解决方案2】:

      使用命令使可执行文件:

      gcc file_name.c -g
      

      launch.json

      "targetArchitecture": "x86_64",

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2023-02-26
        • 2018-12-18
        • 2015-03-12
        • 1970-01-01
        • 1970-01-01
        • 2023-03-20
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多