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: fortran/1880: display of part of an array


On Mon, 27 Jun 2005, Fred Krogh wrote:

> Hi Wu Zhou --
>    There are a number of things that keep me from trying this.
> 
> 1. I can print part of local arrays just fine with "p x(3)@5" for example.
> 2. I don't use global variables (as common I presume), so I don't know if the
> current  gdb would support this or not.
> 3. I'm afraid I don't know how to fetch from the CVS tree, so to do so, I
> could use some instructions.

You can use this command:
  
 cvs -d :pserver:anoncvs@sources.redhat.com:/cvs/src co gdb

> 4. I'm a Gentoo user, but woefully ignorant of details I should know about.
> (I'm a developer of mathematical software not a systems person.)  I don't know
> how to update my gdb without messing up the portage information.  Thus I could
> use some help with this issue.

Normally, you need only try "configure && make", then use the gdb under 
your src/gdb directory. 
 
> If you can help me with the last two items, I would be happy to try the patch.
> But it would be nice to know what it does that the current gdb doesn't.

Ok.  This patch is my first attempt to add Fortran sub-array evaluation 
into GDB.  It is very initial.  So it is not reasonable to expect it to be 
perfect or to resolve all related problem. :-) 

> Finally, I don't see what the lack of a sub-array operatot in the Fortran 77
> standard has to do with gdb.  

IMO, when GDB developers wish to add support for a language, his first 
target will be to support all the valid expression of that language.  A 
language extension will not in the top priority IMHO.

> Can't one define whatever they want and let gdb
> parse it and act on it?  If this is the case then one would probably want to
> follow the current Fortran standard.  I should think that C programmers would
> also benefit from the ability to print subarrays with ease.

Sure.  If there is enough requirement, I think GDB is willing to support 
that.  In fact, I also believe that sub-array evaluation supporting is 
a good thing. 
  
> Lest this appear too negative, let me add that I really appreciate your
> responding to my problem.  And I am hopeful of getting a gdb that is more
> useful to me.  Many people think that Fortran is dead, but when it comes to
> mathematical/scientific/engineering computation, Fortran still rules.

Yes.  I also think so. And I am also hoping GDB to be good enough to 
handle fortran code.  

Cheers
- Wu Zhou
 
