在项目的官网没有找到相应说明,只有编译方法,但是只有断点跟踪才能更好的理解代码逻辑,于是开始想办法编写launch.json,settings.json,tasks.json。
最开始打算使用GDB,但是发现M2芯片不能使用GDB,只能使用LLDB。Enlee
在launch.json中 指定LLDB路径
"miDebuggerPath": "/Applications/Xcode.app/Contents/Developer/usr/bin/lldb",
下面是完整的launch.json文件
{
"version": "0.2.0",
"configurations": [
{
"name": "LLDB Launch",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceFolder}/build/bin/inkscape",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
"environment": [
{
"name": "PATH",
"value": "/opt/homebrew/bin:/usr/bin:/bin:/usr/sbin:/sbin"
},
{
"name": "PKG_CONFIG_PATH",
"value": "/opt/homebrew/opt/icu4c/lib/pkgconfig:/opt/homebrew/opt/libsoup@2/lib/pkgconfig:/opt/homebrew/opt/libxslt/lib/pkgconfig:/opt/homebrew/opt/libxml2/lib/pkgconfig"
}
],
"externalConsole": false,
"MIMode": "lldb",
"miDebuggerPath": "/Applications/Xcode.app/Contents/Developer/usr/bin/lldb", // 指定 LLDB 路径
"setupCommands": [
{
"text": "-enable-pretty-printing",
"description": "Enable LLDB pretty-printing",
"ignoreFailures": true
}
],
"preLaunchTask": "CMake Build", // 确保此任务已在 tasks.json 中定义
"internalConsoleOptions": "openOnSessionStart",
}
]
}
但是运行的时候报了错误
Starting: "/Applications/Xcode.app/Contents/Developer/usr/bin/lldb" --interpreter=mi
error: unknown option: --interpreter=mi
Use 'lldb --help' for a complete list of options.
"/Applications/Xcode.app/Contents/Developer/usr/bin/lldb" exited with code 1 (0x1).
找了各种博客,都说是要安装 lldb-mi 之类的,后来发现只需要去除miDebuggerPath就可以了。
附件是完整的修改之后的三个文件