* NEWS: Update description of string changes. Mention print/s.
authorDaniel Jacobowitz <drow@false.org>
Wed, 5 Sep 2007 00:51:49 +0000 (00:51 +0000)
committerDaniel Jacobowitz <drow@false.org>
Wed, 5 Sep 2007 00:51:49 +0000 (00:51 +0000)
* c-valprint.c (textual_element_type): New.
(c_val_print): Use it.  Do not skip address printing for pointers
with a string format.
(c_value_print): Doc update.
* dwarf2read.c (read_array_type): Use make_vector_type.
* gdbtypes.c (make_vector_type): New.
(init_vector_type): Use it.
(gdbtypes_post_init): Initialize builtin_true_unsigned_char.
(_initialize_gdbtypes): Mark int8_t and uint8_t as TYPE_FLAG_NOTTEXT.
* gdbtypes.h (struct builtin_type): Add builtin_true_unsigned_char.
(TYPE_FLAG_NOTTEXT, TYPE_NOTTEXT): New.
(make_vector_type): New.
* printcmd.c (print_formatted): Only handle 's' and 'i' for examine.
Call the language print routine for string format.
(print_scalar_formatted): Call val_print for string format.  Handle
unsigned original types for char format.
(validate_format): Do not reject string format.
* stabsread.c (read_type): Use make_vector_type.
* xml-tdesc.c (tdesc_start_vector): Use init_vector_type.

* gdb.texinfo (Output Formats): Update 'c' description.  Describe 's'.
(Examining Memory): Update mentions of the 's' format.
(Automatic Display): Likewise.

* gdb.arch/i386-sse.exp: Do not expect character constants.
* gdb.base/charsign.c, gdb.base/charsign.exp: Delete.
* gdb.base/display.exp: Allow print/s.
* gdb.base/printcmds.exp, gdb.base/setvar.exp: Revert signed
and unsigned char array changes.

16 files changed:
gdb/ChangeLog
gdb/NEWS
gdb/c-valprint.c
gdb/doc/ChangeLog
gdb/doc/gdb.texinfo
gdb/dwarf2read.c
gdb/gdbtypes.c
gdb/gdbtypes.h
gdb/printcmd.c
gdb/stabsread.c
gdb/testsuite/ChangeLog
gdb/testsuite/gdb.arch/i386-sse.exp
gdb/testsuite/gdb.base/display.exp
gdb/testsuite/gdb.base/printcmds.exp
gdb/testsuite/gdb.base/setvar.exp
gdb/xml-tdesc.c

index a26e493..49435ca 100644 (file)
@@ -1,3 +1,27 @@
+2007-09-04  Daniel Jacobowitz  <dan@codesourcery.com>
+           Jim Blandy  <jimb@codesourcery.com>
+
+       * NEWS: Update description of string changes.  Mention print/s.
+       * c-valprint.c (textual_element_type): New.
+       (c_val_print): Use it.  Do not skip address printing for pointers
+       with a string format.
+       (c_value_print): Doc update.
+       * dwarf2read.c (read_array_type): Use make_vector_type.
+       * gdbtypes.c (make_vector_type): New.
+       (init_vector_type): Use it.
+       (gdbtypes_post_init): Initialize builtin_true_unsigned_char.
+       (_initialize_gdbtypes): Mark int8_t and uint8_t as TYPE_FLAG_NOTTEXT.
+       * gdbtypes.h (struct builtin_type): Add builtin_true_unsigned_char.
+       (TYPE_FLAG_NOTTEXT, TYPE_NOTTEXT): New.
+       (make_vector_type): New.
+       * printcmd.c (print_formatted): Only handle 's' and 'i' for examine.
+       Call the language print routine for string format.
+       (print_scalar_formatted): Call val_print for string format.  Handle
+       unsigned original types for char format.
+       (validate_format): Do not reject string format.
+       * stabsread.c (read_type): Use make_vector_type.
+       * xml-tdesc.c (tdesc_start_vector): Use init_vector_type.
+
 2007-09-04  Michael Snyder  <msnyder@access-company.com>
 
        * expprint.c (print_subexp_standard): Check strchr for null.
