Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: "Andrew Burgess" <aburgess@broadcom.com>
To: "gdb-patches@sourceware.org" <gdb-patches@sourceware.org>
Subject: [rfc] display vector types using vector_size syntax
Date: Mon, 03 Sep 2012 10:56:00 -0000	[thread overview]
Message-ID: <50448CC0.8060706@broadcom.com> (raw)

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


             reply	other threads:[~2012-09-03 10:56 UTC|newest]

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

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=50448CC0.8060706@broadcom.com \
    --to=aburgess@broadcom.com \
    --cc=gdb-patches@sourceware.org \
    /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