This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] Add pretty-printer for CORE_ADDR


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/gdb-gdb.py.in | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/gdb/gdb-gdb.py.in b/gdb/gdb-gdb.py.in
index cde6068..aeaf69d 100644
--- a/gdb/gdb-gdb.py.in
+++ b/gdb/gdb-gdb.py.in
@@ -222,6 +222,16 @@ class StructMainTypePrettyPrinter:
 
         return "\n{" + ",\n ".join(fields) + "}"
 
+
+class CoreAddrPrettyPrinter:
+
+    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 +240,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):
-- 
2.7.4


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]