From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 32306 invoked by alias); 19 Jun 2012 09:15:26 -0000 Received: (qmail 32293 invoked by uid 22791); 19 Jun 2012 09:15:24 -0000 X-SWARE-Spam-Status: No, hits=-0.8 required=5.0 tests=BAYES_00,RCVD_IN_HOSTKARMA_NO,RCVD_NUMERIC_HELO,SPF_HELO_PASS,T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from plane.gmane.org (HELO plane.gmane.org) (80.91.229.3) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 19 Jun 2012 09:15:12 +0000 Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1SguWf-0007nB-PZ for gdb@sources.redhat.com; Tue, 19 Jun 2012 11:15:05 +0200 Received: from 91.85.219.222 ([91.85.219.222]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Tue, 19 Jun 2012 11:15:05 +0200 Received: from graham.labdon by 91.85.219.222 with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Tue, 19 Jun 2012 11:15:05 +0200 To: gdb@sources.redhat.com From: graham Subject: pretty printer for pointers Date: Tue, 19 Jun 2012 09:15:00 -0000 Message-ID: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit User-Agent: Loom/3.14 (http://gmane.org/) X-IsSubscribed: yes Mailing-List: contact gdb-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-owner@sourceware.org X-SW-Source: 2012-06/txt/msg00075.txt.bz2 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