From: graham <graham.labdon@avalonsciences.com>
To: gdb@sources.redhat.com
Subject: pretty printer for pointers
Date: Tue, 19 Jun 2012 09:15:00 -0000 [thread overview]
Message-ID: <loom.20120619T094622-441@post.gmane.org> (raw)
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
next reply other threads:[~2012-06-19 9:15 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-06-19 9:15 graham [this message]
2012-06-21 13:57 ` Joachim Protze
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=loom.20120619T094622-441@post.gmane.org \
--to=graham.labdon@avalonsciences.com \
--cc=gdb@sources.redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).