GDB whatis返回变量的类型。 我想知道如何将此结果用作变量。
(gdb) whatis myIntValue
int
(gdb) set $typeInt = whatis myIntValue // it's impossible but what I want
(gdb) p *($typeInt)0xabcd // this address having an int value
我想使用上面的通用内存地址转换为模板类类型(名称非常长)。
并且转换类型非常不同,在调试时很难放入每个名称。
答案 0 :(得分:1)
无法为便利变量分配类型。但是,您可以通过将值保存在便捷变量中然后使用typeof
:
(gdb) set $x = 23ll
(gdb) ptype $x
type = long long
(gdb) ptype (typeof($x))'z'
type = long long