varobj zero-padded hexadecimal format
authorLuis Machado <lgustavo@codesourcery.com>
Wed, 9 Dec 2015 12:56:27 +0000 (10:56 -0200)
committerLuis Machado <lgustavo@codesourcery.com>
Wed, 9 Dec 2015 13:00:47 +0000 (11:00 -0200)
This set of patches add support for the zero-padded hexadecimal format for
varobj's, defined as "zero-hexadecimal".  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'.

gdb/ChangeLog:

2015-12-09  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.
* NEWS: Add new note to MI changes citing the new zero-hexadecimal
format for -var-set-format.

gdb/doc/ChangeLog:

2015-12-09  Luis Machado  <lgustavo@codesourcery.com>

* gdb.texinfo (GDB/MI Variable Objects): Update text to mention
-var-set-format's new zero-hexadecimal format.

gdb/testsuite/ChangeLog:

2015-12-09  Luis Machado  <lgustavo@codesourcery.com>

* gdb.mi/mi-var-display.exp: Add new checks for the zero-hexadecimal
  format and change test names to make them unique.

gdb/ChangeLog
gdb/NEWS
gdb/doc/ChangeLog
gdb/doc/gdb.texinfo
gdb/mi/mi-cmd-var.c
gdb/testsuite/ChangeLog
gdb/testsuite/gdb.mi/mi-var-display.exp
gdb/varobj.c
gdb/varobj.h

index 8a8202cebb5fafc8607f9f9d94ae16b3b6d30477..bafae523645f2b6c5abb32d3e8796d29682eaa00 100644 (file)
@@ -1,3 +1,15 @@
+2015-12-09  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.
+       * NEWS: Add new note to MI changes citing the new zero-hexadecimal
+       format for -var-set-format.
+
 2015-12-09  Ruslan Kabatsayev  <b7.10110111@gmail.com>  (tiny patch)
 
        PR gdb/18702
index 280c8fea3e79dc72dfacfa3bd197a14a82cf51d0..9ca7f4985f511402efa44e4a75e39f022e888eb4 100644 (file)
--- a/gdb/NEWS
+++ b/gdb/NEWS
@@ -135,6 +135,12 @@ show remote exec-event-feature-packet
    The reply to qXfer:threads:read may now include a name attribute for each
    thread.
 
+* MI changes
+
+  ** The -var-set-format command now accepts the zero-hexadecimal
+     format.  It outputs data in hexadecimal format with zero-padding on the
+     left.
+
 *** Changes in GDB 7.10
 
 * Support for process record-replay and reverse debugging on aarch64*-linux*
index 6f05e361ddbd62e97e7801d4ddca9ccf718c832b..7b0dc353c8288f720d46ddcd9d7e89099ff3b7a7 100644 (file)
@@ -1,3 +1,8 @@
+2015-12-09  Luis Machado  <lgustavo@codesourcery.com>
+
+       * gdb.texinfo (GDB/MI Variable Objects): Update text to mention
+       -var-set-format's new zero-hexadecimal format.
+
 2015-12-08  Pierre-Marie de Rodat  <derodat@adacore.com>
 
        * gdb.texinfo (Ada Mode Into): Move overloading support
index 9f72c52e151f502ce9753223dc58d401d1472240..be39f1c6d7f86e4570f01cc14fac4f8299d1c034 100644 (file)
@@ -28980,13 +28980,18 @@ 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 | zero-hexadecimal@}
 @end smallexample
 
 The natural format is the default format choosen automatically
 based on the variable type (like decimal for an @code{int}, hex
 for pointers, etc.).
 
+The zero-hexadecimal format has a representation similar to hexadecimal
+but with padding zeroes to the left of the value.  For example, a 32-bit
+hexadecimal value of 0x1234 would be represented as 0x00001234 in the
+zero-hexadecimal format.
+
 For a variable with children, the format is set only on the 
 variable itself, and the children are not affected.  
 
index e316812e466eda6b9cc6f520c4a4df839d51e22d..643fd7a1d490e4567076ed583dfda0704539b1a3 100644 (file)
@@ -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
index d959e7b615818c9115ef808e7ebae1a55dd3bf95..e4b396f44f4941731d73eb5bd39523115c85ac09 100644 (file)
@@ -1,3 +1,8 @@
+2015-12-09  Luis Machado  <lgustavo@codesourcery.com>
+
+       * gdb.mi/mi-var-display.exp: Add new checks for the zero-hexadecimal
+         format and change test names to make them unique.
+
 2015-12-09  Ruslan Kabatsayev  <b7.10110111@gmail.com>
            Pedro Alves  <pedro@redhat.com>
 
index 31bdce4eb67669d5bb751e49bddd86089cae9c41..d65233b9292896c44e8f9170426f2e2a54726c5d 100644 (file)
@@ -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 zero-hexadecimal" \
+       "\\^done,format=\"zero-hexadecimal\",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 zero-hexadecimal" \
+       "\\^done,format=\"zero-hexadecimal\",value=\"$hex\"" \
+       "set format variable weird.func_ptr in zero-padded hex"
+
+mi_gdb_test "-var-show-format weird.func_ptr" \
+       "\\^done,format=\"zero-hexadecimal\"" \
+       "show format variable weird.func_ptr (zhex)"
+
+mi_gdb_test "-var-set-format weird.func_ptr_ptr zero-hexadecimal" \
+       "\\^done,format=\"zero-hexadecimal\",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=\"zero-hexadecimal\"" \
+       "show format variable weird.func_ptr_ptr (zhex)"
 
 # Test: c_variable-6.24
 # Desc: format of weird and children
index 92b0f33ffb2ca940c83e8e6ce2e682d1bb995b4a..0b19d843a70479f7322b9c578d29362d8946df3e 100644 (file)
@@ -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;
 
index 88605268ecad091c07e7b4a908b14762aa851da9..179b2a58cc1057e8d94acd4c619709a2426824df 100644 (file)
@@ -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
This page took 0.056069 seconds and 4 git commands to generate.