Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: "Tedeschi, Walfred" <walfred.tedeschi@intel.com>
To: Doug Evans <dje@google.com>
Cc: "palves@redhat.com" <palves@redhat.com>,
	"mark.kettenis@xs4all.nl"	<mark.kettenis@xs4all.nl>,
	"gdb-patches@sourceware.org"	<gdb-patches@sourceware.org>
Subject: RE: [PATCH, PR 17364] Need better printer names in bound_register.py
Date: Fri, 10 Oct 2014 06:58:00 -0000	[thread overview]
Message-ID: <AC542571535E904D8E8ADAE745D60B192F92F627@IRSMSX104.ger.corp.intel.com> (raw)
In-Reply-To: <21558.50988.529374.214950@ruffy2.mtv.corp.google.com>

Hello Doug,

Thanks a lot for the nice and detailed explanation. I am fine to stick with the patch you mentioned.

Grouping the pretty-printers is indeed a nice idea!
Sorry for having taking some time to answer to the defect. I usually try to answer quick! :(

Do you think we should after that think about a mechanism to add this printer according to the architecture?

Thanks again and best regards,
-Fred


-----Original Message-----
From: Doug Evans [mailto:dje@google.com] 
Sent: Thursday, October 09, 2014 7:35 PM
To: Tedeschi, Walfred
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

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).

Intel GmbH
Dornacher Strasse 1
85622 Feldkirchen/Muenchen, Deutschland
Sitz der Gesellschaft: Feldkirchen bei Muenchen
Geschaeftsfuehrer: Christian Lamprechter, Hannes Schwaderer, Douglas Lusk
Registergericht: Muenchen HRB 47456
Ust.-IdNr./VAT Registration No.: DE129385895
Citibank Frankfurt a.M. (BLZ 502 109 00) 600119052


  reply	other threads:[~2014-10-10  6:58 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
2014-10-10  6:58   ` Tedeschi, Walfred [this message]
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=AC542571535E904D8E8ADAE745D60B192F92F627@IRSMSX104.ger.corp.intel.com \
    --to=walfred.tedeschi@intel.com \
    --cc=dje@google.com \
    --cc=gdb-patches@sourceware.org \
    --cc=mark.kettenis@xs4all.nl \
    --cc=palves@redhat.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