This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
[PATCH, PR 17364] Need better printer names in bound_register.py
- From: Walfred Tedeschi <walfred dot tedeschi at intel dot com>
- To: palves at redhat dot com, mark dot kettenis at xs4all dot nl
- Cc: gdb-patches at sourceware dot org, Walfred Tedeschi <walfred dot tedeschi at intel dot com>
- Date: Tue, 30 Sep 2014 09:28:53 +0200
- Subject: [PATCH, PR 17364] Need better printer names in bound_register.py
- Authentication-results: sourceware.org; auth=none
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