public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Doug Evans <dje@google.com>
To: Walfred Tedeschi <walfred.tedeschi@intel.com>
Cc: palves@redhat.com,    mark.kettenis@xs4all.nl,
	   gdb-patches@sourceware.org
Subject: Re: [PATCH, PR 17364] Need better printer names in bound_register.py
Date: Thu, 09 Oct 2014 17:34:00 -0000	[thread overview]
Message-ID: <21558.50988.529374.214950@ruffy2.mtv.corp.google.com> (raw)
In-Reply-To: <1412062133-22469-1-git-send-email-walfred.tedeschi@intel.com>

Walfred Tedeschi writes:
 > Moved the printer to the global scope and changed the name of the
 > printer to a more specific name.
 > 
 > 2014.09.11  Walfred Tedeschi  <walfred.tedeschi@intel.com>
 > 
 > python/lib/gdb/command:
 > 
 > 	* bound_registers.py (mpx_bound_reg_printer) Added function to
 > 	register pretty-printing for bound registers, and fixed comments.
 > 	(build_pretty_printer) Removed.

Hi.

fwiw, I kinda like grouping together all the pretty-printers provided by gdb.
See https://sourceware.org/ml/gdb-patches/2014-10/msg00081.html

Using RegexpCollectionPrettyPrinter is a bit of overkill since there are no
templates, at least not yet.  We could certainly add
SimpleCollectionPrettyPrinter or some such that just did string comparisons
on tag names instead of regexps, but since this is all implementation detail
we could defer this.

 > +def mpx_bound_reg_printer (val):
 > +    lookup_tag = val.type.tag
 > +    if lookup_tag == None:
 > +        return None
 > +    if lookup_tag == "__gdb_builtin_type_bound128":
 > +        return BoundPrinter (val)

Random comments:

1) "lookup_tag" is a bit confusing as there is no lookup done here.
I'd rename it to just val_type_tag or some such.
[Assuming we keep this version.]

2) "mpx" is presumably enough to distinguish this pretty-printer from other
arch's bounds reg pretty-printers (probably a better choice than "x86" too).

3) If I do "info pretty" I see this:

global pretty-printers:
  mpx_bound_reg_printer

Having "printer" in the name is superfluous, thus if one was to do
things this way I'd rename mpx_bound_reg_printer to mpx_bound_reg.
That way the user can do "disable pretty-printer global mpx_bound_reg".

4) It might be preferable to pick a name closer to the actual type's name:
"mpx_bound128" ?

[digression:
Registering printers as functions was how pretty-printers were originally
added, but it turned out to be insufficient: printers need to be disableable
and thus need names.  OTOH one tends to think of the name of the function
here as an implementation detail, except that it isn't.]

---

Going forward,
I like the idea of providing basic infrastructure for grouping builtin
pretty-printers together and using that for 17364.
Plus this file really doesn't belong in python/lib/gdb/command.

I propose sticking with this patch
https://sourceware.org/ml/gdb-patches/2014-10/msg00081.html
but I'm happy to tweak it as desired (e.g. use "mpx_bound128" as the name).

  reply	other threads:[~2014-10-09 17:34 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-09-30  7:29 Walfred Tedeschi
2014-10-09 17:34 ` Doug Evans [this message]
2014-10-10  6:58   ` Tedeschi, Walfred
2014-10-15 20:28     ` Doug Evans

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=21558.50988.529374.214950@ruffy2.mtv.corp.google.com \
    --to=dje@google.com \
    --cc=gdb-patches@sourceware.org \
    --cc=mark.kettenis@xs4all.nl \
    --cc=palves@redhat.com \
    --cc=walfred.tedeschi@intel.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).