From: Luis Machado <lgustavo@codesourcery.com>
To: <gdb-patches@sourceware.org>
Subject: [PATCH v2 1/3] Add zero-padded hexadecimal format support for varobj's
Date: Thu, 07 May 2015 17:37:00 -0000 [thread overview]
Message-ID: <1431020207-14371-2-git-send-email-lgustavo@codesourcery.com> (raw)
In-Reply-To: <1431020207-14371-1-git-send-email-lgustavo@codesourcery.com>
This patch changes things so that we can support zero-padded hexadecimal
formats for varobj's. The new type is "zero-hexadecimal" and maps to GDB's 'z'
print format.
Ideally we would share all the formats we currently support with the MI/varobj
layer, but this requires a bit more work. Meanwhile, adding a new mapping seems
to work.
gdb/ChangeLog:
2015-05-07 Luis Machado <lgustavo@codesourcery.com>
* gdb/mi/mi-cmd-var.c (mi_parse_format): Handle new "zero-hexadecimal"
format.
* gdb/varobj.c (varobj_format_string): Add "zero-hexadecimal" entry.
(format_code): Add 'z' entry.
(varobj_set_display_format): Handle FORMAT_ZHEXADECIMAL.
* gdb/varobj.h (varobj_display_formats) <FORMAT_ZHEXADECIMAL>: New enum
field.
---
gdb/mi/mi-cmd-var.c | 4 +++-
gdb/varobj.c | 5 +++--
gdb/varobj.h | 3 ++-
3 files changed, 8 insertions(+), 4 deletions(-)
diff --git a/gdb/mi/mi-cmd-var.c b/gdb/mi/mi-cmd-var.c
index ee0bbc6..5554e3c 100644
--- a/gdb/mi/mi-cmd-var.c
+++ b/gdb/mi/mi-cmd-var.c
@@ -233,10 +233,12 @@ mi_parse_format (const char *arg)
return FORMAT_HEXADECIMAL;
else if (strncmp (arg, "octal", len) == 0)
return FORMAT_OCTAL;
+ else if (strncmp (arg, "zero-hexadecimal", len) == 0)
+ return FORMAT_ZHEXADECIMAL;
}
error (_("Must specify the format as: \"natural\", "
- "\"binary\", \"decimal\", \"hexadecimal\", or \"octal\""));
+ "\"binary\", \"decimal\", \"hexadecimal\", \"octal\" or \"zero-hexadecimal\""));
}
void
diff --git a/gdb/varobj.c b/gdb/varobj.c
index b220fd8..2f2939e 100644
--- a/gdb/varobj.c
+++ b/gdb/varobj.c
@@ -50,7 +50,7 @@ show_varobjdebug (struct ui_file *file, int from_tty,
/* String representations of gdb's format codes. */
char *varobj_format_string[] =
- { "natural", "binary", "decimal", "hexadecimal", "octal" };
+ { "natural", "binary", "decimal", "hexadecimal", "octal", "zero-hexadecimal" };
/* True if we want to allow Python-based pretty-printing. */
static int pretty_printing = 0;
@@ -214,7 +214,7 @@ static struct varobj *varobj_add_child (struct varobj *var,
/* Private data */
/* Mappings of varobj_display_formats enums to gdb's format codes. */
-static int format_code[] = { 0, 't', 'd', 'x', 'o' };
+static int format_code[] = { 0, 't', 'd', 'x', 'o', 'z' };
/* Header of the list of root variable objects. */
static struct varobj_root *rootlist;
@@ -583,6 +583,7 @@ varobj_set_display_format (struct varobj *var,
case FORMAT_DECIMAL:
case FORMAT_HEXADECIMAL:
case FORMAT_OCTAL:
+ case FORMAT_ZHEXADECIMAL:
var->format = format;
break;
diff --git a/gdb/varobj.h b/gdb/varobj.h
index 8860526..179b2a5 100644
--- a/gdb/varobj.h
+++ b/gdb/varobj.h
@@ -28,7 +28,8 @@ enum varobj_display_formats
FORMAT_BINARY, /* Binary display */
FORMAT_DECIMAL, /* Decimal display */
FORMAT_HEXADECIMAL, /* Hex display */
- FORMAT_OCTAL /* Octal display */
+ FORMAT_OCTAL, /* Octal display */
+ FORMAT_ZHEXADECIMAL /* Zero padded hexadecimal */
};
enum varobj_type
--
1.9.1
next prev parent reply other threads:[~2015-05-07 17:37 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-05-07 17:37 [PATCH v2 0/3] varobj zero-padded hexadecimal format Luis Machado
2015-05-07 17:37 ` [PATCH v2 2/3] Add varobj zero-hexadecimal format tests Luis Machado
2015-05-08 17:30 ` Joel Brobecker
2015-05-07 17:37 ` Luis Machado [this message]
2015-05-08 17:28 ` [PATCH v2 1/3] Add zero-padded hexadecimal format support for varobj's Joel Brobecker
2015-05-08 18:23 ` Luis Machado
2015-05-11 20:55 ` Joel Brobecker
2015-05-20 12:16 ` Luis Machado
2015-05-25 23:39 ` Luis Machado
2015-05-07 17:37 ` [PATCH v2 3/3] Documentation changes for the new zero-hexadecimal format Luis Machado
2015-05-07 18:01 ` Eli Zaretskii
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=1431020207-14371-2-git-send-email-lgustavo@codesourcery.com \
--to=lgustavo@codesourcery.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).