【问题标题】:stl(libcxx) renderers in Xcode debugXcode 调试中的 stl(libcxx) 渲染器
【发布时间】:2018-08-04 19:47:47
【问题描述】:

测试用例很简单:只是带有一些元素的 std::vector。在调试会话期间,我什至看不到向量的大小,根据 lldb 为 0。

我用谷歌搜索了很多,我只发现 lldb 使用 libcxx.py 脚本使调试开发人员友好:

def update(self):
    logger = lldb.formatters.Logger.Logger()
    try:
        self.start = self.valobj.GetChildMemberWithName('__begin_')
        self.finish = self.valobj.GetChildMemberWithName('__end_')
        # the purpose of this field is unclear, but it is the only field whose type is clearly T* for a vector<T>
        # if this ends up not being correct, we can use the APIs to get at
        # template arguments
        data_type_finder = self.valobj.GetChildMemberWithName(
            '__end_cap_').GetChildMemberWithName('__first_')
        self.data_type = data_type_finder.GetType().GetPointeeType()
        self.data_size = self.data_type.GetByteSize()
    except:
        pass

这看起来已经过时了,我觉得要为所有容器完善此脚本中的所有内容需要做大量工作。我不敢相信2018年有这么多痛苦:(

这个python脚本的头部还写着:

与当前版本的 OS X 一起提供 - 它们不适用于其他实现 标准 C++ 库的 - 他们一定会使用 libc++ 特定的命名空间

也许有一个版本的 macOS 附带兼容的 libc++ 和格式化程序?

现在我使用的是 macOS 10.13.4、Xcode 9.4.1,我需要 c++17 支持。

【问题讨论】:

    标签: xcode macos lldb libc++


    【解决方案1】:

    不久前,stl 数据格式化程序从基于 python 的程序转移到了内置的 C++ 程序。当前向量一在这里,如果你有兴趣:

    http://llvm.org/svn/llvm-project/lldb/trunk/source/Plugins/Language/CPlusPlus/LibCxxVector.cpp

    留下的 Python 版本作为您可以在数据格式化程序中执行的操作的示例。

    我没有容易获得的 9.4,但我尝试了 10.0 beta 和 lldb 在使用 -std=c++17 编译时正确打印 std::vectors。如果这不是您的经验,请使用 http://bugreporter.apple.comhttp://bugs.llvm.org 提交错误,并附上您失败的示例。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-11-30
      • 2017-02-18
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-07-13
      • 2017-02-02
      • 1970-01-01
      相关资源
      最近更新 更多