Add pretty-printer for CORE_ADDR
authorSimon Marchi <simon.marchi@ericsson.com>
Wed, 27 Jun 2018 19:21:47 +0000 (15:21 -0400)
committerSimon Marchi <simon.marchi@ericsson.com>
Wed, 27 Jun 2018 19:21:47 +0000 (15:21 -0400)
Add a pretty-printer that prints CORE_ADDR values in hex.

gdb/ChangeLog:

* gdb-gdb.py.in (CoreAddrPrettyPrinter): New class.
(type_lookup_function): Recognize CORE_ADDR values.

gdb/ChangeLog
gdb/gdb-gdb.py.in

index 18c1915675fe4e0d9fcfefd68806fb97088caaef..d8bae2310fd8918e6c7f48f19c97a6e4f8c9cf26 100644 (file)
@@ -1,3 +1,8 @@
+2018-06-27  Simon Marchi  <simon.marchi@ericsson.com>
+
+       * gdb-gdb.py.in (CoreAddrPrettyPrinter): New class.
+       (type_lookup_function): Recognize CORE_ADDR values.
+
 2018-06-27  Simon Marchi  <simon.marchi@ericsson.com>
 
        * gdb-gdb.py.in (StructMainTypePrettyPrinter) <to_string>: Don't
index cde6068b4dc78783291b29b97bda937826e39e50..436f05cc6555723a00cc5e819ac47e6b79ebda2f 100644 (file)
@@ -222,6 +222,17 @@ class StructMainTypePrettyPrinter:
 
         return "\n{" + ",\n ".join(fields) + "}"
 
+
+class CoreAddrPrettyPrinter:
+    """Print CORE_ADDR values as hex."""
+
+    def __init__(self, val):
+        self._val = val
+
+    def to_string(self):
+        return hex(int(self._val))
+
+
 def type_lookup_function(val):
     """A routine that returns the correct pretty printer for VAL
     if appropriate.  Returns None otherwise.
@@ -230,6 +241,8 @@ def type_lookup_function(val):
         return StructTypePrettyPrinter(val)
     elif val.type.tag == "main_type":
         return StructMainTypePrettyPrinter(val)
+    elif val.type.name == 'CORE_ADDR':
+        return CoreAddrPrettyPrinter(val)
     return None
 
 def register_pretty_printer(objfile):