* [PATCH] Add pretty-printer for CORE_ADDR
@ 2018-06-27 19:05 Simon Marchi
2018-06-27 19:18 ` Pedro Alves
0 siblings, 1 reply; 3+ messages in thread
From: Simon Marchi @ 2018-06-27 19:05 UTC (permalink / raw)
To: gdb-patches; +Cc: Simon Marchi
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
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2018-06-27 19:25 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-06-27 19:05 [PATCH] Add pretty-printer for CORE_ADDR Simon Marchi
2018-06-27 19:18 ` Pedro Alves
2018-06-27 19:25 ` Simon Marchi
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).