From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 12430 invoked by alias); 25 Jun 2010 08:37:42 -0000 Received: (qmail 12419 invoked by uid 22791); 25 Jun 2010 08:37:41 -0000 X-SWARE-Spam-Status: No, hits=-2.0 required=5.0 tests=AWL,BAYES_00,T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mtagate3.uk.ibm.com (HELO mtagate3.uk.ibm.com) (194.196.100.163) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 25 Jun 2010 08:37:36 +0000 Received: from d06nrmr1707.portsmouth.uk.ibm.com (d06nrmr1707.portsmouth.uk.ibm.com [9.149.39.225]) by mtagate3.uk.ibm.com (8.13.1/8.13.1) with ESMTP id o5P8bYqg000310 for ; Fri, 25 Jun 2010 08:37:34 GMT Received: from d06av04.portsmouth.uk.ibm.com (d06av04.portsmouth.uk.ibm.com [9.149.37.216]) by d06nrmr1707.portsmouth.uk.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id o5P8bXwh1515698 for ; Fri, 25 Jun 2010 09:37:34 +0100 Received: from d06av04.portsmouth.uk.ibm.com (loopback [127.0.0.1]) by d06av04.portsmouth.uk.ibm.com (8.12.11.20060308/8.13.3) with ESMTP id o5P8bXpP026070 for ; Fri, 25 Jun 2010 09:37:33 +0100 Received: from leonard.localnet (dyn-9-152-224-29.boeblingen.de.ibm.com [9.152.224.29]) by d06av04.portsmouth.uk.ibm.com (8.12.11.20060308/8.12.11) with ESMTP id o5P8bU9j025970 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Fri, 25 Jun 2010 09:37:33 +0100 From: Ken Werner To: gdb-patches@sourceware.org Subject: [patch] Printing of character vectors Date: Fri, 25 Jun 2010 08:37:00 -0000 User-Agent: KMail/1.13.2 (Linux/2.6.32-22-generic-pae; KDE/4.4.2; i686; ; ) MIME-Version: 1.0 Content-Type: Multipart/Mixed; boundary="Boundary-00=_JrGJMC3aGYsZKPC" Message-Id: <201006251037.29862.ken@linux.vnet.ibm.com> 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: 2010-06/txt/msg00573.txt.bz2 --Boundary-00=_JrGJMC3aGYsZKPC Content-Type: Text/Plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Content-length: 667 Hello, I noticed that char vectors are printed like char arrays (as strings). Here is the output of a sample session: Temporary breakpoint 1, main () at gnu_vector.c:3 3 int __attribute__ ((vector_size (4 * sizeof(int)))) i4 = {3, 2, 1, 0}; (gdb) n 4 char __attribute__ ((vector_size (4 * sizeof(char)))) c4 = {3, 2, 1, 0}; (gdb) 5 return 0; (gdb) p i4 $1 = {3, 2, 1, 0} (gdb) p c4 $2 = "\003\002\001" Is this intended? The attached patch changes c_val_print to additionally check if the type is a vector. Tested on powerpc64-*-linux-gnu and i686-*-linux-gnu, no regressions. Any suggestions are welcome. Regards, -ken --Boundary-00=_JrGJMC3aGYsZKPC Content-Type: text/x-patch; charset="UTF-8"; name="vec-valprint.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="vec-valprint.patch" Content-length: 2931 ChangeLog: 2010-06-25 Ken Werner * gdb/c-valprint.c (c_val_print): Fix printing of character vectors. testsuite/ChangeLog: 2010-06-25 Ken Werner * gdb.arch/altivec-abi.exp: Fix expect pattern of character vectors. Index: gdb/c-valprint.c =================================================================== RCS file: /cvs/src/src/gdb/c-valprint.c,v retrieving revision 1.70 diff -p -u -r1.70 c-valprint.c --- gdb/c-valprint.c 21 Jun 2010 18:01:50 -0000 1.70 +++ gdb/c-valprint.c 24 Jun 2010 16:19:27 -0000 @@ -180,7 +180,8 @@ c_val_print (struct type *type, const gd /* Print arrays of textual chars with a string syntax, as long as the entire array is valid. */ - if (c_textual_element_type (unresolved_elttype, options->format) + if (!TYPE_VECTOR (type) + && c_textual_element_type (unresolved_elttype, options->format) && value_bits_valid (original_value, TARGET_CHAR_BIT * embedded_offset, TARGET_CHAR_BIT * TYPE_LENGTH (type))) Index: gdb/testsuite/gdb.arch/altivec-abi.exp =================================================================== RCS file: /cvs/src/src/gdb/testsuite/gdb.arch/altivec-abi.exp,v retrieving revision 1.18 diff -p -u -r1.18 altivec-abi.exp --- gdb/testsuite/gdb.arch/altivec-abi.exp 1 Jan 2010 07:32:00 -0000 1.18 +++ gdb/testsuite/gdb.arch/altivec-abi.exp 24 Jun 2010 16:19:28 -0000 @@ -82,7 +82,7 @@ proc altivec_abi_tests { extra_flags for # now all the arguments of vec_fun are initialized - set pattern "vec_func .vshort_f=.111, 222, 333, 444, 555, 666, 777, 888., vushort_f=.100, 200, 300, 400, 500, 600, 700, 800., vint_f=.-10, -20, -30, -40., vuint_f=.1111, 2222, 3333, 4444., vchar_f=.abcdefghilmnopqr., vuchar_f=.ABCDEFGHILMNOPQR., vfloat_f=.1.25, 3.75, 5.5, 1.25., x_f=.1, 2, 3, 4, 5, 6, 7, 8., y_f=.12, 22, 32, 42., a_f=.vector of chars.., b_f=.5.5, 4.5, 3.75, 2.25., c_f=.1.25, 3.5, 5.5, 7.75., intv_on_stack_f=.12, 34, 56, 78.." + set pattern "vec_func .vshort_f=.111, 222, 333, 444, 555, 666, 777, 888., vushort_f=.100, 200, 300, 400, 500, 600, 700, 800., vint_f=.-10, -20, -30, -40., vuint_f=.1111, 2222, 3333, 4444., vchar_f=.97 'a', 98 'b', 99 'c', 100 'd', 101 'e', 102 'f', 103 'g', 104 'h', 105 'i', 108 'l', 109 'm', 110 'n', 111 'o', 112 'p', 113 'q', 114 'r'., vuchar_f=.65 'A', 66 'B', 67 'C', 68 'D', 69 'E', 70 'F', 71 'G', 72 'H', 73 'I', 76 'L', 77 'M', 78 'N', 79 'O', 80 'P', 81 'Q', 82 'R'., vfloat_f=.1.25, 3.75, 5.5, 1.25., x_f=.1, 2, 3, 4, 5, 6, 7, 8., y_f=.12, 22, 32, 42., a_f=.118 'v', 101 'e', 99 'c', 116 't', 111 'o', 114 'r', 32 ' ', 111 'o', 102 'f', 32 ' ', 99 'c', 104 'h', 97 'a', 114 'r', 115 's', 46 '.'., b_f=.5.5, 4.5, 3.75, 2.25., c_f=.1.25, 3.5, 5.5, 7.75., intv_on_stack_f=.12, 34, 56, 78.." set pattern1 $pattern append pattern1 " at.*altivec-abi.c.*vint_res = vec_add.*vint_f, intv_on_stack_f.;" --Boundary-00=_JrGJMC3aGYsZKPC--