MAC M123系列芯片调试C++,不能用GDB,只能用LLDB,MAC系统自带了lldb,需要安装lldb-mi
按照lldb-mi的readme
https://github.com/lldb-tools/lldb-mi
显示找不到这俩 LLVMConfig.cmake
和 llvm-config.cmake
xxxx@MacBook-Pro lldb-mi % cmake .
xxxx
CMake Error at CMakeLists.txt:15 (find_package):
Could not find a package configuration file provided by "LLVM" with any of
the following names:
LLVMConfig.cmake
llvm-config.cmake
Add the installation prefix of "LLVM" to CMAKE_PREFIX_PATH or set
"LLVM_DIR" to a directory containing one of the above files. If "LLVM"
provides a separate development package or SDK, be sure it has been
installed.
安装一下 LLVM,如果已经有了,则跳到最后的GitHub链接
brew install llvm
如果没有 brew,执行
/bin/bash -c "$(curl -fsSL https://gitee.com/ineo6/homebrew-install/raw/master/install.sh)"
brew install llvm
前面都是安装 llvm 的一些 log,后这几句有用
To use the bundled libc++ please add the following LDFLAGS:
LDFLAGS="-L/opt/homebrew/opt/llvm/lib/c++ -L/opt/homebrew/opt/llvm/lib -lunwind"
llvm is keg-only, which means it was not symlinked into /opt/homebrew,
because macOS already provides this software and installing another version in
parallel can cause all kinds of trouble.
If you need to have llvm first in your PATH, run:
echo 'export PATH="/opt/homebrew/opt/llvm/bin:$PATH"' >> ~/.zshrc
For compilers to find llvm you may need to set:
export LDFLAGS="-L/opt/homebrew/opt/llvm/lib"
export CPPFLAGS="-I/opt/homebrew/opt/llvm/include"
把这三句加到 ~/.zshrc
中
export PATH="/opt/homebrew/opt/llvm/bin:$PATH"
export LDFLAGS="-L/opt/homebrew/opt/llvm/lib"
export CPPFLAGS="-I/opt/homebrew/opt/llvm/include"
然后刷新一下
source ~/.zshrc
如果有 llvm 还有这个问题,可以参考
https://github.com/EOSIO/eos/issues/43
如果这两步 cmake 都没啥问题
cmake .
cmake --build .
那么最后执行
make install # 不知道为啥github最后没有写这个 (莫非是默认的?)
之后vscode的 .vscode
中的 launch.json
改为:
{
"version": "0.2.0",
"configurations": [
{
......
"osx": {
"MIMode": "lldb",
"miDebuggerPath": "lldb-mi",
"program": "${workspaceFolder}/output/main"
},
.....
}
]
}
PS:
lldb-mi
是什么
lldb-mi 是一个为 LLDB 调试器提供的机器接口(Machine Interface, MI)前端。MI 是一种用于与调试器交互的文本协议,通常用于实现 IDE 和调试器之间的通信。lldb-mi 允许那些期望使用 GDB/MI 接口的工具与 LLDB 调试器进行交互。