From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 11268 invoked by alias); 3 Sep 2012 10:56:26 -0000 Received: (qmail 11257 invoked by uid 22791); 3 Sep 2012 10:56:25 -0000 X-SWARE-Spam-Status: No, hits=-3.7 required=5.0 tests=AWL,BAYES_00,KHOP_RCVD_UNTRUST,RCVD_IN_HOSTKARMA_W,RCVD_IN_HOSTKARMA_WL,RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mms2.broadcom.com (HELO mms2.broadcom.com) (216.31.210.18) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 03 Sep 2012 10:56:11 +0000 Received: from [10.9.200.131] by mms2.broadcom.com with ESMTP (Broadcom SMTP Relay (Email Firewall v6.5)); Mon, 03 Sep 2012 03:54:39 -0700 X-Server-Uuid: 4500596E-606A-40F9-852D-14843D8201B2 Received: from mail-irva-13.broadcom.com (10.11.16.103) by IRVEXCHHUB01.corp.ad.broadcom.com (10.9.200.131) with Microsoft SMTP Server id 8.2.247.2; Mon, 3 Sep 2012 03:56:02 -0700 Received: from [10.177.72.87] (unknown [10.177.72.87]) by mail-irva-13.broadcom.com (Postfix) with ESMTP id DB00C9F9F8 for ; Mon, 3 Sep 2012 03:56:01 -0700 (PDT) Message-ID: <50448CC0.8060706@broadcom.com> Date: Mon, 03 Sep 2012 10:56:00 -0000 From: "Andrew Burgess" User-Agent: Mozilla/5.0 (Windows NT 6.1; rv:15.0) Gecko/20120824 Thunderbird/15.0 MIME-Version: 1.0 To: "gdb-patches@sourceware.org" Subject: [rfc] display vector types using vector_size syntax Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 7bit X-IsSubscribed: yes Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2012-09/txt/msg00015.txt.bz2 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 * 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 * 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}"