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]

[rfc] display vector types using vector_size syntax


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]