Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [rfc] display vector types using vector_size syntax
@ 2012-09-03 10:56 Andrew Burgess
  2012-09-10 17:12 ` Tom Tromey
  0 siblings, 1 reply; 10+ messages in thread
From: Andrew Burgess @ 2012-09-03 10:56 UTC (permalink / raw)
  To: gdb-patches

Given a test program such as:

char vector  __attribute__ ((vector_size (4)));

int
main ( void )
{
  return 0;
}

The current gdb behaviour is:

(gdb) ptype vector
type = char [4]
(gdb) whatis vector 
type = char [4]

I'd like to change the behaviour to this:

(gdb) ptype vector 
type = char ((vector_size(4)))
(gdb) whatis vector 
type = char ((vector_size(4)))

My real aim here is to distinguish between variables that are classic arrays, and those that are vectors, stealing the gcc "vector_size" seemed the clearest, though I've dropped the "__attribute__" text to avoid too much clutter.

I've updated the one existing test I could find that tested this behaviour, it's in gdb.xml/tdesc-regs.exp of all places, I could add a test to gdb.base/gnu_vector.exp too if needed, but this would be a duplicate test.

Ok to apply?


Andrew

gdb/ChangeLog

2012-09-03  Andrew Burgess  <aburgess@broadcom.com>

	* c-typeprint.c (c_type_print_varspec_suffix): Display the size of
	vector variables using vector_size syntax rather than array
	syntax.

diff --git a/gdb/c-typeprint.c b/gdb/c-typeprint.c
index b51ced8..045a5b4 100644
--- a/gdb/c-typeprint.c
+++ b/gdb/c-typeprint.c
@@ -618,15 +618,16 @@ c_type_print_varspec_suffix (struct type *type,
     case TYPE_CODE_ARRAY:
       {
        LONGEST low_bound, high_bound;
+       int is_vector = TYPE_VECTOR (type);
 
        if (passed_a_ptr)
          fprintf_filtered (stream, ")");
 
-       fprintf_filtered (stream, "[");
+       fprintf_filtered (stream, (is_vector ? "((vector_size(" : "["));
        if (get_array_bounds (type, &low_bound, &high_bound))
          fprintf_filtered (stream, "%d", 
                            (int) (high_bound - low_bound + 1));
-       fprintf_filtered (stream, "]");
+       fprintf_filtered (stream, (is_vector ? ")))" : "]"));
 
        c_type_print_varspec_suffix (TYPE_TARGET_TYPE (type), stream,
                                     show, 0, 0);

gdb/testsuite/ChangeLog

2012-09-03  Andrew Burgess  <aburgess@broadcom.com>

	* gdb.xml/tdesc-regs.exp: Update expected output for new
	vector_size syntax of vector types.

diff --git a/gdb/testsuite/gdb.xml/tdesc-regs.exp b/gdb/testsuite/gdb.xml/tdesc-
index 9a89d7e..d2aa710 100644
--- a/gdb/testsuite/gdb.xml/tdesc-regs.exp
+++ b/gdb/testsuite/gdb.xml/tdesc-regs.exp
@@ -137,13 +137,13 @@ proc load_description { file errmsg } {
 load_description "extra-regs.xml" ""
 gdb_test "ptype \$extrareg" "type = (int|long|long long)"
 gdb_test "ptype \$uintreg" "type = uint32_t"
-gdb_test "ptype \$vecreg" "type = int8_t \\\[4\\\]"
+gdb_test "ptype \$vecreg" "type = int8_t \\(\\(vector_size\\(4\\)\\)\\)"
 gdb_test "ptype \$unionreg" \
     "type = union {\r\n *v4int8 v4;\r\n *v2int16 v2;\r\n}"
-gdb_test "ptype \$unionreg.v4" "type = int8_t \\\[4\\\]"
+gdb_test "ptype \$unionreg.v4" "type = int8_t \\(\\(vector_size\\(4\\)\\)\\)"
 gdb_test "ptype \$structreg" \
     "type = struct struct1 {\r\n *v4int8 v4;\r\n *v2int16 v2;\r\n}"
-gdb_test "ptype \$structreg.v4" "type = int8_t \\\[4\\\]"
+gdb_test "ptype \$structreg.v4" "type = int8_t \\(\\(vector_size\\(4\\)\\)\\)"
 gdb_test "ptype \$bitfields" \
     "type = struct struct2 {\r\n *uint64_t f1 : 35;\r\n *uint64_t f2 : 1;\r\n}"
 


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

* Re: [rfc] display vector types using vector_size syntax
  2012-09-03 10:56 [rfc] display vector types using vector_size syntax Andrew Burgess
@ 2012-09-10 17:12 ` Tom Tromey
  2012-09-10 22:06   ` Joel Brobecker
  2012-09-14 21:27   ` Andrew Burgess
  0 siblings, 2 replies; 10+ messages in thread
