From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 4055 invoked by alias); 8 Jun 2005 06:57:23 -0000 Mailing-List: contact gdb-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-owner@sources.redhat.com Received: (qmail 4042 invoked by uid 22791); 8 Jun 2005 06:57:18 -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; Wed, 08 Jun 2005 06:57:18 +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 j586xCIW109502 for ; Wed, 8 Jun 2005 16:59:14 +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 j586xZHA114578 for ; Wed, 8 Jun 2005 16:59:35 +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 j586ug3d006716 for ; Wed, 8 Jun 2005 16:56:42 +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 j586ue8k006645 for ; Wed, 8 Jun 2005 16:56:41 +1000 Date: Wed, 08 Jun 2005 06:57:00 -0000 From: Wu Zhou To: gdb@sources.redhat.com Subject: Re: Program terminated with SIGSEGV when trying to print an array element In-Reply-To: <20050607131417.GB30174@nevyn.them.org> Message-ID: References: <20050607131417.GB30174@nevyn.them.org> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-SW-Source: 2005-06/txt/msg00064.txt.bz2 On Tue, 7 Jun 2005, Daniel Jacobowitz wrote: > On Tue, Jun 07, 2005 at 04:58:10PM +0800, Wu Zhou wrote: > > As far as I can see, the problem lies in that GDB take TYPE_CODE_PTR as > > a function call as well. But in the above failing testcase, "a" is a > > pointer to array type (Fortran treat formal parameter as pointer). Its > > code is TYPE_CODE_PTR indeed, but it is not a function call. > > > > So maybe we need to change the code logic above. My thought is when the > > code match TYPE_CODE_PTR, we first get its target_type. If it is > > TYPE_CODE_ARRAY, we can goto multi_f77_subscript. If not, we can go on > > with the orignial path. But I have one question on the original code: > > in which circumstance should a function's code return TYPE_CODE_PTR, > > isn't the code of a function always return TYPE_CODE_FUNC? > > > > Any thought on this? Any suggestions and comments are highly appreciated! > > You didn't mention what Fortran compiler was being used. Probably, > whichever one it was, it generates debug information that GDB is not > expecting. I used g77-3.3.3 on PPC64, and gfortran-4.0.0 on Fedora 4 test 3 on i386. Both failed (Illegal instruction on PPC64 and SEGV error on i386). I had some look at the related debuginfo (array "a"), it is indeed an pointer to array on both platform. > It sounds like you're right; we should be checking the target type of > the pointer. Can we end up with a pointer to a string, too? Sure. But now I am having difficulty in one problem: given an struct value with the type being TYPE_CODE_PTR, how to get the value of the array (or string or whatever) it refer to? We need to know this to go on with the following evaluation. I had thought that function "value_from_pointer" will do this, but it turn out to be false. Anyone could help on this? Thanks in advance. Cheers - Wu Zhou