Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: "Andrew Burgess" <aburgess@broadcom.com>
To: "Tom Tromey" <tromey@redhat.com>
Cc: gdb-patches@sourceware.org
Subject: Re: [rfc] display vector types using vector_size syntax
Date: Mon, 29 Oct 2012 10:54:00 -0000	[thread overview]
Message-ID: <508E6050.1040806@broadcom.com> (raw)
In-Reply-To: <87r4ol12vs.fsf@fleche.redhat.com>

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}"




  reply	other threads:[~2012-10-29 10:54 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-09-03 10:56 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 [this message]
2012-10-30 20:46         ` Tom Tromey

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=508E6050.1040806@broadcom.com \
    --to=aburgess@broadcom.com \
    --cc=gdb-patches@sourceware.org \
    --cc=tromey@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox