我正在尝试配置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“删除了警告,但没有修复错误。
发布于 2021-05-25 17:44:55
我也遇到了同样的问题,我发现VScode还不支持ARM64二进制文件的调试器。以下是链接的问题。
但是,如果使用另一个扩展,它就能工作。安装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"
}
]
}
您可以查看vscode-lldb存储库的快速启动指南。
注意,preLaunchTask的值应该与task.json中标签的值相同。
发布于 2021-08-30 00:19:28
使可执行命令:
gcc file_name.c -g
launch.json
targetArchitecture:"x86_64",
https://stackoverflow.com/questions/67270447
复制相似问题