From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 29029 invoked by alias); 15 Jan 2010 19:28:50 -0000 Received: (qmail 29016 invoked by uid 22791); 15 Jan 2010 19:28:49 -0000 X-SWARE-Spam-Status: No, hits=-2.4 required=5.0 tests=AWL,BAYES_00,SPF_HELO_PASS,SPF_PASS 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; Fri, 15 Jan 2010 19:28:44 +0000 Received: from int-mx04.intmail.prod.int.phx2.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.17]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o0FJShgV011600 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Fri, 15 Jan 2010 14:28:43 -0500 Received: from host0.dyn.jankratochvil.net (ovpn01.gateway.prod.ext.phx2.redhat.com [10.5.9.1]) by int-mx04.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o0FJSfkP031643 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Fri, 15 Jan 2010 14:28:43 -0500 Received: from host0.dyn.jankratochvil.net (localhost [127.0.0.1]) by host0.dyn.jankratochvil.net (8.14.3/8.14.3) with ESMTP id o0FJSeV4005951 for ; Fri, 15 Jan 2010 20:28:40 +0100 Received: (from jkratoch@localhost) by host0.dyn.jankratochvil.net (8.14.3/8.14.3/Submit) id o0FJSehh005950 for gdb-patches@sourceware.org; Fri, 15 Jan 2010 20:28:40 +0100 Date: Fri, 15 Jan 2010 19:28:00 -0000 From: Jan Kratochvil To: gdb-patches@sourceware.org Subject: [patch 1/2] gdb-gdb.py: Make the fields copy-paste friendly Message-ID: <20100115192840.GB4324@host0.dyn.jankratochvil.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.20 (2009-08-17) 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: 2010-01/txt/msg00414.txt.bz2 Hi, I would like to copy-paste the fields when I am not allowed to click on them in CLI. This patch makes the copy-pasting more friendly such as I can do: (gdb) p *(struct type *) 0x1dfabf0 Without having to figure out first target_type has type `struct type *'. The same applies to "field[x]:" which may not be clear for the user one has to translate into "flds_bnds.fields[x]." to access the printed fields (for further dereferencing). But such printing should be probably more integrated into the framework if approved than doing it this way in each case. Regards, Jan before: $1 = {name = 0x0, tag_name = 0x0, code = TYPE_CODE_RANGE, flags = [unsigned|objfile_owned], owner = 0x1de89b0 (objfile), target_type = 0x1dfabf0, vptr_basetype = 0x0, bounds = {0, 8}, type_specific_field = TYPE_SPECIFIC_NONE} after: $1 = {name = 0x0, tag_name = 0x0, code = TYPE_CODE_RANGE, flags = [unsigned|objfile_owned], owner = (struct objfile *) 0x1de89b0, target_type = (struct type *) 0x1dfabf0, vptr_basetype = 0x0, bounds = {0, 8}, type_specific_field = TYPE_SPECIFIC_NONE} 2010-01-15 Jan Kratochvil * gdb-gdb.py: Use `(type *) address' copy-paste notation. Rename `field[%d]:' to `flds_bnds.fields[%d].'. --- ./gdb/gdb-gdb.py-range 2010-01-15 20:10:29.000000000 +0100 +++ ./gdb/gdb-gdb.py 2010-01-15 20:13:38.000000000 +0100 @@ -118,7 +118,7 @@ class StructTypePrettyPrinter: fields.append("instance_flags = %s" % TypeFlagsPrinter(self.val['instance_flags'])) fields.append("length = %d" % self.val['length']) - fields.append("main_type = %s" % self.val['main_type']) + fields.append("main_type = (%s) %s" % (self.val['main_type'].type, self.val['main_type'])) return "\n{" + ",\n ".join(fields) + "}" class StructMainTypePrettyPrinter: @@ -143,9 +143,9 @@ class StructMainTypePrettyPrinter: """Return an image of component "owner". """ if self.val['flag_objfile_owned'] != 0: - return "%s (objfile)" % self.val['owner']['objfile'] + return "(%s) %s" % (self.val['owner']['objfile'].type, self.val['owner']['objfile']) else: - return "%s (gdbarch)" % self.val['owner']['gdbarch'] + return "(%s) %s" % (self.val['owner']['gdbarch'].type, self.val['owner']['gdbarch']) def struct_field_location_img(self, field_val): """Return an image of the loc component inside the given field gdb.Value. @@ -166,12 +166,12 @@ 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 = [] fields.append("name = %s" % f['name']) - fields.append("type = %s" % f['type']) + fields.append("type = (%s) %s" % (f['type'].type, f['type'])) fields.append("loc_kind = %s" % f['loc_kind']) fields.append("bitsize = %d" % f['bitsize']) fields.append(self.struct_field_location_img(f)) @@ -220,7 +220,7 @@ class StructMainTypePrettyPrinter: fields.append("code = %s" % self.val['code']) fields.append("flags = [%s]" % self.flags_to_string()) fields.append("owner = %s" % self.owner_to_string()) - fields.append("target_type = %s" % self.val['target_type']) + fields.append("target_type = (%s) %s" % (self.val['target_type'].type, self.val['target_type'])) fields.append("vptr_basetype = %s" % self.val['vptr_basetype']) if self.val['nfields'] > 0: for fieldno in range(self.val['nfields']):