如何打印<不完整的类型>在gdb中变量 [英] How to print <incomplete type> variable in gdb

查看:921
本文介绍了如何打印<不完整的类型>在gdb中变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有时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:

这篇关于如何打印<不完整的类型>在gdb中变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