pretty printer for pointers

Tue Jun 19 09:15:00 GMT 2012

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()

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
        result = gdb.parse_and_eval(exp)
        print "pass"
    #print("  -> %s" % result)
    return result

I would be grateful if someone could help me solve this issue

Thanks in advance


More information about the Gdb mailing list