index 698e182..15c5de8 100644 (file)
--- a/gdb/NEWS
+++ b/gdb/NEWS
@@ -27,8 +27,12 @@ frequency signals (e.g. SIGALRM) via the QPassSignals packet.
 target's overall architecture.  GDB can read a description from
 a local file or over the remote serial protocol.
 
-* Arrays of explicitly SIGNED or UNSIGNED CHARs are now printed as arrays
-of numbers.
+* Vectors of single-byte data use a new integer type which is not
+automatically displayed as character or string data.
+
+* The /s format now works with the print command.  It displays
+arrays of single-byte integers and pointers to single-byte integers
+as strings.
 
 * Target descriptions can now describe target-specific registers,
 for architectures which have implemented the support (currently
index f060071..cd4c85a 100644 (file)
@@ -54,6 +54,52 @@ print_function_pointer_address (CORE_ADDR address, struct ui_file *stream)
 }
 
 
+/* Apply a heuristic to decide whether an array of TYPE or a pointer
+   to TYPE should be printed as a textual string.  Return non-zero if
+   it should, or zero if it should be treated as an array of integers
+   or pointer to integers.  FORMAT is the current format letter,
+   or 0 if none.
+
+   We guess that "char" is a character.  Explicitly signed and
+   unsigned character types are also characters.  Integer data from
+   vector types is not.  The user can override this by using the /s
+   format letter.  */
+
+static int
+textual_element_type (struct type *type, char format)
+{
+  struct type *true_type = check_typedef (type);
+
+  if (format != 0 && format != 's')
+    return 0;
+
+  /* TYPE_CODE_CHAR is always textual.  */
+  if (TYPE_CODE (true_type) == TYPE_CODE_CHAR)
+    return 1;
+
+  if (format == 's')
+    {
+      /* Print this as a string if we can manage it.  For now, no
+        wide character support.  */
+      if (TYPE_CODE (true_type) == TYPE_CODE_INT
+         && TYPE_LENGTH (true_type) == 1)
+       return 1;
+    }
+  else
+    {
+      /* If a one-byte TYPE_CODE_INT is missing the not-a-character
+        flag, then we treat it as text; otherwise, we assume it's
+        being used as data.  */
+      if (TYPE_CODE (true_type) == TYPE_CODE_INT
+         && TYPE_LENGTH (true_type) == 1
+         && !TYPE_NOTTEXT (true_type))
+       return 1;
+    }
+
+  return 0;
+}
+
+
 /* Print data of type TYPE located at VALADDR (within GDB), which came from
    the inferior at address ADDRESS, onto stdio stream STREAM according to
    FORMAT (a letter or 0 for natural format).  The data at VALADDR is in
@@ -92,12 +138,9 @@ c_val_print (struct type *type, const gdb_byte *valaddr, int embedded_offset,
            {
              print_spaces_filtered (2 + 2 * recurse, stream);
            }
-         /* For an array of chars, print with string syntax.  */
-         if (eltlen == 1 &&
-             ((TYPE_CODE (elttype) == TYPE_CODE_INT && TYPE_NOSIGN (elttype))
-              || ((current_language->la_language == language_m2)
-                  && (TYPE_CODE (elttype) == TYPE_CODE_CHAR)))
-             && (format == 0 || format == 's'))
+
+         /* Print arrays of textual chars with a string syntax.  */
+          if (textual_element_type (elttype, format))
            {
              /* If requested, look for the first null char and only print
                 elements up to it.  */
@@ -184,19 +227,16 @@ c_val_print (struct type *type, const gdb_byte *valaddr, int embedded_offset,
              return (0);
            }
 
-         if (addressprint && format != 's')
+         if (addressprint)
            {
              deprecated_print_address_numeric (addr, 1, stream);
            }
 
-         /* For a pointer to char or unsigned char, also print the string
+         /* For a pointer to a textual type, also print the string
             pointed to, unless pointer is null.  */
          /* FIXME: need to handle wchar_t here... */
 
-         if (TYPE_LENGTH (elttype) == 1
-             && TYPE_CODE (elttype) == TYPE_CODE_INT
-             && (format == 0 || format == 's')
-             && addr != 0)
+         if (textual_element_type (elttype, format) && addr != 0)
            {
              i = val_print_string (addr, -1, TYPE_LENGTH (elttype), stream);
            }
@@ -395,8 +435,8 @@ c_val_print (struct type *type, const gdb_byte *valaddr, int embedded_offset,
          /* C and C++ has no single byte int type, char is used instead.
             Since we don't know whether the value is really intended to
             be used as an integer or a character, print the character
-            equivalent as well. */
-         if (TYPE_LENGTH (type) == 1)
+            equivalent as well.  */
+         if (textual_element_type (type, format))
            {
              fputs_filtered (" ", stream);
              LA_PRINT_CHAR ((unsigned char) unpack_long (type, valaddr + embedded_offset),
@@ -498,7 +538,9 @@ c_value_print (struct value *val, struct ui_file *stream, int format,
       || TYPE_CODE (type) == TYPE_CODE_REF)
     {
       /* Hack:  remove (char *) for char strings.  Their
-         type is indicated by the quoted string anyway. */
+         type is indicated by the quoted string anyway.
+         (Don't use textual_element_type here; quoted strings
+         are always exactly (char *).  */
       if (TYPE_CODE (type) == TYPE_CODE_PTR
          && TYPE_NAME (type) == NULL
          && TYPE_NAME (TYPE_TARGET_TYPE (type)) != NULL
index ddb643d..ad0ed2f 100644 (file)
@@ -1,3 +1,10 @@
+2007-09-04  Daniel Jacobowitz  <dan@codesourcery.com>
+           Jim Blandy  <jimb@codesourcery.com>
+
+       * gdb.texinfo (Output Formats): Update 'c' description.  Describe 's'.
+       (Examining Memory): Update mentions of the 's' format.
+       (Automatic Display): Likewise.
+
 2007-09-02  Daniel Jacobowitz  <dan@codesourcery.com>
 
        * gdb.texinfo: Update the FSF's Back-Cover Text.
index 334e5c3..38e6f6a 100644 (file)
@@ -5767,9 +5767,27 @@ prints both the numerical value and its character representation.  The
 character representation is replaced with the octal escape @samp{\nnn}
 for characters outside the 7-bit @sc{ascii} range.
 
+Without this format, @value{GDBN} displays @code{char},
+@w{@code{unsigned char}}, and @w{@code{signed char}} data as character
+constants.  Single-byte members of vectors are displayed as integer
+data.
+
 @item f
 Regard the bits of the value as a floating point number and print
 using typical floating point syntax.
+
+@item s
+@cindex printing strings
+@cindex printing byte arrays
+Regard as a string, if possible.  With this format, pointers to single-byte
+data are displayed as null-terminated strings and arrays of single-byte data
+are displayed as fixed-length strings.  Other values are displayed in their
+natural types.
+
+Without this format, @value{GDBN} displays pointers to and arrays of
+@code{char}, @w{@code{unsigned char}}, and @w{@code{signed char}} as
+strings.  Single-byte members of a vector are displayed as an integer
+array.
 @end table
 
 For example, to print the program counter in hex (@pxref{Registers}), type
@@ -5817,10 +5835,9 @@ how much memory (counting by units @var{u}) to display.
 @item @var{f}, the display format
 The display format is one of the formats used by @code{print}
 (@samp{x}, @samp{d}, @samp{u}, @samp{o}, @samp{t}, @samp{a}, @samp{c},
-@samp{f}), and in addition @samp{s} (for null-terminated strings) and
-@samp{i} (for machine instructions).  The default is @samp{x}
-(hexadecimal) initially.  The default changes each time you use either
-@code{x} or @code{print}.
+@samp{f}, @samp{s}), and in addition @samp{i} (for machine instructions).
+The default is @samp{x} (hexadecimal) initially.  The default changes
+each time you use either @code{x} or @code{print}.
 
 @item @var{u}, the unit size
 The unit size is any of
@@ -5936,10 +5953,9 @@ The automatic display looks like this:
 This display shows item numbers, expressions and their current values.  As with
 displays you request manually using @code{x} or @code{print}, you can
 specify the output format you prefer; in fact, @code{display} decides
-whether to use @code{print} or @code{x} depending on how elaborate your
-format specification is---it uses @code{x} if you specify a unit size,
-or one of the two formats (@samp{i} and @samp{s}) that are only
-supported by @code{x}; otherwise it uses @code{print}.
+whether to use @code{print} or @code{x} depending your format
+specification---it uses @code{x} if you specify either the @samp{i}
+or @samp{s} format, or a unit size; otherwise it uses @code{print}.
 
 @table @code
 @kindex display
index 458d04a..370035f 100644 (file)
@@ -4325,7 +4325,7 @@ read_array_type (struct die_info *die, struct dwarf2_cu *cu)
      to functions.  */
   attr = dwarf2_attr (die, DW_AT_GNU_vector, cu);
   if (attr)
-    TYPE_FLAGS (type) |= TYPE_FLAG_VECTOR;
+    make_vector_type (type);
 
   attr = dwarf2_attr (die, DW_AT_name, cu);
   if (attr && DW_STRING (attr))
index 171447d..838bfcf 100644 (file)
@@ -917,6 +917,32 @@ init_flags_type (char *name, int length)
   return type;
 }
 
+/* Convert ARRAY_TYPE to a vector type.  This may modify ARRAY_TYPE
+   and any array types nested inside it.  */
+
+void
+make_vector_type (struct type *array_type)
+{
+  struct type *inner_array, *elt_type;
+  int flags;
+
+  /* Find the innermost array type, in case the array is
+     multi-dimensional.  */
+  inner_array = array_type;
+  while (TYPE_CODE (TYPE_TARGET_TYPE (inner_array)) == TYPE_CODE_ARRAY)
+    inner_array = TYPE_TARGET_TYPE (inner_array);
+
+  elt_type = TYPE_TARGET_TYPE (inner_array);
+  if (TYPE_CODE (elt_type) == TYPE_CODE_INT)
+    {
+      flags = TYPE_INSTANCE_FLAGS (elt_type) | TYPE_FLAG_NOTTEXT;
+      elt_type = make_qualified_type (elt_type, flags, NULL);
+      TYPE_TARGET_TYPE (inner_array) = elt_type;
+    }
+
+  TYPE_FLAGS (array_type) |= TYPE_FLAG_VECTOR;
+}
+
 struct type *
 init_vector_type (struct type *elt_type, int n)
 {
@@ -926,7 +952,7 @@ init_vector_type (struct type *elt_type, int n)
                                  create_range_type (0, 
                                                     builtin_type_int,
                                                     0, n-1));
-  TYPE_FLAGS (array_type) |= TYPE_FLAG_VECTOR;
+  make_vector_type (array_type);
   return array_type;
 }
 
@@ -3410,6 +3436,10 @@ gdbtypes_post_init (struct gdbarch *gdbarch)
     init_type (TYPE_CODE_CHAR, TARGET_CHAR_BIT / TARGET_CHAR_BIT,
               0,
               "true character", (struct objfile *) NULL);
+  builtin_type->builtin_true_unsigned_char =
+    init_type (TYPE_CODE_CHAR, TARGET_CHAR_BIT / TARGET_CHAR_BIT,
+              TYPE_FLAG_UNSIGNED,
+              "true character", (struct objfile *) NULL);
   builtin_type->builtin_signed_char =
     init_type (TYPE_CODE_INT, TARGET_CHAR_BIT / TARGET_CHAR_BIT,
               0,
@@ -3557,11 +3587,11 @@ _initialize_gdbtypes (void)
               "int0_t", (struct objfile *) NULL);
   builtin_type_int8 =
     init_type (TYPE_CODE_INT, 8 / 8,
-              0,
+              TYPE_FLAG_NOTTEXT,
               "int8_t", (struct objfile *) NULL);
   builtin_type_uint8 =
     init_type (TYPE_CODE_INT, 8 / 8,
-              TYPE_FLAG_UNSIGNED,
+              TYPE_FLAG_UNSIGNED | TYPE_FLAG_NOTTEXT,
               "uint8_t", (struct objfile *) NULL);
   builtin_type_int16 =
     init_type (TYPE_CODE_INT, 16 / 8,
index 00ceb6b..7c93ca5 100644 (file)
@@ -325,6 +325,12 @@ enum type_code
 #define TYPE_FLAG_STUB_SUPPORTED (1 << 16)
 #define TYPE_STUB_SUPPORTED(t)   (TYPE_FLAGS (t) & TYPE_FLAG_STUB_SUPPORTED)
 
+/* Not textual.  By default, GDB treats all single byte integers as
+   characters (or elements of strings) unless this flag is set.  */
+
+#define TYPE_FLAG_NOTTEXT      (1 << 17)
+#define TYPE_NOTTEXT(t)                (TYPE_FLAGS (t) & TYPE_FLAG_NOTTEXT)
+
 /*  Array bound type.  */
 enum array_bound_type
 {
@@ -1009,10 +1015,11 @@ struct builtin_type
 
   /* Integral types.  */
 
-  /* We use this for the '/c' print format, because c_char is just a
+  /* We use these for the '/c' print format, because c_char is just a
      one-byte integral type, which languages less laid back than C
      will print as ... well, a one-byte integral type.  */
   struct type *builtin_true_char;
+  struct type *builtin_true_unsigned_char;
 
   /* Implicit size/sign (based on the the architecture's ABI).  */
   struct type *builtin_void;
@@ -1261,6 +1268,7 @@ extern void append_composite_type_field (struct type *t, char *name,
 extern struct type *init_flags_type (char *name, int length);
 extern void append_flags_type_flag (struct type *type, int bitpos, char *name);
 
+extern void make_vector_type (struct type *array_type);
 extern struct type *init_vector_type (struct type *elt_type, int n);
 
 extern struct type *lookup_reference_type (struct type *);
index 019a4a6..04cfd77 100644 (file)
@@ -250,7 +250,8 @@ decode_format (char **string_ptr, int oformat, int osize)
    Do not end with a newline.
    0 means print VAL according to its own type.
    SIZE is the letter for the size of datum being printed.
-   This is used to pad hex numbers so they line up.  */
+   This is used to pad hex numbers so they line up.  SIZE is 0
+   for print / output and set for examine.  */
 
 static void
 print_formatted (struct value *val, int format, int size,
@@ -262,45 +263,41 @@ print_formatted (struct value *val, int format, int size,
   if (VALUE_LVAL (val) == lval_memory)
     next_address = VALUE_ADDRESS (val) + len;
 
-  switch (format)
+  if (size)
     {
-    case 's':
-      /* FIXME: Need to handle wchar_t's here... */
-      next_address = VALUE_ADDRESS (val)
-       + val_print_string (VALUE_ADDRESS (val), -1, 1, stream);
-      break;
-
-    case 'i':
-      /* The old comment says
-         "Force output out, print_insn not using _filtered".
-         I'm not completely sure what that means, I suspect most print_insn
-         now do use _filtered, so I guess it's obsolete.
-         --Yes, it does filter now, and so this is obsolete.  -JB  */
-
-      /* We often wrap here if there are long symbolic names.  */
-      wrap_here ("    ");
-      next_address = (VALUE_ADDRESS (val)
-                     + gdb_print_insn (VALUE_ADDRESS (val), stream,
-                                       &branch_delay_insns));
-      break;
+      switch (format)
+       {
+       case 's':
+         /* FIXME: Need to handle wchar_t's here... */
+         next_address = VALUE_ADDRESS (val)
+           + val_print_string (VALUE_ADDRESS (val), -1, 1, stream);
+         return;
 
-    default:
-      if (format == 0
-         || TYPE_CODE (type) == TYPE_CODE_ARRAY
-         || TYPE_CODE (type) == TYPE_CODE_STRING
-         || TYPE_CODE (type) == TYPE_CODE_STRUCT
-         || TYPE_CODE (type) == TYPE_CODE_UNION
-         || TYPE_CODE (type) == TYPE_CODE_NAMESPACE)
-       /* If format is 0, use the 'natural' format for that type of
-          value.  If the type is non-scalar, we have to use language
-          rules to print it as a series of scalars.  */
-       value_print (val, stream, format, Val_pretty_default);
-      else
-       /* User specified format, so don't look to the the type to
-          tell us what to do.  */
-       print_scalar_formatted (value_contents (val), type,
-                               format, size, stream);
+       case 'i':
+         /* We often wrap here if there are long symbolic names.  */
+         wrap_here ("    ");
+         next_address = (VALUE_ADDRESS (val)
+                         + gdb_print_insn (VALUE_ADDRESS (val), stream,
+                                           &branch_delay_insns));
+         return;
+       }
     }
+
+  if (format == 0 || format == 's'
+      || TYPE_CODE (type) == TYPE_CODE_ARRAY
+      || TYPE_CODE (type) == TYPE_CODE_STRING
+      || TYPE_CODE (type) == TYPE_CODE_STRUCT
+      || TYPE_CODE (type) == TYPE_CODE_UNION
+      || TYPE_CODE (type) == TYPE_CODE_NAMESPACE)
+    /* If format is 0, use the 'natural' format for that type of
+       value.  If the type is non-scalar, we have to use language
+       rules to print it as a series of scalars.  */
+    value_print (val, stream, format, Val_pretty_default);
+  else
+    /* User specified format, so don't look to the the type to
+       tell us what to do.  */
+    print_scalar_formatted (value_contents (val), type,
+                           format, size, stream);
 }
 
 /* Print a scalar of data of type TYPE, pointed to in GDB by VALADDR,
@@ -317,6 +314,15 @@ print_scalar_formatted (const void *valaddr, struct type *type,
   LONGEST val_long = 0;
   unsigned int len = TYPE_LENGTH (type);
 
+  /* If we get here with a string format, try again without it.  Go
+     all the way back to the language printers, which may call us
+     again.  */
+  if (format == 's')
+    {
+      val_print (type, valaddr, 0, 0, stream, 0, 0, 0, Val_pretty_default);
+      return;
+    }
+
   if (len > sizeof(LONGEST) &&
       (TYPE_CODE (type) == TYPE_CODE_INT
        || TYPE_CODE (type) == TYPE_CODE_ENUM))
@@ -407,8 +413,17 @@ print_scalar_formatted (const void *valaddr, struct type *type,
       break;
 
     case 'c':
-      value_print (value_from_longest (builtin_type_true_char, val_long),
-                  stream, 0, Val_pretty_default);
+      if (TYPE_UNSIGNED (type))
+       {
+         struct type *utype;
+
+         utype = builtin_type (current_gdbarch)->builtin_true_unsigned_char;
+         value_print (value_from_longest (utype, val_long),
+                      stream, 0, Val_pretty_default);
+       }
+      else
+       value_print (value_from_longest (builtin_type_true_char, val_long),
+                    stream, 0, Val_pretty_default);
       break;
 
     case 'f':
@@ -809,7 +824,7 @@ validate_format (struct format_data fmt, char *cmdname)
   if (fmt.count != 1)
     error (_("Item count other than 1 is meaningless in \"%s\" command."),
           cmdname);
-  if (fmt.format == 'i' || fmt.format == 's')
+  if (fmt.format == 'i')
     error (_("Format letter \"%c\" is meaningless in \"%s\" command."),
           fmt.format, cmdname);
 }
index 0e09368..f914e1e 100644 (file)
@@ -1916,7 +1916,7 @@ again:
       if (is_string)
        TYPE_CODE (type) = TYPE_CODE_STRING;
       if (is_vector)
-       TYPE_FLAGS (type) |= TYPE_FLAG_VECTOR;
+       make_vector_type (type);
       break;
 
     case 'S':                  /* Set or bitstring  type */
index c453ab2..14d731d 100644 (file)
@@ -1,4 +1,13 @@
 2007-09-04  Daniel Jacobowitz  <dan@codesourcery.com>
+           Jim Blandy  <jimb@codesourcery.com>
+
+       * gdb.arch/i386-sse.exp: Do not expect character constants.
+       * gdb.base/charsign.c, gdb.base/charsign.exp: Delete.
+       * gdb.base/display.exp: Allow print/s.
+       * gdb.base/printcmds.exp, gdb.base/setvar.exp: Revert signed
+       and unsigned char array changes.
+
+2007-09-04  Daniel Jacobowitz  <dan@codesourcery.com>
 
        * gdb.base/display.exp: Add tests for printf %p.
 
index b31b07a..259eb86 100644 (file)
@@ -84,7 +84,7 @@ foreach r {0 1 2 3 4 5 6 7} {
         ".. = \\{$r, $r.25, $r.5, $r.75\\}.*" \
         "check float contents of %xmm$r"
     gdb_test "print \$xmm$r.v16_int8" \
-        ".. = \\{(-?\[0-9\]+ '.*', ){15}-?\[0-9\]+ '.*'\\}.*" \
+        ".. = \\{(-?\[0-9\]+, ){15}-?\[0-9\]+\\}.*" \
         "check int8 contents of %xmm$r"
 }
 
index 254c431..6ff3920 100644 (file)
@@ -197,7 +197,7 @@ if [istarget "hppa*-hp-hpux*"] {
     gdb_test "x/rx j" ".*(Cannot access|Error accessing) memory.*|.*0xa:\[ \t\]*\[0-9\]+.*"
 }
 gdb_test "print/0 j" ".*Item count other than 1 is meaningless.*" "print/0 j"
-gdb_test "print/s sum" ".*Format letter.*is meaningless.*" " no s"
+gdb_test "print/s sum" " = 1000" "ignored s"
 gdb_test "print/i sum" ".*Format letter.*is meaningless.*.*" "no i"
 gdb_test "print/a &sum" ".*= $hex.*<sum>.*"
 # If the constant below is larger than the length of main, then
index 3768d67..a44db01 100644 (file)
@@ -589,18 +589,18 @@ proc test_print_char_arrays {} {
     gdb_test "set print address on" ""
 
     gdb_test "p arrays" \
-       " = \\{array1 = \\{97 'a', 98 'b', 99 'c', 0 '\\\\0'\\}, array2 = \\{100 'd'\\}, array3 = \\{101 'e'\\}, array4 = \\{102 'f', 103 'g'\\}, array5 = \\{104 'h', 105 'i', 106 'j', 0 '\\\\0'\\}\\}"
+       " = {array1 = \"abc\", array2 = \"d\", array3 = \"e\", array4 = \"fg\", array5 = \"hij\"}"
 
     gdb_test "p parrays"               " = \\(struct some_arrays \\*\\) $hex"
-    gdb_test "p parrays->array1"       " = \\{97 'a', 98 'b', 99 'c', 0 '\\\\0'\\}"
+    gdb_test "p parrays->array1"       " = \"abc\""
     gdb_test "p &parrays->array1"      " = \\(unsigned char \\(\\*\\)\\\[4\\\]\\) $hex"
-    gdb_test "p parrays->array2"       " = \\{100 'd'\\}"
+    gdb_test "p parrays->array2"       " = \"d\""
     gdb_test "p &parrays->array2"      " = \\(unsigned char \\(\\*\\)\\\[1\\\]\\) $hex"
-    gdb_test "p parrays->array3"       " = \\{101 'e'\\}"
+    gdb_test "p parrays->array3"       " = \"e\""
     gdb_test "p &parrays->array3"      " = \\(unsigned char \\(\\*\\)\\\[1\\\]\\) $hex"
-    gdb_test "p parrays->array4"       " = \\{102 'f', 103 'g'\\}"
+    gdb_test "p parrays->array4"       " = \"fg\""
     gdb_test "p &parrays->array4"      " = \\(unsigned char \\(\\*\\)\\\[2\\\]\\) $hex"
-    gdb_test "p parrays->array5"       " = \\{104 'h', 105 'i', 106 'j', 0 '\\\\0'\\}"
+    gdb_test "p parrays->array5"       " = \"hij\""
     gdb_test "p &parrays->array5"      " = \\(unsigned char \\(\\*\\)\\\[4\\\]\\) $hex"
 
     gdb_test "set print address off" ""
index dd047c1..5310506 100644 (file)
@@ -232,11 +232,11 @@ test_set "set variable v_char_array\[0\]='h'" "set variable v_char_array\[1\]='i
 #
 # test "set variable" for "signed char array[2]"
 #
-test_set "set variable v_signed_char_array\[0\]='h'" "set variable v_signed_char_array\[1\]='i'" "print v_signed_char_array" ".*.\[0-9\]* =.*\\{104 'h', 105 'i'\\}"        "set variable signed char array=\"hi\" (string)" 
+test_set "set variable v_signed_char_array\[0\]='h'" "set variable v_signed_char_array\[1\]='i'" "print v_signed_char_array" ".*.\[0-9\]* =.*\"hi\""        "set variable signed char array=\"hi\" (string)" 
 #
 # test "set variable" for "unsigned char array[2]"
 #
-test_set "set variable v_unsigned_char_array\[0\]='h'" "set variable v_unsigned_char_array\[1\]='i'" "print v_unsigned_char_array" ".*.\[0-9\]* =.*\\{104 'h', 105 'i'\\}"        "set variable unsigned char array=\"hi\" (string)" 
+test_set "set variable v_unsigned_char_array\[0\]='h'" "set variable v_unsigned_char_array\[1\]='i'" "print v_unsigned_char_array" ".*.\[0-9\]* =.*\"hi\""        "set variable unsigned char array=\"hi\" (string)" 
 #
 # test "set variable" for "short array[2]"
 #
@@ -288,11 +288,11 @@ test_set "set v_char_pointer=v_char_array" "set variable *(v_char_pointer)='h'"
 #
 # test "set variable" for type "signed char *"
 #
-test_set "set v_signed_char_pointer=v_signed_char_array" "set variable *(v_signed_char_pointer)='h'" "set variable *(v_signed_char_pointer+1)='i'" "print v_signed_char_array" ".*.\[0-9\]* =.*\\{104 'h', 105 'i'\\}"  "print *(v_signed_char_pointer+1)" ".*.\[0-9\]* = 105 \'i\'"     "set variable signed char pointer=\"hi\" (string)" 
+test_set "set v_signed_char_pointer=v_signed_char_array" "set variable *(v_signed_char_pointer)='h'" "set variable *(v_signed_char_pointer+1)='i'" "print v_signed_char_array" ".*.\[0-9\]* =.*\"hi\""  "print *(v_signed_char_pointer+1)" ".*.\[0-9\]* = 105 \'i\'"     "set variable signed char pointer=\"hi\" (string)" 
 #
 # test "set variable" for type "unsigned char *"
 #
-test_set "set v_unsigned_char_pointer=v_unsigned_char_array" "set variable *(v_unsigned_char_pointer)='h'" "set variable *(v_unsigned_char_pointer+1)='i'" "print v_unsigned_char_array" ".*.\[0-9\]* =.*\\{104 'h', 105 'i'\\}"  "print *(v_unsigned_char_pointer+1)" ".*.\[0-9\]* = 105 \'i\'"     "set variable unsigned char pointer=\"hi\" (string)" 
+test_set "set v_unsigned_char_pointer=v_unsigned_char_array" "set variable *(v_unsigned_char_pointer)='h'" "set variable *(v_unsigned_char_pointer+1)='i'" "print v_unsigned_char_array" ".*.\[0-9\]* =.*\"hi\""  "print *(v_unsigned_char_pointer+1)" ".*.\[0-9\]* = 105 \'i\'"     "set variable unsigned char pointer=\"hi\" (string)" 
 #
 # test "set variable" for type "short *"
 #
index 95fd60f..e56cb6a 100644 (file)
@@ -277,13 +277,9 @@ tdesc_start_vector (struct gdb_xml_parser *parser,
     gdb_xml_error (parser, _("Vector \"%s\" references undefined type \"%s\""),
                   id, field_type_id);
 
-  /* A vector is just an array plus a special flag.  */
-  range_type = create_range_type (NULL, builtin_type_int, 0, count - 1);
-  type = create_array_type (NULL, field_type, range_type);
+  type = init_vector_type (field_type, count);
   TYPE_NAME (type) = xstrdup (id);
 
-  TYPE_FLAGS (type) |= TYPE_FLAG_VECTOR;
-
   tdesc_record_type (data->current_feature, type);
 }