在GDB中打印子类成员 [英] Printing Sub-Class Members in GDB
本文介绍了在GDB中打印子类成员的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
GDB中是否存在一个设置,该设置会自动从基类指针中打印(C ++)子类的所有成员,还是我总是必须在取消引用它之前将其强制转换为子类指针.
Is there a setting in GDB that automatically prints all the members of a (C++) subclass from base-class pointer or do I always have to cast it to the sub-class pointer before dereferencing it.
那是我并不总是想做的事:
That is I don't always want to do:
p *(SubClass*)baseClassInstance
推荐答案
set print object
show print object
Choose whether to print derived (actual) or declared types of objects.
我想set print object
是您所需要的,但它仅适用于多态类型.
I guess set print object
is what you need but it works only for polymorphic types.
http://www.delorie.com/gnu/docs/gdb/gdb_106.html
这篇关于在GDB中打印子类成员的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文