public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [patch]  Printing of character vectors
@ 2010-06-25  8:37 Ken Werner
  2010-06-25 21:59 ` Tom Tromey
  0 siblings, 1 reply; 6+ messages in thread
From: Ken Werner @ 2010-06-25  8:37 UTC (permalink / raw)
  To: gdb-patches

[-- Attachment #1: Type: Text/Plain, Size: 667 bytes --]

Hello,

I noticed that char vectors are printed like char arrays (as strings). Here is 
the output of a sample session:
<snip>
Temporary breakpoint 1, main () at gnu_vector.c:3
3         int __attribute__ ((vector_size (4 * sizeof(int)))) i4 = {3, 2, 1, 
0};
(gdb) n
4         char __attribute__ ((vector_size (4 * sizeof(char)))) c4 = {3, 2, 1, 
0};
(gdb) 
5         return 0;
(gdb) p i4
$1 = {3, 2, 1, 0}
(gdb) p c4
$2 = "\003\002\001"
</snip>

Is this intended?
The attached patch changes c_val_print to additionally check if the type is a 
vector. Tested on powerpc64-*-linux-gnu and i686-*-linux-gnu, no regressions. 
Any suggestions are welcome.

Regards,
-ken

[-- Attachment #2: vec-valprint.patch --]
[-- Type: text/x-patch, Size: 2931 bytes --]

ChangeLog:

2010-06-25  Ken Werner  <ken.werner@de.ibm.com>

	* gdb/c-valprint.c (c_val_print): Fix printing of character vectors.

testsuite/ChangeLog:

2010-06-25  Ken Werner  <ken.werner@de.ibm.com>

	* gdb.arch/altivec-abi.exp: Fix expect pattern of character vectors.


Index: gdb/c-valprint.c
===================================================================
RCS file: /cvs/src/src/gdb/c-valprint.c,v
retrieving revision 1.70
diff -p -u -r1.70 c-valprint.c
--- gdb/c-valprint.c	21 Jun 2010 18:01:50 -0000	1.70
+++ gdb/c-valprint.c	24 Jun 2010 16:19:27 -0000
@@ -180,7 +180,8 @@ c_val_print (struct type *type, const gd
 
 	  /* Print arrays of textual chars with a string syntax, as
 	     long as the entire array is valid.  */
-          if (c_textual_element_type (unresolved_elttype, options->format)
+          if (!TYPE_VECTOR (type)
+	      && c_textual_element_type (unresolved_elttype, options->format)
 	      && value_bits_valid (original_value,
 				   TARGET_CHAR_BIT * embedded_offset,
 				   TARGET_CHAR_BIT * TYPE_LENGTH (type)))
Index: gdb/testsuite/gdb.arch/altivec-abi.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.arch/altivec-abi.exp,v
retrieving revision 1.18
diff -p -u -r1.18 altivec-abi.exp
--- gdb/testsuite/gdb.arch/altivec-abi.exp	1 Jan 2010 07:32:00 -0000	1.18
+++ gdb/testsuite/gdb.arch/altivec-abi.exp	24 Jun 2010 16:19:28 -0000
@@ -82,7 +82,7 @@ proc altivec_abi_tests { extra_flags for
 
     # now all the arguments of vec_fun are initialized
 
-    set pattern "vec_func .vshort_f=.111, 222, 333, 444, 555, 666, 777, 888., vushort_f=.100, 200, 300, 400, 500, 600, 700, 800., vint_f=.-10, -20, -30, -40., vuint_f=.1111, 2222, 3333, 4444., vchar_f=.abcdefghilmnopqr., vuchar_f=.ABCDEFGHILMNOPQR., vfloat_f=.1.25, 3.75, 5.5, 1.25., x_f=.1, 2, 3, 4, 5, 6, 7, 8., y_f=.12, 22, 32, 42., a_f=.vector of chars.., b_f=.5.5, 4.5, 3.75, 2.25., c_f=.1.25, 3.5, 5.5, 7.75., intv_on_stack_f=.12, 34, 56, 78.."
+    set pattern "vec_func .vshort_f=.111, 222, 333, 444, 555, 666, 777, 888., vushort_f=.100, 200, 300, 400, 500, 600, 700, 800., vint_f=.-10, -20, -30, -40., vuint_f=.1111, 2222, 3333, 4444., vchar_f=.97 'a', 98 'b', 99 'c', 100 'd', 101 'e', 102 'f', 103 'g', 104 'h', 105 'i', 108 'l', 109 'm', 110 'n', 111 'o', 112 'p', 113 'q', 114 'r'., vuchar_f=.65 'A', 66 'B', 67 'C', 68 'D', 69 'E', 70 'F', 71 'G', 72 'H', 73 'I', 76 'L', 77 'M', 78 'N', 79 'O', 80 'P', 81 'Q', 82 'R'., vfloat_f=.1.25, 3.75, 5.5, 1.25., x_f=.1, 2, 3, 4, 5, 6, 7, 8., y_f=.12, 22, 32, 42., a_f=.118 'v', 101 'e', 99 'c', 116 't', 111 'o', 114 'r', 32 ' ', 111 'o', 102 'f', 32 ' ', 99 'c', 104 'h', 97 'a', 114 'r', 115 's', 46 '.'., b_f=.5.5, 4.5, 3.75, 2.25., c_f=.1.25, 3.5, 5.5, 7.75., intv_on_stack_f=.12, 34, 56, 78.."
 
     set pattern1 $pattern
     append pattern1 " at.*altivec-abi.c.*vint_res  = vec_add.*vint_f, intv_on_stack_f.;"

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [patch]  Printing of character vectors
  2010-06-25  8:37 [patch] Printing of character vectors Ken Werner
@ 2010-06-25 21:59 ` Tom Tromey
  2010-06-27 17:15   ` Joel Brobecker
  2010-07-02 14:06   ` Ken Werner
  0 siblings, 2 replies; 6+ messages in thread
