From: Simon Marchi <simon.marchi@ericsson.com>
To: <gdb-patches@sourceware.org>
Cc: Simon Marchi <simon.marchi@ericsson.com>
Subject: [PATCH] Add pretty-printer for CORE_ADDR
Date: Wed, 27 Jun 2018 19:05:00 -0000 [thread overview]
Message-ID: <1530126295-3218-1-git-send-email-simon.marchi@ericsson.com> (raw)
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
next reply other threads:[~2018-06-27 19:05 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-06-27 19:05 Simon Marchi [this message]
2018-06-27 19:18 ` Pedro Alves
2018-06-27 19:25 ` Simon Marchi
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1530126295-3218-1-git-send-email-simon.marchi@ericsson.com \
--to=simon.marchi@ericsson.com \
--cc=gdb-patches@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).