From: Tom Tromey @ 2012-09-10 17:12 UTC (permalink / raw)
  To: Andrew Burgess; +Cc: gdb-patches

>>>>> "Andrew" == Andrew Burgess <aburgess@broadcom.com> writes:

Andrew> I'd like to change the behaviour to this:
Andrew> (gdb) ptype vector 
Andrew> type = char ((vector_size(4)))
Andrew> (gdb) whatis vector 
Andrew> type = char ((vector_size(4)))

Seems reasonable to me.

Andrew> Ok to apply?

Please wait a few more days to see if there are any objections.

Tom


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

* Re: [rfc] display vector types using vector_size syntax
  2012-09-10 17:12 ` Tom Tromey
@ 2012-09-10 22:06   ` Joel Brobecker
  2012-09-11  9:11     ` Andrew Burgess
  2012-09-14 21:27   ` Andrew Burgess
  1 sibling, 1 reply; 10+ messages in thread
From: Joel Brobecker @ 2012-09-10 22:06 UTC (permalink / raw)
  To: Tom Tromey; +Cc: Andrew Burgess, gdb-patches

> Andrew> I'd like to change the behaviour to this:
> Andrew> (gdb) ptype vector 
> Andrew> type = char ((vector_size(4)))
> Andrew> (gdb) whatis vector 
> Andrew> type = char ((vector_size(4)))
> 
> Seems reasonable to me.

Just a thought: How about

    type = char __attribute__ ((vector_size(4)))

?

It know it's a lot more verbose, but the later speaks a lot more
to me than the original proposal...

-- 
Joel


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

* Re: [rfc] display vector types using vector_size syntax
  2012-09-10 22:06   ` Joel Brobecker
@ 2012-09-11  9:11     ` Andrew Burgess
  2012-09-11 11:35       ` Pedro Alves
  2012-09-11 22:07       ` Stan Shebs
  0 siblings, 2 replies; 10+ messages in thread
From: Andrew Burgess @ 2012-09-11  9:11 UTC (permalink / raw)
  To: gdb-patches; +Cc: Joel Brobecker, Tom Tromey

On 10/09/2012 11:06 PM, Joel Brobecker wrote:
>> Andrew> I'd like to change the behaviour to this:
>> Andrew> (gdb) ptype vector
>> Andrew> type = char ((vector_size(4)))
>> Andrew> (gdb) whatis vector
>> Andrew> type = char ((vector_size(4)))
>>
>> Seems reasonable to me.
>
> Just a thought: How about
>
>      type = char __attribute__ ((vector_size(4)))
>
> ?
>
> It know it's a lot more verbose, but the later speaks a lot more
> to me than the original proposal...

I only dropped this to avoid clutter, but I don't really mind either way.

I'll give it a couple more days for people to reply, then commit a 
version with "__attibute__".

Thanks,

Andrew


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

