From: Jan Kratochvil <jan.kratochvil@redhat.com>
To: gdb-patches@sourceware.org
Subject: [patch 1/2] gdb-gdb.py: Make the fields copy-paste friendly
Date: Fri, 15 Jan 2010 19:28:00 -0000 [thread overview]
Message-ID: <20100115192840.GB4324@host0.dyn.jankratochvil.net> (raw)
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 <jan.kratochvil@redhat.com>
* 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']):
next reply other threads:[~2010-01-15 19:28 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-01-15 19:28 Jan Kratochvil [this message]
2010-01-15 19:49 ` Tom Tromey
2010-01-15 19:56 ` Jan Kratochvil
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=20100115192840.GB4324@host0.dyn.jankratochvil.net \
--to=jan.kratochvil@redhat.com \
--cc=gdb-patches@sourceware.org \
/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