This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [RFC] Changes to signed char and unsigned char handling


On Thu, Jul 05, 2007 at 09:54:02AM -0400, Daniel Jacobowitz wrote:
> This patch is a follow-up to Jan's patch to change the behavior of
> "print" for uint8_t.  It follows option #3 from my earlier mail on
> this subject:
> 
>  3.  Treat "char" as a character, but "unsigned char" and "signed char"
>  as numbers (Jan's patch started down this road and Jim's went a bit
>  further).  Treat pointers/arrays of char as strings and
>  pointers/arrays of unsigned or signed char as numbers.  Add a "/s"
>  flag to the print command that treats single byte types as
>  characters or strings.
> 
>  (From: http://sourceware.org/ml/gdb/2007-04/msg00057.html )

Here's option 1 instead:

1.  Make vector types special.  Treat arrays of single byte integers
as characters, like before, unless they occur in a vector type.  This
is reasonable, but tricky to implement.

It restores the historic behavior for unsigned char and signed char.
Only the behavior of vector registers has changed.  You basically
never want to print these as strings, but since I had already
implemented print/s I kept it.

Comments?  Mark, is this better?

-- 
Daniel Jacobowitz
CodeSourcery

2007-07-05  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.

	* 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.

Index: NEWS
===================================================================
RCS file: /cvs/src/src/gdb/NEWS,v
retrieving revision 1.235
diff -u -p -r1.235 NEWS
--- NEWS	17 Jul 2007 12:51:40 -0000	1.235
+++ NEWS	25 Aug 2007 01:08:23 -0000
@@ -23,8 +23,12 @@ frequency signals (e.g. SIGALRM) via the
 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: c-valprint.c
===================================================================
RCS file: /cvs/src/src/gdb/c-valprint.c,v
retrieving revision 1.44
diff -u -p -r1.44 c-valprint.c
--- c-valprint.c	23 Aug 2007 18:08:27 -0000	1.44
+++ c-valprint.c	25 Aug 2007 01:08:23 -0000
@@ -54,6 +54,52 @@ print_function_pointer_address (CORE_ADD
 }
 
 
+/* 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 gd
 	    {
 	      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 gd
 	      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 gd
 	  /* 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
       || 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: dwarf2read.c
===================================================================
RCS file: /cvs/src/src/gdb/dwarf2read.c,v
retrieving revision 1.230
diff -u -p -r1.230 dwarf2read.c
--- dwarf2read.c	23 Aug 2007 18:08:28 -0000	1.230
+++ dwarf2read.c	25 Aug 2007 01:08:24 -0000
@@ -4325,7 +4325,7 @@ read_array_type (struct die_info *die, s
      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: gdbtypes.c
===================================================================
RCS file: /cvs/src/src/gdb/gdbtypes.c,v
retrieving revision 1.133
diff -u -p -r1.133 gdbtypes.c
--- gdbtypes.c	23 Aug 2007 18:08:33 -0000	1.133
+++ gdbtypes.c	25 Aug 2007 01:08:24 -0000
@@ -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,
 				  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 *gdba
     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: gdbtypes.h
===================================================================
RCS file: /cvs/src/src/gdb/gdbtypes.h,v
retrieving revision 1.77
diff -u -p -r1.77 gdbtypes.h
--- gdbtypes.h	23 Aug 2007 18:08:33 -0000	1.77
+++ gdbtypes.h	25 Aug 2007 01:08:24 -0000
@@ -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 
 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: printcmd.c
===================================================================
RCS file: /cvs/src/src/gdb/printcmd.c,v
retrieving revision 1.109
diff -u -p -r1.109 printcmd.c
--- printcmd.c	23 Aug 2007 18:08:36 -0000	1.109
+++ printcmd.c	25 Aug 2007 01:08:24 -0000
@@ -250,7 +250,8 @@ decode_format (char **string_ptr, int of
    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 
   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 *vala
   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 *vala
       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,
   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: stabsread.c
===================================================================
RCS file: /cvs/src/src/gdb/stabsread.c,v
retrieving revision 1.97
diff -u -p -r1.97 stabsread.c
--- stabsread.c	23 Aug 2007 18:08:38 -0000	1.97
+++ stabsread.c	25 Aug 2007 01:08:25 -0000
@@ -1914,7 +1914,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: xml-tdesc.c
===================================================================
RCS file: /cvs/src/src/gdb/xml-tdesc.c,v
retrieving revision 1.8
diff -u -p -r1.8 xml-tdesc.c
--- xml-tdesc.c	23 Aug 2007 18:08:47 -0000	1.8
+++ xml-tdesc.c	25 Aug 2007 01:08:25 -0000
@@ -277,13 +277,9 @@ tdesc_start_vector (struct gdb_xml_parse
     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);
 }
 
Index: doc/gdb.texinfo
===================================================================
RCS file: /cvs/src/src/gdb/doc/gdb.texinfo,v
retrieving revision 1.423
diff -u -p -r1.423 gdb.texinfo
--- doc/gdb.texinfo	21 Aug 2007 15:09:59 -0000	1.423
+++ doc/gdb.texinfo	25 Aug 2007 01:08:27 -0000
@@ -5769,9 +5769,27 @@ prints both the numerical value and its 
 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
@@ -5819,10 +5837,9 @@ how much memory (counting by units @var{
 @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
@@ -5938,10 +5955,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: testsuite/gdb.arch/i386-sse.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.arch/i386-sse.exp,v
retrieving revision 1.7
diff -u -p -r1.7 i386-sse.exp
--- testsuite/gdb.arch/i386-sse.exp	23 Aug 2007 18:14:16 -0000	1.7
+++ testsuite/gdb.arch/i386-sse.exp	25 Aug 2007 01:08:27 -0000
@@ -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: testsuite/gdb.base/charsign.c
===================================================================
RCS file: testsuite/gdb.base/charsign.c
diff -N testsuite/gdb.base/charsign.c
--- testsuite/gdb.base/charsign.c	23 Aug 2007 18:08:49 -0000	1.2
+++ /dev/null	1 Jan 1970 00:00:00 -0000
@@ -1,36 +0,0 @@
-/* This testcase is part of GDB, the GNU debugger.
-
-   Copyright 2007 Free Software Foundation, Inc.
-
-   This program is free software; you can redistribute it and/or modify
-   it under the terms of the GNU General Public License as published by
-   the Free Software Foundation; either version 3 of the License, or
-   (at your option) any later version.
-
-   This program is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-   GNU General Public License for more details.
-
-   You should have received a copy of the GNU General Public License
-   along with this program.  If not, see <http://www.gnu.org/licenses/>.
-
-   Please email any bugs, comments, and/or additions to this file to:
-   bug-gdb@prep.ai.mit.edu  */
-
-int main()
-{
-  return 0;
-}
-
-char n[]="A";
-signed char s[]="A";
-unsigned char u[]="A";
-
-typedef char char_n;
-typedef signed char char_s;
-typedef unsigned char char_u;
-
-char_n n_typed[]="A";
-char_s s_typed[]="A";
-char_u u_typed[]="A";
Index: testsuite/gdb.base/charsign.exp
===================================================================
RCS file: testsuite/gdb.base/charsign.exp
diff -N testsuite/gdb.base/charsign.exp
--- testsuite/gdb.base/charsign.exp	23 Aug 2007 18:14:16 -0000	1.3
+++ /dev/null	1 Jan 1970 00:00:00 -0000
@@ -1,67 +0,0 @@
-# Copyright 2007 Free Software Foundation, Inc.
-
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program.  If not, see <http://www.gnu.org/licenses/>.
-
-if $tracelevel then {
-    strace $tracelevel
-}
-
-set prms_id 0
-set bug_id 0
-
-set testfile charsign
-set srcfile ${testfile}.c
-set binfile ${objdir}/${subdir}/${testfile}
-
-proc do_test { cflags } {
-    global srcdir
-    global binfile
-    global subdir
-    global srcfile
-    global gdb_prompt
-
-    if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable [list debug additional_flags=$cflags]] != "" } {
-	untested "Couldn't compile test program"
-	return -1
-    }
-
-    # Get things started.
-
-    gdb_exit
-    gdb_start
-    gdb_reinitialize_dir $srcdir/$subdir
-    gdb_load ${binfile}
-
-    gdb_test "p n" \
-	     "= \"A\""
-    gdb_test "p s" \
-	     "= \\{65 'A', 0 '\\\\0'\\}"
-    gdb_test "p u" \
-	     "= \\{65 'A', 0 '\\\\0'\\}"
-    gdb_test "p n_typed" \
-	     "= \"A\""
-    gdb_test "p s_typed" \
-	     "= \\{65 'A', 0 '\\\\0'\\}"
-    gdb_test "p u_typed" \
-	     "= \\{65 'A', 0 '\\\\0'\\}"
-}
-
-# The string identification works despite the compiler flags below due to
-# gdbtypes.c:
-#   if (name && strcmp (name, "char") == 0)
-#     TYPE_FLAGS (type) |= TYPE_FLAG_NOSIGN;
-
-do_test {}
-do_test {-fsigned-char}
-do_test {-funsigned-char}
Index: testsuite/gdb.base/display.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.base/display.exp,v
retrieving revision 1.11
diff -u -p -r1.11 display.exp
--- testsuite/gdb.base/display.exp	23 Aug 2007 18:14:16 -0000	1.11
+++ testsuite/gdb.base/display.exp	25 Aug 2007 01:08:27 -0000
@@ -195,7 +195,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: testsuite/gdb.base/printcmds.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.base/printcmds.exp,v
retrieving revision 1.16
diff -u -p -r1.16 printcmds.exp
--- testsuite/gdb.base/printcmds.exp	23 Aug 2007 18:14:17 -0000	1.16
+++ testsuite/gdb.base/printcmds.exp	25 Aug 2007 01:08:27 -0000
@@ -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: testsuite/gdb.base/setvar.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.base/setvar.exp,v
retrieving revision 1.12
diff -u -p -r1.12 setvar.exp
--- testsuite/gdb.base/setvar.exp	23 Aug 2007 18:14:17 -0000	1.12
+++ testsuite/gdb.base/setvar.exp	25 Aug 2007 01:08:27 -0000
@@ -232,11 +232,11 @@ test_set "set variable v_char_array\[0\]
 #
 # 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_arra
 #
 # 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 Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]