0
点赞
收藏
分享

微信扫一扫

macOS 下vscode配置GUI debug环境 踩坑小结

青乌 2022-04-14 阅读 52
vscode

macOS 下vscode配置GUI debug环境 踩坑小结

最近发现图形界面的debug很香,于是就在最近的项目中使用了GUI debug,结果里面的一些问题把我给整自闭了,这里小结一些

基本配置方案

这里参考官方文档即可,配置launch.json

基本配置完毕后就真香了,然后。。。

#1 lldb-mi 在某些断点卡死

在一些断点完全卡住,导致不得不手动kill,在晚上查到我的情况大概与freezes on MacOS when breaking near uninitialised variables这个相同,就是lldb卡死在了fetching uninitialized variables

使用clang编译测试代码

#include <initializer_list>

void freeze_up() {
    auto bad_var = {1, 2, 3};  // A breakpoint here will trigger the issue.
}  // A breakpoint here is fine (bad_var is initialised).

int main() {
    freeze_up();
    return 0;
}

也重现了问题。甚至导致了一个只能手动删除的lldb-mi进程,只能说特别搞心态。不过这应该不是lldb的问题,在命令行不会出现这个问题,展示的十分完美,只是在vscode launch出现卡死。

最终也不知道怎么解决,不过发现使用gcc编译的代码不会出现该问题,后面vscode launcg的就用gcc编译了。

#2 无法查看标准库容器的值

标准库容器变成了一堆无法解释的内容,无法得到有意义的值,严重影响debug

在网上查找了很多,无意之间找的了解释

结果编译选项变为-gdwarf-3就解决了

#3 无法查看std::set<int> 的内容

在能查看vector的内容后,发现仍然无法查看set的内容

在这一个回答中找到了对lldb pretty printer的细节描述

就是lldb使用 sythentic child provider提供format

https://lldb.llvm.org/use/variable.html#synthetic-children

这里也说明了原因在于g++的容器没有完全提供formmatter,比如set,lldb提供了下面的命令

(lldb) type synthetic info myVec
synthetic applied to (std::vector<std::basic_string<char, std::char_traits<ch
(lldb) type synthetic list
···
^std::vector<.+>(( )?&)?$:  Python class lldb.formatters.cpp.gnu_libstdcpp.StdVectorSynthProvider
···

我list了一下

···
Category: cplusplus
-----------------------
^std::vector<.+>(( )?&)?$:  Python class lldb.formatters.cpp.gnu_libstdcpp.StdVectorSynthProvider
^std::map<.+> >(( )?&)?$:  Python class lldb.formatters.cpp.gnu_libstdcpp.StdMapSynthProvider
^std::(__cxx11::)?list<.+>(( )?&)?$:  Python class lldb.formatters.cpp.gnu_libstdcpp.StdListSynthProvider
···

好像的确没有set

TODO : 使用gdb printer

举报

相关推荐

0 条评论