This is the mail archive of the gdb@sources.redhat.com mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Program terminated with SIGSEGV when trying to print an arrayelement


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]