This is the mail archive of the
gdb@sourceware.org
mailing list for the GDB project.
pretty printer for pointers
- From: graham <graham dot labdon at avalonsciences dot com>
- To: gdb at sources dot redhat dot com
- Date: Tue, 19 Jun 2012 08:27:32 +0000 (UTC)
- Subject: pretty printer for pointers
Hi
I am trying to write some pretty printers for Qt types. I have had some success
but want to pretty print pointers to classes.
I have a printer for the type QTextDocument and want an equivalent for a pointer
to this type.
In the non printer version of the printer I have lines such as this
def children(self):
yield "isEmpty",callClassMethod(self.val,"isEmpty","")
Which works as expected
Now I want to do the same in the pointer equivalent printer but cannot see how
to do this
I have tried many things including this
def children(self):
data2 = self.val.dereference()
ptype2 = gdb.lookup_type("QTextDocument").pointer()
yield
"isEmpty",callClassMethod(data2.cast(ptype2).dereference(),"isEmpty","")
but this results in an infinite loop
My implementation of the callClassMethod function is
def callClassMethod (value,func,args):
type = value.type
#type = type.unqualified ().strip_typedefs ()
#print "type %s" % type
exp = "((class %s*)%s)->%s()" % (type, value.address, func)
print "exp = %s" % exp
#print("CALL: %s" % exp)
result = None
try:
result = gdb.parse_and_eval(exp)
except:
print "pass"
pass
#print(" -> %s" % result)
return result
I would be grateful if someone could help me solve this issue
Thanks in advance
Graham