[PATCH, PR 17364] Need better printer names in bound_register.py
Walfred Tedeschi
walfred.tedeschi@intel.com
Tue Sep 30 07:29:00 GMT 2014
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
More information about the Gdb-patches
mailing list