From: Tom Tromey @ 2010-06-25 21:59 UTC (permalink / raw)
  To: Ken Werner; +Cc: gdb-patches

>>>>> "Ken" == Ken Werner <ken@linux.vnet.ibm.com> writes:

Ken> I noticed that char vectors are printed like char arrays (as
Ken> strings). Here is the output of a sample session:

Ken> Is this intended?

I do not know.  The test case was written that way, but that isn't
necessarily indicative of intent.

Is it ever useful?

Ken> The attached patch changes c_val_print to additionally check if the
Ken> type is a vector. Tested on powerpc64-*-linux-gnu and
Ken> i686-*-linux-gnu, no regressions.  Any suggestions are welcome.

The patch itself is fine.  I think the only question is what behavior we
want.

If you don't hear any objections in the next week, go ahead and check it
in.

Tom

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [patch]  Printing of character vectors
  2010-06-25 21:59 ` Tom Tromey
@ 2010-06-27 17:15   ` Joel Brobecker
  2010-07-02 14:06   ` Ken Werner
  1 sibling, 0 replies; 6+ messages in thread
From: Joel Brobecker @ 2010-06-27 17:15 UTC (permalink / raw)
  To: Tom Tromey; +Cc: Ken Werner, gdb-patches

> I do not know.  The test case was written that way, but that isn't
> necessarily indicative of intent.
> 
> Is it ever useful?

This is a bit of a guess, but I would tend to agree that vectors should
be displayed as arrays. If one wants to display the vector as a string,
it should be possible to do so using x/s.

-- 
Joel

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [patch]  Printing of character vectors
  2010-06-25 21:59 ` Tom Tromey
  2010-06-27 17:15   ` Joel Brobecker
@ 2010-07-02 14:06   ` Ken Werner
  2010-07-02 18:03     ` Tom Tromey
  1 sibling, 1 reply; 6+ messages in thread
From: Ken Werner @ 2010-07-02 14:06 UTC (permalink / raw)
  To: Tom Tromey; +Cc: gdb-patches

On Friday, June 25, 2010 11:59:08 pm you wrote:
> >>>>> "Ken" == Ken Werner <ken@linux.vnet.ibm.com> writes:
> Ken> The attached patch changes c_val_print to additionally check if the
> Ken> type is a vector. Tested on powerpc64-*-linux-gnu and
> Ken> i686-*-linux-gnu, no regressions.  Any suggestions are welcome.
> 
> The patch itself is fine.  I think the only question is what behavior we
> want.
> 
> If you don't hear any objections in the next week, go ahead and check it
> in.
> 
> Tom

Hi Tom,
A week has passed and it seems there are no objections. As I don't have write 
privileges to the repository could you apply the patch please?

Regards
Ken

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [patch]  Printing of character vectors
  2010-07-02 14:06   ` Ken Werner
@ 2010-07-02 18:03     ` Tom Tromey
  2010-07-05  8:18       ` Ken Werner
  0 siblings, 1 reply; 6+ messages in thread
From: Tom Tromey @ 2010-07-02 18:03 UTC (permalink / raw)
  To: Ken Werner; +Cc: gdb-patches

>>>>> "Ken" == Ken Werner <ken@linux.vnet.ibm.com> writes:

Ken> A week has passed and it seems there are no objections. As I don't
Ken> have write privileges to the repository could you apply the patch
Ken> please?

I checked it in.

Tom

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [patch]  Printing of character vectors
  2010-07-02 18:03     ` Tom Tromey
@ 2010-07-05  8:18       ` Ken Werner
  0 siblings, 0 replies; 6+ messages in thread
From: Ken Werner @ 2010-07-05  8:18 UTC (permalink / raw)
  To: Tom Tromey; +Cc: gdb-patches

On Friday, July 02, 2010 08:03:33 pm you wrote:
> >>>>> "Ken" == Ken Werner <ken@linux.vnet.ibm.com> writes:
> Ken> A week has passed and it seems there are no objections. As I don't
> Ken> have write privileges to the repository could you apply the patch
> Ken> please?
> 
> I checked it in.
> 
> Tom

Thanks Tom.

-ken

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2010-07-05  8:18 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-06-25  8:37 [patch] Printing of character vectors Ken Werner
2010-06-25 21:59 ` Tom Tromey
2010-06-27 17:15   ` Joel Brobecker
2010-07-02 14:06   ` Ken Werner
2010-07-02 18:03     ` Tom Tromey
2010-07-05  8:18       ` Ken Werner

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