public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [PATCH, PR 17364] Need better printer names in bound_register.py
@ 2014-09-30  7:29 Walfred Tedeschi
  2014-10-09 17:34 ` Doug Evans
  0 siblings, 1 reply; 4+ messages in thread
From: Walfred Tedeschi @ 2014-09-30  7:29 UTC (permalink / raw)
  To: palves, mark.kettenis; +Cc: gdb-patches, Walfred Tedeschi

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

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2014-10-15 20:28 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-09-30  7:29 [PATCH, PR 17364] Need better printer names in bound_register.py Walfred Tedeschi
2014-10-09 17:34 ` Doug Evans
2014-10-10  6:58   ` Tedeschi, Walfred
2014-10-15 20:28     ` Doug Evans

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