From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 29858 invoked by alias); 10 Jun 2005 07:37:21 -0000 Mailing-List: contact gdb-patches-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sources.redhat.com Received: (qmail 29844 invoked by uid 22791); 10 Jun 2005 07:37:17 -0000 Received: from ausmtp01.au.ibm.com (HELO ausmtp01.au.ibm.com) (202.81.18.186) by sourceware.org (qpsmtpd/0.30-dev) with ESMTP; Fri, 10 Jun 2005 07:37:17 +0000 Received: from sd0112e0.au.ibm.com (d23rh903.au.ibm.com [202.81.18.201]) by ausmtp01.au.ibm.com (8.12.10/8.12.10) with ESMTP id j5A7cMKa103716 for ; Fri, 10 Jun 2005 17:39:30 +1000 Received: from d23av01.au.ibm.com (d23av01.au.ibm.com [9.190.250.242]) by sd0112e0.au.ibm.com (8.12.10/NCO/VER6.6) with ESMTP id j5A7U8iD050806 for ; Fri, 10 Jun 2005 17:30:09 +1000 Received: from d23av01.au.ibm.com (loopback [127.0.0.1]) by d23av01.au.ibm.com (8.12.11/8.13.3) with ESMTP id j5A7RFm2018809 for ; Fri, 10 Jun 2005 17:27:15 +1000 Received: from plinuxt18.cn.ibm.com (plinuxt18.cn.ibm.com [9.181.140.28]) by d23av01.au.ibm.com (8.12.11/8.12.11) with ESMTP id j5A7RAQI018638; Fri, 10 Jun 2005 17:27:13 +1000 Date: Fri, 10 Jun 2005 07:37:00 -0000 From: Wu Zhou To: Daniel Jacobowitz cc: gdb-patches@sources.redhat.com Subject: Re: [RFA]: Patch to fix the SEGV error when printing f77 array element In-Reply-To: <20050609132002.GB965@nevyn.them.org> Message-ID: References: <20050609132002.GB965@nevyn.them.org> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-SW-Source: 2005-06/txt/msg00090.txt.bz2 On Thu, 9 Jun 2005, Daniel Jacobowitz wrote: > On Thu, Jun 09, 2005 at 06:02:03PM +0800, Wu Zhou wrote: > > Daniel, > > > > I had cleaned up the patch to fix the SEGV error we discussed on gdb@ the > > days before and tested it on ppc64 arch with the latest CVS tree. It > > works ok. Please review and comment. Thanks. > > Can you handle TYPE_CODE_PTR before the switch statement, instead? > > Also, rather than default, you can probably check that the target type > of the pointer is TYPE_CODE_FUNC. Good point. What about the following re-worked patch? Thanks. 2005-06-10 Wu Zhou * eval.c (evaluate_subexp_standard): Add code to check the target type of a TYPE_CODE_PTR value when we encounter a f77 undetermined arglist. If it is array, string or function, work on the target value instead. Index: eval.c =================================================================== RCS file: /cvs/src/src/gdb/eval.c,v retrieving revision 1.55 diff -c -p -r1.55 eval.c *** eval.c 26 May 2005 20:48:58 -0000 1.55 --- eval.c 10 Jun 2005 07:04:12 -0000 *************** evaluate_subexp_standard (struct type *e *** 1246,1251 **** --- 1246,1269 ---- type = check_typedef (value_type (arg1)); code = TYPE_CODE (type); + if (code == TYPE_CODE_PTR) + { + /* Fortran always passes variable to subroutines as pointer. + So we need to look into its target type to see if it is + array, string or function. If it is, we need to switch + to the target value the original one points to. */ + struct type *target_type = check_typedef (TYPE_TARGET_TYPE (type)); + + if (TYPE_CODE (target_type) == TYPE_CODE_ARRAY + || TYPE_CODE (target_type) == TYPE_CODE_STRING + || TYPE_CODE (target_type) == TYPE_CODE_FUNC) + { + arg1 = value_ind (arg1); + type = check_typedef (value_type (arg1)); + code = TYPE_CODE (type); + } + } + switch (code) { case TYPE_CODE_ARRAY: > Do you feel up to adding our first compilable fortran test to the > testsuite? Yes, I am thinking of adding a testcase to verify this. But do I need to keep some principles/tips in mind when adding a new testcase to the testsuite? As you might know, I didn't do that before. TIA. Cheers - Wu Zhou