Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Walfred Tedeschi <walfred.tedeschi@intel.com>
To: palves@redhat.com, mark.kettenis@xs4all.nl
Cc: gdb-patches@sourceware.org,
	Walfred Tedeschi <walfred.tedeschi@intel.com>
Subject: [PATCH, PR 17364] Need better printer names in bound_register.py
Date: Tue, 30 Sep 2014 07:29:00 -0000	[thread overview]
Message-ID: <1412062133-22469-1-git-send-email-walfred.tedeschi@intel.com> (raw)

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.

---
 gdb/python/lib/gdb/command/bound_registers.py | 23 +++++++++++------------
 1 file changed, 11 insertions(+), 12 deletions(-)

diff --git a/gdb/python/lib/gdb/command/bound_registers.py b/gdb/python/lib/gdb/command/bound_registers.py
index 24d4c45..6f2dbc6 100644
--- a/gdb/python/lib/gdb/command/bound_registers.py
+++ b/gdb/python/lib/gdb/command/bound_registers.py
@@ -16,8 +16,8 @@
 
 import gdb.printing
 
-class BoundPrinter:
-    """Adds size field to a _rawbound128 type."""
+class BoundPrinter (object):
+    """Adds size field to a  __gdb_builtin_type_bound128 type."""
 
     def __init__ (self, val):
         self.val = val
@@ -31,15 +31,14 @@ class BoundPrinter:
         result = '{lbound = %s, ubound = %s} : size %s' % (lower, upper, size)
         return result
 
-# There are two pattern matching used: first one is related to a library
-# second is related to the type. Since we are displaying a register all
-# libraries are accepted. Type to be processed is the same present
-# in the xml file.
+# Register a global pretty-printer for the bnd[0..3] pseudo
+# register.
 
-def build_pretty_printer ():
-    pp = gdb.printing.RegexpCollectionPrettyPrinter (".*")
-    pp.add_printer ('bound', '^__gdb_builtin_type_bound128', BoundPrinter)
-    return pp
+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)
 
-gdb.printing.register_pretty_printer (gdb.current_objfile (),
-                                      build_pretty_printer ())
+gdb.pretty_printers.append (mpx_bound_reg_printer)
-- 
1.9.1


             reply	other threads:[~2014-09-30  7:29 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-09-30  7:29 Walfred Tedeschi [this message]
2014-10-09 17:34 ` Doug Evans
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=1412062133-22469-1-git-send-email-walfred.tedeschi@intel.com \
    --to=walfred.tedeschi@intel.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