* Re: [rfc] display vector types using vector_size syntax
  2012-09-11  9:11     ` Andrew Burgess
@ 2012-09-11 11:35       ` Pedro Alves
  2012-09-11 22:07       ` Stan Shebs
  1 sibling, 0 replies; 10+ messages in thread
From: Pedro Alves @ 2012-09-11 11:35 UTC (permalink / raw)
  To: Andrew Burgess; +Cc: gdb-patches, Joel Brobecker, Tom Tromey

On 09/11/2012 10:09 AM, Andrew Burgess wrote:
> On 10/09/2012 11:06 PM, Joel Brobecker wrote:
>>> Andrew> I'd like to change the behaviour to this:
>>> Andrew> (gdb) ptype vector
>>> Andrew> type = char ((vector_size(4)))
>>> Andrew> (gdb) whatis vector
>>> Andrew> type = char ((vector_size(4)))
>>>
>>> Seems reasonable to me.
>>
>> Just a thought: How about
>>
>>      type = char __attribute__ ((vector_size(4)))
>>
>> ?
>>
>> It know it's a lot more verbose, but the later speaks a lot more
>> to me than the original proposal...
> 
> I only dropped this to avoid clutter, but I don't really mind either way.
> 
> I'll give it a couple more days for people to reply, then commit a version with "__attibute__".

+1 for __attribute__ being present from me.

-- 
Pedro Alves


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

* Re: [rfc] display vector types using vector_size syntax
  2012-09-11  9:11     ` Andrew Burgess
  2012-09-11 11:35       ` Pedro Alves
@ 2012-09-11 22:07       ` Stan Shebs
  1 sibling, 0 replies; 10+ messages in thread
From: Stan Shebs @ 2012-09-11 22:07 UTC (permalink / raw)
  To: gdb-patches

On 9/11/12 2:09 AM, Andrew Burgess wrote:
> On 10/09/2012 11:06 PM, Joel Brobecker wrote:
>>> Andrew> I'd like to change the behaviour to this:
>>> Andrew> (gdb) ptype vector
>>> Andrew> type = char ((vector_size(4)))
>>> Andrew> (gdb) whatis vector
>>> Andrew> type = char ((vector_size(4)))
>>>
>>> Seems reasonable to me.
>>
>> Just a thought: How about
>>
>>      type = char __attribute__ ((vector_size(4)))
>>
>> ?
>>
>> It know it's a lot more verbose, but the later speaks a lot more
>> to me than the original proposal...
>
> I only dropped this to avoid clutter, but I don't really mind either way.
>
> I'll give it a couple more days for people to reply, then commit a 
> version with "__attibute__".