> Many Thanks,
>     Fred
> 
> Wu Zhou wrote:
> 
> > Hi Fred,
> > 
> > There is no sub-array operator in Fortran 77 standard.  So current GDB don't
> > support evaluating it.  However I ever tried to code a patch to evaluate
> > part of one-dimension array.  This works ok for array in global
> > namespace and also for local arrays in subroutine, but doesn't work for
> > these arrays which is passed as pointer to the subroutine. The reason is
> > that current GDB has no way to know how large the target array is. Maybe
> > things will change in future.  Would you please try this patch against the
> > latest GDB cvs tree?  Thanks.
> > 
> > Index: f-exp.y
> > ===================================================================
> > RCS file: /cvs/src/src/gdb/f-exp.y,v
> > retrieving revision 1.16
> > diff -c -p -r1.16 f-exp.y
> > *** f-exp.y	12 Dec 2004 21:48:55 -0000	1.16
> > --- f-exp.y	27 Jun 2005 09:18:05 -0000
> > ***************
> > *** 1,6 ****
> >  /* YACC parser for Fortran expressions, for GDB.
> > !    Copyright 1986, 1989, 1990, 1991, 1993, 1994, 1995, 1996, 2000, 2001
> > !    Free Software Foundation, Inc.
> >      Contributed by Motorola.  Adapted from the C parser by Farooq Butt
> >     (fmbutt@engage.sps.mot.com).
> > --- 1,6 ----
> >  /* YACC parser for Fortran expressions, for GDB.
> > !    Copyright 1986, 1989, 1990, 1991, 1993, 1994, 1995, 1996, 2000, 2001,
> > !    2002, 2003, 2004, 2005 Free Software Foundation, Inc.
> >      Contributed by Motorola.  Adapted from the C parser by Farooq Butt
> >     (fmbutt@engage.sps.mot.com).
> > *************** static int parse_number (char *, int, in
> > *** 217,222 ****
> > --- 217,223 ----
> >  %left '@'
> >  %left '+' '-'
> >  %left '*' '/' '%'
> > + %right STARSTAR
> >  %right UNARY  %right '('
> >  *************** arglist	:	exp
> > *** 282,299 ****
> >  			{ arglist_len = 1; }
> >  	;
> >  ! arglist :      substring
> > !                         { arglist_len = 2;}
> > ! 	;
> > !    ! arglist	:	arglist ',' exp   %prec ABOVE_COMMA
> > ! 			{ arglist_len++; }
> >  	;
> >  ! substring:	exp ':' exp   %prec ABOVE_COMMA
> > ! 			{ }  	;
> >    complexnum:     exp ',' exp                  	{ }
> > --- 283,304 ----
> >  			{ arglist_len = 1; }
> >  	;
> >  ! arglist	:	subrange
> > ! 			{ arglist_len = 2; }
> >  	;
> >  ! subrange:	exp ':' exp   %prec ABOVE_COMMA
> > ! 		/*	{ write_exp_elt_opcode (BINOP_RANGE); }*/
> > ! 			{ }
> >  	;
> >  + /*subrange:	subrange ',' exp ':' exp   %prec ABOVE_COMMA
> > + 			{ }
> > + 	;
> > + */
> > + arglist	:	arglist ',' exp   %prec ABOVE_COMMA
> > + 			{ arglist_len++; }
> > + 	;
> >   complexnum:     exp ',' exp                  	{ }
> > *************** exp	:	exp '@' exp
> > *** 315,320 ****
> > --- 320,329 ----
> >  			{ write_exp_elt_opcode (BINOP_REPEAT); }
> >  	;
> >  + exp	:	exp STARSTAR exp
> > + 			{ write_exp_elt_opcode (BINOP_EXP); }
> > + 	;
> > +  exp	:	exp '*' exp
> >  			{ write_exp_elt_opcode (BINOP_MUL); }
> >  	;
> > *************** yylex ()
> > *** 941,947 ****
> >  	}
> >      }
> >    !   /* See if it is a special .foo. operator */
> >       for (i = 0; dot_ops[i].operator != NULL; i++)
> >      if (strncmp (tokstart, dot_ops[i].operator, strlen
> > (dot_ops[i].operator)) == 0)
> > --- 950,956 ----
> >  	}
> >      }
> >    !   /* See if it is a special .foo. operator.  */
> >       for (i = 0; dot_ops[i].operator != NULL; i++)
> >      if (strncmp (tokstart, dot_ops[i].operator, strlen
> > (dot_ops[i].operator)) == 0)
> > *************** yylex ()
> > *** 951,956 ****
> > --- 960,974 ----
> >  	return dot_ops[i].token;
> >        }
> >    +   /* See if it is an exponentiation operator.  */
> > + +   if (strncmp (tokstart, "**", 2) == 0)
> > +     {
> > +       lexptr += 2;
> > +       yylval.opcode = BINOP_EXP;
> > +       return STARSTAR;
> > +     }
> > +    switch (c = *tokstart)
> >      {
> >      case 0:
> > Index: eval.c
> > ===================================================================
> > RCS file: /cvs/src/src/gdb/eval.c,v
> > retrieving revision 1.56
> > diff -c -p -r1.56 eval.c
> > *** eval.c	13 Jun 2005 07:23:15 -0000	1.56
> > --- eval.c	27 Jun 2005 09:18:06 -0000
> > *************** evaluate_subexp_standard (struct type *e
> > *** 1510,1515 ****
> > --- 1510,1516 ----
> >        else
> >  	return value_sub (arg1, arg2);
> >  +     case BINOP_EXP:
> >      case BINOP_MUL:
> >      case BINOP_DIV:
> >      case BINOP_REM:
> > *************** evaluate_subexp_standard (struct type *e
> > *** 1641,1646 ****
> > --- 1642,1654 ----
> >  	tmp_type = check_typedef (value_type (arg1));
> >  	ndimensions = calc_f77_array_dims (type);
> >  + 	/* From 3.2.3 on (maybe early), g77 will treat string variable as an
> > + 	   array.  So the type code of a substring wil be TYPE_CODE_ARRAY +
> > instead.  This conditional statement is added to determine if it + 	   is
> > a substring or sub-array indeed.  */
> > + 	if (nargs == 2 * ndimensions)
> > + 	  goto op_f77_substr;
> > +  	if (nargs != ndimensions)
> >  	  error (_("Wrong number of subscripts"));
> >  
> > On Mon, 27 Jun 2005, Fred Krogh wrote:
> > 
> >  
> > > The following reply was made to PR fortran/1880; it has been noted by
> > > GNATS.
> > > 
> > > From: Fred Krogh <fkrogh@mathalacarte.com>
> > > To: woodzltc@sources.redhat.com, gdb-prs@sources.redhat.com,
> > > 	nobody@sources.redhat.com, woodzltc@sources.redhat.com,
> > > 	gdb-gnats@sources.redhat.com
> > > Cc:  Subject: Re: fortran/1880: display of part of an array
> > > Date: Sun, 26 Jun 2005 21:27:21 -0700
> > > 
> > > woodzltc@sources.redhat.com wrote:
> > > 
> > > >Synopsis: display of part of an array
> > > >
> > > >Responsible-Changed-From-To: unassigned->woodzltc
> > > >Responsible-Changed-By: woodzltc
> > > >Responsible-Changed-When: Mon Jun 27 03:12:31 2005
> > > >Responsible-Changed-Why:
> > > >    I'd like to take up this if some more information could be provided.
> > > Thanks.
> > > >State-Changed-From-To: open->feedback
> > > >State-Changed-By: woodzltc
> > > >State-Changed-When: Mon Jun 27 03:12:31 2005
> > > >State-Changed-Why:
> > > >    I don't have much experiecne in ddd.  If you could give me the
> > > problem description in gdb, I am very willing to take some looks into
> > > this. >    >    Another suggestion is: you can try using the latest GDB
> > > cvs to see whether your problem could be reproduced. >    >    Cheers
> > > >    - Wu Zhou
> > > >
> > > >http://sources.redhat.com/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gdb&pr=1880
> > > >
> > > >  >
> > >    
> 
> 
> 


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