lldb 可以显示类型定义的实际类型吗?
Can lldb show the actual type of a typedef?
我正在调试一些模板代码,并希望lldb向我显示帧变量的实际类型(c类型),而不是极其复杂的typedef。实际类型类似于"int"或"无符号字符",但它只向我显示 typedef,就好像它不知道特定的模板实例一样。
例如:
template <typename T>
struct helper
{
using type = long;
};
int main(int argc, const char * argv[]) {
using var_t = typename helper<short>::type;
var_t foo = 1;
}
在"var_t foo = 1"上设置的断点处停止显示
foo = (var_t)0
我真的需要看到类似的东西
foo = (long)0
有没有办法做到这一点,或者找出解析的类型是什么?
我正在使用 XCode 7.3 和 lldb-350.0.21.3
无法
告诉变量打印机显示解析的类型而不是变量的声明类型。 您可以使用 image lookup
的类型搜索模式找出 typedef 的解析类型是什么:
(lldb) image lookup -t var_t
1 match found in /private/tmp/foo:
id = {0x000000b2}, name = "var_t", byte-size = 8, decl = foo.cpp:9, compiler_type = "typedef var_t"
typedef 'var_t': id = {0x00000043}, name = "helper<short>::type", byte-size = 8, decl = foo.cpp:4, compiler_type = "typedef helper<short>::type"
typedef 'helper<short>::type': id = {0x000000eb}, name = "long int", qualified = "long", byte-size = 8, compiler_type = "long"
如果你想使用它,这是从Python API获取相同信息的另一种方法:
(lldb) script
Python Interactive Interpreter. To exit, type 'quit()', 'exit()' or Ctrl-D.
>>> foo_var = lldb.frame.FindVariable("foo")
>>> foo_type = foo_var.GetType()
>>> print foo_type
typedef var_t
>>> print foo_type.GetCanonicalType()
long
如果这是你需要做很多的事情,你可以编写一个基于 Python 的 lldb 命令来打印完全解析的类型。这里有信息:
http://lldb.llvm.org/python-reference.html
关于如何做到这一点。
相关文章:
- 有没有一种方法可以通过"typedef"为重新定义的基本类型定义特征和强制转换运算符
- 强枚举类型定义:Clang Bug 还是 C++11 标准不确定性?
- 列表参数的类型定义
- 使用模板化的键类型定义 std::map,该键类型基于作为参数接收的函数
- 关于 C++ 中的函数类型定义
- C++(和 ROS) - 包含与前向声明引用,设置默认值和类型定义
- 将使用/类型定义限制为类范围
- 模板类型定义?
- C++:模板类的类型定义
- 如何对命名空间限定类型进行类型定义?
- 此递归模板类型定义是否有效C++?
- 具有调整对齐方式的类型定义
- C++从抽象类型定义类成员
- 用于C++代码的 API 监视器类型定义 (XML)
- 如何将result_of与函数类型定义一起使用
- 在C++的适当类型定义位置
- 如何根据模板类型定义浮点常量?
- 如何为缺少预定义运算符而不扩展命名空间"std"的标准类型定义运算符>> (istream &, ...)?
- 参数化类的别名(或类型定义)内部类
- 如果我想从类型"T"定义元素的容器(来自 STL),那么"T"必须使用默认构造函数?