I vote for __attribute__ too.  Although more cluttered, it immediately 
says "GCC extensions are hanging about" while the vector_size by itself 
looks like it could be one of the app's symbols that somehow found its 
way into the type (and users will no doubt assume that it's a GDB bug :-) ).

Stan
stan@codesourcery.com


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

* Re: [rfc] display vector types using vector_size syntax
  2012-09-10 17:12 ` Tom Tromey
  2012-09-10 22:06   ` Joel Brobecker
@ 2012-09-14 21:27   ` Andrew Burgess
  2012-10-26 18:53     ` Tom Tromey
  1 sibling, 1 reply; 10+ messages in thread
From: Andrew Burgess @ 2012-09-14 21:27 UTC (permalink / raw)
  To: gdb-patches

On 10/09/2012 6:11 PM, Tom Tromey wrote:
>>>>>> "Andrew" == Andrew Burgess <aburgess@broadcom.com> writes:
>
> Andrew> I'd like to change the behaviour to this:
> Andrew> (gdb) ptype vector
> Andrew> type = char ((vector_size(4)))
> Andrew> (gdb) whatis vector
> Andrew> type = char ((vector_size(4)))
>
> Seems reasonable to me.

Committed, but with the extra "__attribute__" syntax as that seemed to 
be the most popular.

http://sourceware.org/ml/gdb-cvs/2012-09/msg00069.html

Cheers,
Andrew




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

* Re: [rfc] display vector types using vector_size syntax
  2012-09-14 21:27   ` Andrew Burgess
@ 2012-10-26 18:53     ` Tom Tromey
  2012-10-29 10:54       ` Andrew Burgess
  0 siblings, 1 reply; 10+ messages in thread
From: Tom Tromey @ 2012-10-26 18:53 UTC (permalink / raw)
  To: Andrew Burgess; +Cc: gdb-patches

>>>>> "Andrew" == Andrew Burgess <aburgess@broadcom.com> writes:

Andrew> Committed, but with the extra "__attribute__" syntax as that seemed to
Andrew> be the most popular.
Andrew> http://sourceware.org/ml/gdb-cvs/2012-09/msg00069.html

With this patch I get weird output sometimes:

(gdb) ptype $_siginfo
type = struct {
    int si_signo;
    int si_errno;
    int si_code;
    union {
        int _pad__attribute__ ((vector_size(28)));

Note the lack of a space between "_pad" and "__attribute__".

I filed this as http://sourceware.org/bugzilla/show_bug.cgi?id=14772

Tom


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

* Re: [rfc] display vector types using vector_size syntax
  2012-10-26 18:53     ` Tom Tromey
@ 2012-10-29 10:54       ` Andrew Burgess
  2012-10-30 20:46         ` Tom Tromey
  0 siblings, 1 reply; 10+ messages in thread
From: Andrew Burgess @ 2012-10-29 10:54 UTC (permalink / raw)
  To: Tom Tromey; +Cc: gdb-patches

On 26/10/2012 7:53 PM, Tom Tromey wrote:
>>>>>> "Andrew" == Andrew Burgess <aburgess@broadcom.com> writes:
> 
> Andrew> Committed, but with the extra "__attribute__" syntax as that seemed to
> Andrew> be the most popular.
> Andrew> http://sourceware.org/ml/gdb-cvs/2012-09/msg00069.html
> 
> With this patch I get weird output sometimes:
> 
> (gdb) ptype $_siginfo
> type = struct {
>     int si_signo;
>     int si_errno;
>     int si_code;
>     union {
>         int _pad__attribute__ ((vector_size(28)));
> 
> Note the lack of a space between "_pad" and "__attribute__".
> 
> I filed this as http://sourceware.org/bugzilla/show_bug.cgi?id=14772

Sorry for the breakage.

The patch below fixes this, and adds some suitable tests.

OK to commit?

Thanks,
Andrew


gdb/ChangeLog

2012-10-29  Andrew Burgess  <aburgess@broadcom.com>

	PR cli/14772
	* c-typeprint.c (c_print_type): Don't print a space for vector
	types, this is handled within the suffix.
	(c_type_print_varspec_suffix): Add a space to vector suffix.

diff --git a/gdb/c-typeprint.c b/gdb/c-typeprint.c
index 8b5bc21..a43dfce 100644
--- a/gdb/c-typeprint.c
+++ b/gdb/c-typeprint.c
@@ -67,7 +67,8 @@ c_print_type (struct type *type,
       || ((show > 0 || TYPE_NAME (type) == 0)
 	  && (code == TYPE_CODE_PTR || code == TYPE_CODE_FUNC
 	      || code == TYPE_CODE_METHOD
-	      || code == TYPE_CODE_ARRAY
+	      || (code == TYPE_CODE_ARRAY
+		  && !TYPE_VECTOR (type))
 	      || code == TYPE_CODE_MEMBERPTR
 	      || code == TYPE_CODE_METHODPTR
 	      || code == TYPE_CODE_REF)))
@@ -619,7 +620,7 @@ c_type_print_varspec_suffix (struct type *type,
 	  fprintf_filtered (stream, ")");
 
 	fprintf_filtered (stream, (is_vector ?
-				   "__attribute__ ((vector_size(" : "["));
+				   " __attribute__ ((vector_size(" : "["));
 	if (get_array_bounds (type, &low_bound, &high_bound))
 	  fprintf_filtered (stream, "%s", 
 			    plongest (high_bound - low_bound + 1));



gdb/testsuite/ChangeLog

2012-10-29  Andrew Burgess  <aburgess@broadcom.com>

	PR cli/14772
	* gdb.base/gnu_vector.c (union_with_vector_1)
	(struct_with_vector_1): Add new struct and union for testing
	ptype.
	* gdb.base/gnu_vector.exp: Add testing of ptype on vectors, and
	structs / unions containing vectors.


diff --git a/gdb/testsuite/gdb.base/gnu_vector.c b/gdb/testsuite/gdb.base/gnu_vector.c
index dc4f60d..a2a218f 100644
--- a/gdb/testsuite/gdb.base/gnu_vector.c
+++ b/gdb/testsuite/gdb.base/gnu_vector.c
@@ -42,6 +42,19 @@ longlong2 ll2 = {1, 2};
 float2 f2 = {1, 2};
 double2 d2 = {1, 2};
 
+union
+{
+  int i;
+  char cv __attribute__ ((vector_size (sizeof (int))));
+} union_with_vector_1;
+
+struct
+{
+  int i;
+  char cv __attribute__ ((vector_size (sizeof (int))));
+  float4 f4;
+} struct_with_vector_1;
+
 int
 main ()
 {
diff --git a/gdb/testsuite/gdb.base/gnu_vector.exp b/gdb/testsuite/gdb.base/gnu_vector.exp
index a1443a5..baba119 100644
--- a/gdb/testsuite/gdb.base/gnu_vector.exp
+++ b/gdb/testsuite/gdb.base/gnu_vector.exp
@@ -130,3 +130,13 @@ gdb_test "print i2 + i4a" "Cannot perform operation on vectors with different ty
 gdb_test "print f4a + f2" "Cannot perform operation on vectors with different types"
 gdb_test "print f2 + f4a" "Cannot perform operation on vectors with different types"
 
+# Test ptype on vector types.
+gdb_test "ptype c4" "type = char __attribute__ \\(\\(vector_size\\(4\\)\\)\\)"
+gdb_test "ptype char4" "type = char __attribute__ \\(\\(vector_size\\(4\\)\\)\\)"
+gdb_test "ptype i4a" "type = int __attribute__ \\(\\(vector_size\\(4\\)\\)\\)"
+gdb_test "ptype int4" "type = int __attribute__ \\(\\(vector_size\\(4\\)\\)\\)"
+gdb_test "ptype f4b" "type = float __attribute__ \\(\\(vector_size\\(4\\)\\)\\)"
+gdb_test "ptype float4" "type = float __attribute__ \\(\\(vector_size\\(4\\)\\)\\)"
+
+gdb_test "ptype union_with_vector_1" "type = union {\r\n\[\t \]+int i;\r\n\[\t \]+char cv __attribute__ \\(\\(vector_size\\(4\\)\\)\\);\r\n}"
+gdb_test "ptype struct_with_vector_1" "type = struct {\r\n\[\t \]+int i;\r\n\[\t \]+char cv __attribute__ \\(\\(vector_size\\(4\\)\\)\\);\r\n\[\t \]+float4 f4;\r\n}"




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

* Re: [rfc] display vector types using vector_size syntax
  2012-10-29 10:54       ` Andrew Burgess
@ 2012-10-30 20:46         ` Tom Tromey
  0 siblings, 0 replies; 10+ messages in thread
From: Tom Tromey @ 2012-10-30 20:46 UTC (permalink / raw)
  To: Andrew Burgess; +Cc: gdb-patches

>>>>> "Andrew" == Andrew Burgess <aburgess@broadcom.com> writes:

Andrew> Sorry for the breakage.

No problem -- thanks for fixing it so quickly.

Andrew> The patch below fixes this, and adds some suitable tests.
Andrew> OK to commit?

Yes, thank you.

Tom


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

end of thread, other threads:[~2012-10-30 20:46 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-09-03 10:56 [rfc] display vector types using vector_size syntax Andrew Burgess
2012-09-10 17:12 ` Tom Tromey
2012-09-10 22:06   ` Joel Brobecker
2012-09-11  9:11     ` Andrew Burgess
2012-09-11 11:35       ` Pedro Alves
2012-09-11 22:07       ` Stan Shebs
2012-09-14 21:27   ` Andrew Burgess
2012-10-26 18:53     ` Tom Tromey
2012-10-29 10:54       ` Andrew Burgess
2012-10-30 20:46         ` Tom Tromey

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox