This is the mail archive of the
gdb-cvs@sourceware.org
mailing list for the GDB project.
[binutils-gdb] Add pretty-printer for CORE_ADDR
- From: Simon Marchi <simark at sourceware dot org>
- To: gdb-cvs at sourceware dot org
- Date: 27 Jun 2018 19:25:24 -0000
- Subject: [binutils-gdb] Add pretty-printer for CORE_ADDR
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=9a14af7b1a6765a353d4bf710d267a1c47a162fb
commit 9a14af7b1a6765a353d4bf710d267a1c47a162fb
Author: Simon Marchi <simon.marchi@ericsson.com>
Date: Wed Jun 27 15:21:47 2018 -0400
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.
Diff:
---
gdb/ChangeLog | 5 +++++
gdb/gdb-gdb.py.in | 13 +++++++++++++
2 files changed, 18 insertions(+)
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 18c1915..d8bae23 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,10 @@
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
print tag_name.
diff --git a/gdb/gdb-gdb.py.in b/gdb/gdb-gdb.py.in
index cde6068..436f05c 100644
--- a/gdb/gdb-gdb.py.in
+++ b/gdb/gdb-gdb.py.in
@@ -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):