From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 4854 invoked by alias); 9 Jun 2005 11:00:35 -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 4837 invoked by uid 22791); 9 Jun 2005 11:00:32 -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; Thu, 09 Jun 2005 11:00:32 +0000 Received: from sd0208e0.au.ibm.com (d23rh904.au.ibm.com [202.81.18.202]) by ausmtp01.au.ibm.com (8.12.10/8.12.10) with ESMTP id j59B2VIW230158 for ; Thu, 9 Jun 2005 21:02:36 +1000 Received: from d23av03.au.ibm.com (d23av03.au.ibm.com [9.190.250.244]) by sd0208e0.au.ibm.com (8.12.10/NCO/VER6.6) with ESMTP id j59AdAsM036842 for ; Thu, 9 Jun 2005 21:02:50 +1000 Received: from d23av03.au.ibm.com (loopback [127.0.0.1]) by d23av03.au.ibm.com (8.12.11/8.13.3) with ESMTP id j59A6PQN025143 for ; Thu, 9 Jun 2005 20:06:26 +1000 Received: from plinuxt18.cn.ibm.com (plinuxt18.cn.ibm.com [9.181.140.28]) by d23av03.au.ibm.com (8.12.11/8.12.11) with ESMTP id j59A6NIm025037; Thu, 9 Jun 2005 20:06:24 +1000 Date: Thu, 09 Jun 2005 11:00:00 -0000 From: Wu Zhou To: drow@false.org cc: gdb-patches@sources.redhat.com Subject: [RFA]: Patch to fix the SEGV error when printing f77 array element Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-SW-Source: 2005-06/txt/msg00075.txt.bz2 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. 2005-06-9 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 TYPE_CODE_ARRAY or TYPE_CODE_STRING, jump to relevant code path, else go on with the original path. 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 9 Jun 2005 09:23:02 -0000 *************** evaluate_subexp_standard (struct type *e *** 1254,1260 **** case TYPE_CODE_STRING: goto op_f77_substr; - case TYPE_CODE_PTR: case TYPE_CODE_FUNC: /* It's a function call. */ /* Allocate arg vector, including space for the function to be --- 1254,1259 ---- *************** evaluate_subexp_standard (struct type *e *** 1267,1272 **** --- 1266,1298 ---- argvec[tem] = 0; /* signal end of arglist */ goto do_call_it; + case TYPE_CODE_PTR: + /* Fortran always passes variables to subroutines as pointer. + So we need to look into its target type to see if it is + array subscript or substring operations. */ + switch (TYPE_CODE (TYPE_TARGET_TYPE (type))) + { + case TYPE_CODE_ARRAY: + arg1 = value_ind (arg1); + type = check_typedef (value_type (arg1)); + goto multi_f77_subscript; + + case TYPE_CODE_STRING: + arg1 = value_ind (arg1); + type = check_typedef (value_type (arg1)); + goto op_f77_substr; + + default: + /* It's a function call. */ + argvec = (struct value **) alloca (sizeof (struct value *) * (nargs + 2)); + argvec[0] = arg1; + tem = 1; + for (; tem <= nargs; tem++) + argvec[tem] = evaluate_subexp_with_coercion (exp, pos, noside); + argvec[tem] = 0; /* signal end of arglist */ + goto do_call_it; + } + default: error (_("Cannot perform substring on this type")); } Cheers - Wu Zhou