Add pretty-printer for CORE_ADDR
Commit Message
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(+)
Comments
On 06/27/2018 08:04 PM, Simon Marchi wrote:
> Add a pretty-printer that prints CORE_ADDR values in hex.
Yes please!
Thanks,
Pedro Alves
On 2018-06-27 15:18, Pedro Alves wrote:
> On 06/27/2018 08:04 PM, Simon Marchi wrote:
>> Add a pretty-printer that prints CORE_ADDR values in hex.
>
> Yes please!
Thanks, pushed.
Simon
@@ -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):