From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 11080 invoked by alias); 9 Feb 2012 09:28:15 -0000 Received: (qmail 11070 invoked by uid 22791); 9 Feb 2012 09:28:15 -0000 X-SWARE-Spam-Status: No, hits=-6.6 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_HI,SPF_HELO_PASS,T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 09 Feb 2012 09:27:57 +0000 Received: from int-mx12.intmail.prod.int.phx2.redhat.com (int-mx12.intmail.prod.int.phx2.redhat.com [10.5.11.25]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id q199RW9w030995 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Thu, 9 Feb 2012 04:27:35 -0500 Received: from host2.jankratochvil.net (ovpn-116-26.ams2.redhat.com [10.36.116.26]) by int-mx12.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id q199RSUg015824 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES128-SHA bits=128 verify=NO); Thu, 9 Feb 2012 04:27:31 -0500 Date: Thu, 09 Feb 2012 09:28:00 -0000 From: Jan Kratochvil To: gdb-patches@sourceware.org Cc: Joel Brobecker Subject: [patch] Fix gdb-gdb.py for flds_bnds copy-pastes Message-ID: <20120209092727.GA2664@host2.jankratochvil.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) X-IsSubscribed: yes Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2012-02/txt/msg00134.txt.bz2 Hi, one such a longstanding pain - accessing pretty-printed field name does not work: (gdb) p *type.main_type $2 = {name = 0x0, [...] field[0]: ######## {name = 0x2115978 "i", [...] bitpos = 0}, cplus_stuff = 0xf33b80} (gdb) p/r *type.main_type $3 = {code = TYPE_CODE_STRUCT, [...] target_type = 0x0, flds_bnds = {fields = 0x21161f0, bounds = 0x21161f0}, #################################################### [...], func_stuff = 0xf33b80}} (gdb) p type.main_type.field[0] ######## There is no member named field. ############################### (gdb) p type.main_type.fields[0] ######### There is no member named fields. ################################ (gdb) p type.main_type.flds_bnds.fields[0] ################### $3 = {loc = {bitpos = 0, physaddr = 0, [...], name = 0x2115978 "i"} Probably clear to check it in. I had to `print/r' to suppress gdb-gdb.py to ba able to access GDB types fields. Thanks, Jan gdb/ 2012-02-09 Jan Kratochvil * gdb-gdb.py (StructMainTypePrettyPrinter) : Print flds_bnds.fields. (StructMainTypePrettyPrinter) : Print flds_bnds.bounds. --- a/gdb/gdb-gdb.py +++ b/gdb/gdb-gdb.py @@ -166,7 +166,7 @@ class StructMainTypePrettyPrinter: """Return an image of the main_type field number FIELDNO. """ f = self.val['flds_bnds']['fields'][fieldno] - label = "field[%d]:" % fieldno + label = "flds_bnds.fields[%d]:" % fieldno if f['artificial']: label += " (artificial)" fields = [] @@ -186,7 +186,7 @@ class StructMainTypePrettyPrinter: high = str(b['high']) if b['high_undefined'] != 0: high += " (undefined)" - return "bounds = {%s, %s}" % (low, high) + return "flds_bnds.bounds = {%s, %s}" % (low, high) def type_specific_img(self): """Return a string image of the main_type type_specific union. Only the relevant component of that union is printed (based on