栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > C/C++/C#

VScode M1芯片 报错:ERROR: Unable to start debugging. Unexpected LLDB output from command “-exec-run“.

C/C++/C# 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

VScode M1芯片 报错:ERROR: Unable to start debugging. Unexpected LLDB output from command “-exec-run“.

VScode 报错:ERROR: Unable to start debugging. Unexpected LLDB output from command “-exec-run”.

1. 背景介绍
  1. 新手 VScode 使用者,使用系统是:MacOS Big Sur 11.4,使用的是Apple M1 芯片。
  2. 利用 Vscode 编译 c++ 代码,按照标准流程, 进行了配置。标准配置链接为:https://code.visualstudio.com/docs/cpp/config-clang-mac。

debug 之后出现的问题是:

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 ‘/Users/Desktop/test/test’ has exited with code 42 (0x0000002a).

2. 问题分析以及解决方法

tasks.json 中代码为:

    {
    "version": "2.0.0",
    "tasks": [
        {
            "type": "cppbuild",
            "label": "C/C++: clang++ 生成活动文件",
            "command": "/usr/bin/clang++",
            "args": [
                "-g",
                "${file}",
                "-o",
                "${fileDirname}/${filebasenameNoExtension}"
            ],
            "options": {
                "cwd": "${fileDirname}"
            },
            "problemMatcher": [
                "$gcc"
            ],
            "group": "build",
            "detail": "编译器: /usr/bin/clang++"
        },
    ]
}

其中 args 中的参数代表编译器会执行:

clang++ -g test.cpp -o test

在此之后,生成的结果为:

然后,下一步是需要执行 ./test 操作,这一步需要用扩展来完成:CodeLLDB,具体是在 launch.json 中写入 launch 的操作,具体是操作 ./test 的步骤,使结果输出:

        {
            "name": "Launch",
            "type": "lldb",
            "request": "launch",
            "program": "${workspaceFolder}/${filebasenameNoExtension}",
            "args": ["-arg1", "-arg2"],
        }

其中 ${filebasenameNoExtension} 代表 test 的文件。之后,在cpp文件中执行 F5 操作,无报错。

3. 重点

CodeLLDB 扩展的引入以及 launch 中写入了

"program": "${workspaceFolder}/${filebasenameNoExtension}", 

命令。

参考:
  1. lldb 使用: https://blog.csdn.net/Vinsuan1993/article/details/103983520
  2. 思路指向:https://github.com/microsoft/vscode-cpptools/issues/6779
转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/664984.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号