如何打印<不完整的类型>在gdb中变量 [英] How to print <incomplete type> variable in gdb
问题描述
这意味着该变量的类型没有完全指定。例如:
struct hatstand;
struct hatstand * foo;
GDB知道 foo
是一个指向一个 hatstand
结构,但该结构的成员尚未定义。因此,不完整的类型。
要打印该值,可以将其转换为兼容的类型。
例如,如果您知道 foo
确实是指向 lampshade
结构的指针:
print(struct lampshade *)foo
或者,您可以将其打印为通用指针,或将其视为一个整数:
print (void *)foo
print(int)foo
另请参阅GDB中的这些页面手册:
Sometimes gdb prints "incomplete type" for some type of variables. What does this mean and how can we see that value?
It means that the type of that variable has been incompletely specified. For example:
struct hatstand;
struct hatstand *foo;
GDB knows that foo
is a pointer to a hatstand
structure, but the members of that structure haven't been defined. Hence, "incomplete type".
To print the value, you can cast it to a compatible type.
For example, if you know that foo
is really a pointer to a lampshade
structure:
print (struct lampshade *)foo
Or, you could print it as a generic pointer, or treat it as if it were an integer:
print (void *)foo
print (int)foo
See also these pages from the GDB manual:
- http://sourceware.org/gdb/current/onlinedocs/gdb/Data.html#Data
- http://sourceware.org/gdb/current/onlinedocs/gdb/Symbols.html#Symbols
这篇关于如何打印<不完整的类型>在gdb中变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!