Add array start and end strings to generic_val_print_decorations
authorTom Tromey <tom@tromey.com>
Tue, 26 Apr 2016 22:45:21 +0000 (16:45 -0600)
committerTom Tromey <tom@tromey.com>
Tue, 17 May 2016 18:02:00 +0000 (12:02 -0600)
For Rust value-printing, I wanted to use generic_val_print_array, but
I also wanted to control the starting and ending strings.

This patch adds new strings to generic_val_print_decorations, updates
generic_val_print_array to use them, and updates all the existing
instances of generic_val_print_decorations.

2016-05-17  Tom Tromey  <tom@tromey.com>

* valprint.h (struct generic_val_print_array) <array_start,
array_end>: New fields.
* valprint.c (generic_val_print_array): Add "decorations"
parameter.  Use "array_start", "array_end".
(generic_val_print) <TYPE_CODE_ARRAY>: Update.
* p-valprint.c (p_decorations): Update.
* m2-valprint.c (m2_decorations): Update.
* f-valprint.c (f_decorations): Update.
* c-valprint.c (c_decorations): Update.

gdb/ChangeLog
gdb/c-valprint.c
gdb/f-valprint.c
gdb/m2-valprint.c
gdb/p-valprint.c
gdb/valprint.c
gdb/valprint.h

index cad948f1a7398e8d075668728cceca2e933c9f27..0b7af7abd9e5ca090744ab9d52c8d21c1e4ae385 100644 (file)
@@ -1,3 +1,15 @@
+2016-05-17  Tom Tromey  <tom@tromey.com>
+
+       * valprint.h (struct generic_val_print_array) <array_start,
+       array_end>: New fields.
+       * valprint.c (generic_val_print_array): Add "decorations"
+       parameter.  Use "array_start", "array_end".
+       (generic_val_print) <TYPE_CODE_ARRAY>: Update.
+       * p-valprint.c (p_decorations): Update.
+       * m2-valprint.c (m2_decorations): Update.
+       * f-valprint.c (f_decorations): Update.
+       * c-valprint.c (c_decorations): Update.
+
 2016-05-17  Tom Tromey  <tom@tromey.com>
 
        * NEWS: Add "maint selftest" entry.
index e1da3d50e36e4b1a130adc00b6fdab88c85728df..61302a36da9c43d639436c86faf351b0d86336de 100644 (file)
@@ -124,7 +124,9 @@ static const struct generic_val_print_decorations c_decorations =
   " * I",
   "true",
   "false",
-  "void"
+  "void",
+  "{",
+  "}"
 };
 
 /* Print a pointer based on the type of its target.
index 71bd2c3e2cca6a70f683ee0fe0037305b8086289..1264737441a0bd5af2a09112ee5d8be7b1f62bb7 100644 (file)
@@ -203,6 +203,8 @@ static const struct generic_val_print_decorations f_decorations =
   ".TRUE.",
   ".FALSE.",
   "VOID",
+  "{",
+  "}"
 };
 
 /* See val_print for a description of the various parameters of this
index 73fbdfea5b6effb4f5bd0f2d4a71123183a74332..2d3a32f769a4198c567217c27281ad2759023218 100644 (file)
@@ -301,7 +301,9 @@ static const struct generic_val_print_decorations m2_decorations =
   " * I",
   "TRUE",
   "FALSE",
-  "void"
+  "void",
+  "{",
+  "}"
 };
 
 /* See val_print for a description of the various parameters of this
index 72dc6fd40d41576234ffc90f989d88df3d4bcb46..3e840d867eed36a3ccc0ad4f368dd0d9f9ff9576 100644 (file)
@@ -49,7 +49,9 @@ static const struct generic_val_print_decorations p_decorations =
   " * I",
   "true",
   "false",
-  "void"
+  "void",
+  "{",
+  "}"
 };
 
 /* See val_print for a description of the various parameters of this
index 720942b85e74d55561c98dba0ed344d5f26e57f4..cea69f324118bfe11b755ccc04739f04e144c977 100644 (file)
@@ -407,10 +407,12 @@ print_unpacked_pointer (struct type *type, struct type *elttype,
 
 static void
 generic_val_print_array (struct type *type, const gdb_byte *valaddr,
-                  int embedded_offset, CORE_ADDR address,
-                  struct ui_file *stream, int recurse,
-                  const struct value *original_value,
-                  const struct value_print_options *options)
+                        int embedded_offset, CORE_ADDR address,
+                        struct ui_file *stream, int recurse,
+                        const struct value *original_value,
+                        const struct value_print_options *options,
+                        const struct
+                            generic_val_print_decorations *decorations)
 {
   struct type *unresolved_elttype = TYPE_TARGET_TYPE (type);
   struct type *elttype = check_typedef (unresolved_elttype);
@@ -427,11 +429,11 @@ generic_val_print_array (struct type *type, const gdb_byte *valaddr,
          print_spaces_filtered (2 + 2 * recurse, stream);
        }
 
-      fprintf_filtered (stream, "{");
+      fputs_filtered (decorations->array_start, stream);
       val_print_array_elements (type, valaddr, embedded_offset,
                                address, stream,
                                recurse, original_value, options, 0);
-      fprintf_filtered (stream, "}");
+      fputs_filtered (decorations->array_end, stream);
     }
   else
     {
@@ -851,7 +853,7 @@ generic_val_print (struct type *type, const gdb_byte *valaddr,
     {
     case TYPE_CODE_ARRAY:
       generic_val_print_array (type, valaddr, embedded_offset, address, stream,
-                              recurse, original_value, options);
+                              recurse, original_value, options, decorations);
       break;
 
     case TYPE_CODE_MEMBERPTR:
index 1a83cb519bd5c9492c41b7873b87b066b85dd7fa..451b5fe0ac8c4dacb2659b28f1f9060e04432300 100644 (file)
@@ -186,6 +186,10 @@ struct generic_val_print_decorations
   /* What to print when we see TYPE_CODE_VOID.  */
 
   const char *void_name;
+
+  /* Array start and end strings.  */
+  const char *array_start;
+  const char *array_end;
 };