【发布时间】: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 支持。
【问题讨论】: