* [PATCH 0/3] varobj zero-padded hexadecimal format @ 2015-05-01 14:32 Luis Machado 2015-05-01 14:32 ` [PATCH 1/3] Add zero-padded hexadecimal format support for varobj's Luis Machado ` (2 more replies) 0 siblings, 3 replies; 9+ messages in thread From: Luis Machado @ 2015-05-01 14:32 UTC (permalink / raw) To: gdb-patches This set of patches add support for the zero-padded hexadecimal format for varobj's, defined as "zhexadecimal". We currently only support regular non-zero-padded hexadecimal. Talking with IDE developers, they would like to have this option that is already available to GDB's print/x commands in the CLI as 'z'. Luis Machado (3): Add zero-padded hexadecimal format support for varobj's Add varobj zhexadecimal format tests. Documentation changes for the new zhexadecimal format gdb/NEWS | 5 +++++ gdb/doc/gdb.texinfo | 2 +- gdb/mi/mi-cmd-var.c | 4 +++- gdb/testsuite/gdb.mi/mi-var-display.exp | 25 +++++++++++++++++++++++-- gdb/varobj.c | 5 +++-- gdb/varobj.h | 3 ++- 6 files changed, 37 insertions(+), 7 deletions(-) -- 1.9.1 ^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH 1/3] Add zero-padded hexadecimal format support for varobj's 2015-05-01 14:32 [PATCH 0/3] varobj zero-padded hexadecimal format Luis Machado @ 2015-05-01 14:32 ` Luis Machado 2015-05-01 14:33 ` [PATCH 2/3] Add varobj zhexadecimal format tests Luis Machado 2015-05-01 14:33 ` [PATCH 3/3] Documentation changes for the new zhexadecimal format Luis Machado 2 siblings, 0 replies; 9+ messages in thread From: Luis Machado @ 2015-05-01 14:32 UTC (permalink / raw) To: gdb-patches This patch changes things so that we can support zero-padded hexadecimal formats for varobj's. The new type is "zhexadecimal" 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-01 Luis Machado <lgustavo@codesourcery.com> * mi/mi-cmd-var.c (mi_parse_format): Handle new "zhexadecimal" format. * varobj.c (varobj_format_string): Add "zhexadecimal" entry. (format_code): Add 'z' entry. (varobj_set_display_format): Handle FORMAT_ZHEXADECIMAL. * 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, "zhexadecimal", len) == 0) + return FORMAT_ZHEXADECIMAL; } error (_("Must specify the format as: \"natural\", " - "\"binary\", \"decimal\", \"hexadecimal\", or \"octal\"")); + "\"binary\", \"decimal\", \"hexadecimal\", \"octal\" or \"zhexadecimal\"")); } 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", "zhexadecimal" }; /* 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 ^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH 2/3] Add varobj zhexadecimal format tests. 2015-05-01 14:32 [PATCH 0/3] varobj zero-padded hexadecimal format Luis Machado 2015-05-01 14:32 ` [PATCH 1/3] Add zero-padded hexadecimal format support for varobj's Luis Machado @ 2015-05-01 14:33 ` Luis Machado 2015-05-01 14:33 ` [PATCH 3/3] Documentation changes for the new zhexadecimal format Luis Machado 2 siblings, 0 replies; 9+ messages in thread From: Luis Machado @ 2015-05-01 14:33 UTC (permalink / raw) To: gdb-patches This patch adds a few tests to exercise the new zhexadecimal format for varobj's. I see 5 FAIL's without the zhexadecimal format support and full passes with a zhexadecimal format support. I renamed some of the tests to make them unique. gdb/testsuite/ChangeLog: 2015-05-01 Luis Machado <lgustavo@codesourcery.com> * gdb.mi/mi-var-display.exp: Add new checks for the zhexadecimal format and change test names to make them unique. --- gdb/testsuite/gdb.mi/mi-var-display.exp | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/gdb/testsuite/gdb.mi/mi-var-display.exp b/gdb/testsuite/gdb.mi/mi-var-display.exp index 31bdce4..6aedb53 100644 --- a/gdb/testsuite/gdb.mi/mi-var-display.exp +++ b/gdb/testsuite/gdb.mi/mi-var-display.exp @@ -81,6 +81,11 @@ mi_gdb_test "-var-evaluate-expression bar" \ "eval variable bar" # Test: c_variable-6.5 +# Desc: change format of bar to zero-padded hexadecimal +mi_gdb_test "-var-set-format bar zhexadecimal" \ + "\\^done,format=\"zhexadecimal\",value=\"0x0.*849\"" \ + "set format variable bar in zero-padded hexadecimal" + # Desc: change format of bar to hex mi_gdb_test "-var-set-format bar hexadecimal" \ "\\^done,format=\"hexadecimal\",value=\"0x849\"" \ @@ -241,7 +246,7 @@ mi_gdb_test "-var-set-format weird.func_ptr hexadecimal" \ mi_gdb_test "-var-show-format weird.func_ptr" \ "\\^done,format=\"hexadecimal\"" \ - "show format variable weird.func_ptr" + "show format variable weird.func_ptr (hex)" mi_gdb_test "-var-set-format weird.func_ptr_ptr hexadecimal" \ "\\^done,format=\"hexadecimal\",value=\"$hex\"" \ @@ -249,7 +254,23 @@ mi_gdb_test "-var-set-format weird.func_ptr_ptr hexadecimal" \ mi_gdb_test "-var-show-format weird.func_ptr_ptr" \ "\\^done,format=\"hexadecimal\"" \ - "show format variable weird.func_ptr_ptr" + "show format variable weird.func_ptr_ptr (hex)" + +mi_gdb_test "-var-set-format weird.func_ptr zhexadecimal" \ + "\\^done,format=\"zhexadecimal\",value=\"$hex\"" \ + "set format variable weird.func_ptr in zero-padded hex" + +mi_gdb_test "-var-show-format weird.func_ptr" \ + "\\^done,format=\"zhexadecimal\"" \ + "show format variable weird.func_ptr (zhex)" + +mi_gdb_test "-var-set-format weird.func_ptr_ptr zhexadecimal" \ + "\\^done,format=\"zhexadecimal\",value=\"$hex\"" \ + "set format variable weird.func_ptr_ptr in zero-padded hex" + +mi_gdb_test "-var-show-format weird.func_ptr_ptr" \ + "\\^done,format=\"zhexadecimal\"" \ + "show format variable weird.func_ptr_ptr (zhex)" # Test: c_variable-6.24 # Desc: format of weird and children -- 1.9.1 ^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH 3/3] Documentation changes for the new zhexadecimal format 2015-05-01 14:32 [PATCH 0/3] varobj zero-padded hexadecimal format Luis Machado 2015-05-01 14:32 ` [PATCH 1/3] Add zero-padded hexadecimal format support for varobj's Luis Machado 2015-05-01 14:33 ` [PATCH 2/3] Add varobj zhexadecimal format tests Luis Machado @ 2015-05-01 14:33 ` Luis Machado 2015-05-01 15:07 ` Eli Zaretskii 2 siblings, 1 reply; 9+ messages in thread From: Luis Machado @ 2015-05-01 14:33 UTC (permalink / raw) To: gdb-patches This patch updates the documentation to reflect the addition of the new zhexadecimal format option for -var-set-format and also adds a NEWS entry for the change. gdb/ChangeLog: 2015-05-01 Luis Machado <lgustavo@codesourcery.com> * NEWS: Add new note to MI changes. gdb/doc/ChangeLog: 2015-05-01 Luis Machado <lgustavo@codesourcery.com> * gdb.texinfo (GDB/MI Variable Objects): Update text for -var-set-format. --- gdb/NEWS | 5 +++++ gdb/doc/gdb.texinfo | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/gdb/NEWS b/gdb/NEWS index 651401d..9d4fd03 100644 --- a/gdb/NEWS +++ b/gdb/NEWS @@ -142,6 +142,11 @@ qXfer:exec-file:read HP/PA running HP-UX hppa*-*-hpux* Itanium running HP-UX ia64-*-hpux* +* MI changes + + ** The -var-set-format command now accepts the zhexadecimal format. It + outputs data in hexadecimal format with zero-padding on the left. + *** Changes in GDB 7.9 * GDB now supports hardware watchpoints on x86 GNU Hurd. diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo index 9e2787d..89fd2ca 100644 --- a/gdb/doc/gdb.texinfo +++ b/gdb/doc/gdb.texinfo @@ -28927,7 +28927,7 @@ The syntax for the @var{format-spec} is as follows: @smallexample @var{format-spec} @expansion{} - @{binary | decimal | hexadecimal | octal | natural@} + @{binary | decimal | hexadecimal | octal | natural | zhexadecimal@} @end smallexample The natural format is the default format choosen automatically -- 1.9.1 ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH 3/3] Documentation changes for the new zhexadecimal format 2015-05-01 14:33 ` [PATCH 3/3] Documentation changes for the new zhexadecimal format Luis Machado @ 2015-05-01 15:07 ` Eli Zaretskii 2015-05-01 18:58 ` Luis Machado 2015-05-06 13:56 ` Luis Machado 0 siblings, 2 replies; 9+ messages in thread From: Eli Zaretskii @ 2015-05-01 15:07 UTC (permalink / raw) To: Luis Machado; +Cc: gdb-patches > From: Luis Machado <lgustavo@codesourcery.com> > Date: Fri, 1 May 2015 11:32:38 -0300 > > This patch updates the documentation to reflect the addition of the new > zhexadecimal format option for -var-set-format and also adds a NEWS entry > for the change. OK, but should we perhaps explain what zhexadecimal means? I didn't know about it until I read this patch. Thanks. ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH 3/3] Documentation changes for the new zhexadecimal format 2015-05-01 15:07 ` Eli Zaretskii @ 2015-05-01 18:58 ` Luis Machado 2015-05-06 13:56 ` Luis Machado 1 sibling, 0 replies; 9+ messages in thread From: Luis Machado @ 2015-05-01 18:58 UTC (permalink / raw) To: Eli Zaretskii; +Cc: gdb-patches On 05/01/2015 12:07 PM, Eli Zaretskii wrote: >> From: Luis Machado <lgustavo@codesourcery.com> >> Date: Fri, 1 May 2015 11:32:38 -0300 >> >> This patch updates the documentation to reflect the addition of the new >> zhexadecimal format option for -var-set-format and also adds a NEWS entry >> for the change. > > OK, but should we perhaps explain what zhexadecimal means? I didn't > know about it until I read this patch. Yes. Or maybe have a better (longer?) nomeclature for this option, making it more intuitive? ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH 3/3] Documentation changes for the new zhexadecimal format 2015-05-01 15:07 ` Eli Zaretskii 2015-05-01 18:58 ` Luis Machado @ 2015-05-06 13:56 ` Luis Machado 2015-05-06 14:01 ` Luis Machado 2015-05-06 15:36 ` Eli Zaretskii 1 sibling, 2 replies; 9+ messages in thread From: Luis Machado @ 2015-05-06 13:56 UTC (permalink / raw) To: Eli Zaretskii; +Cc: gdb-patches On 05/01/2015 12:07 PM, Eli Zaretskii wrote: >> From: Luis Machado <lgustavo@codesourcery.com> >> Date: Fri, 1 May 2015 11:32:38 -0300 >> >> This patch updates the documentation to reflect the addition of the new >> zhexadecimal format option for -var-set-format and also adds a NEWS entry >> for the change. > > OK, but should we perhaps explain what zhexadecimal means? I didn't > know about it until I read this patch. I'm not too sure where that explanation should go. The other formats are self-explanatory. What about 'zero-padded-hexadecimal'? Too long? The 'z' is an attempt to map back to the CLI format specifier /z when using the print and x commands. Though that requires some GDB-fu to get the first time. ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH 3/3] Documentation changes for the new zhexadecimal format 2015-05-06 13:56 ` Luis Machado @ 2015-05-06 14:01 ` Luis Machado 2015-05-06 15:36 ` Eli Zaretskii 1 sibling, 0 replies; 9+ messages in thread From: Luis Machado @ 2015-05-06 14:01 UTC (permalink / raw) To: Eli Zaretskii; +Cc: gdb-patches On 05/06/2015 10:56 AM, Luis Machado wrote: > On 05/01/2015 12:07 PM, Eli Zaretskii wrote: >>> From: Luis Machado <lgustavo@codesourcery.com> >>> Date: Fri, 1 May 2015 11:32:38 -0300 >>> >>> This patch updates the documentation to reflect the addition of the new >>> zhexadecimal format option for -var-set-format and also adds a NEWS >>> entry >>> for the change. >> >> OK, but should we perhaps explain what zhexadecimal means? I didn't >> know about it until I read this patch. > > I'm not too sure where that explanation should go. The other formats are > self-explanatory. What about 'zero-padded-hexadecimal'? Too long? > > The 'z' is an attempt to map back to the CLI format specifier /z when > using the print and x commands. Though that requires some GDB-fu to get > the first time. > > Also, i've been informed by IDE guys that these strings are usually translated, so 'zero-padded-hexadecimal' would be correct for internationalization purposes so it can be translated to other languages, as opposed to 'zhexadecimal'. ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH 3/3] Documentation changes for the new zhexadecimal format 2015-05-06 13:56 ` Luis Machado 2015-05-06 14:01 ` Luis Machado @ 2015-05-06 15:36 ` Eli Zaretskii 1 sibling, 0 replies; 9+ messages in thread From: Eli Zaretskii @ 2015-05-06 15:36 UTC (permalink / raw) To: Luis Machado; +Cc: gdb-patches > Date: Wed, 6 May 2015 10:56:32 -0300 > From: Luis Machado <lgustavo@codesourcery.com> > CC: <gdb-patches@sourceware.org> > > On 05/01/2015 12:07 PM, Eli Zaretskii wrote: > >> From: Luis Machado <lgustavo@codesourcery.com> > >> Date: Fri, 1 May 2015 11:32:38 -0300 > >> > >> This patch updates the documentation to reflect the addition of the new > >> zhexadecimal format option for -var-set-format and also adds a NEWS entry > >> for the change. > > > > OK, but should we perhaps explain what zhexadecimal means? I didn't > > know about it until I read this patch. > > I'm not too sure where that explanation should go. It should be near the first use of this term. > What about 'zero-padded-hexadecimal'? Too long? Yes, and I don't think we should go to such extremes. Just explaining the term the first time it is used in the manual should be OK. ^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2015-05-06 15:36 UTC | newest] Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2015-05-01 14:32 [PATCH 0/3] varobj zero-padded hexadecimal format Luis Machado 2015-05-01 14:32 ` [PATCH 1/3] Add zero-padded hexadecimal format support for varobj's Luis Machado 2015-05-01 14:33 ` [PATCH 2/3] Add varobj zhexadecimal format tests Luis Machado 2015-05-01 14:33 ` [PATCH 3/3] Documentation changes for the new zhexadecimal format Luis Machado 2015-05-01 15:07 ` Eli Zaretskii 2015-05-01 18:58 ` Luis Machado 2015-05-06 13:56 ` Luis Machado 2015-05-06 14:01 ` Luis Machado 2015-05-06 15:36 ` Eli Zaretskii
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).