C++ 从whatis返回的GDB set变量
GDB whatis返回变量的类型。 我想知道如何使用这个结果作为变量C++ 从whatis返回的GDB set变量,c++,debugging,stl,gdb,C++,Debugging,Stl,Gdb,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 我想使用上述从通用内存地址到模板类类型(名称非常长)的转换 而且转换类型非常多变,调试时很难将每
(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
我想使用上述从通用内存地址到模板类类型(名称非常长)的转换
而且转换类型非常多变,调试时很难将每个名称都放进去。无法将类型分配给方便变量。但是,您可以通过将值保存在方便变量中,然后使用
typeof
:
(gdb) set $x = 23ll
(gdb) ptype $x
type = long long
(gdb) ptype (typeof($x))'z'
type = long long
谢谢我很高兴看到这个答案!不再按ctrl键c+v!!