public inbox for gdb@sourceware.org
 help / color / mirror / Atom feed
* Re: fortran/1880: display of part of an array
       [not found]   ` <42C00F60.10401@mathalacarte.com>
@ 2005-06-28  4:03     ` Wu Zhou
       [not found]       ` <42C16389.90705@mathalacarte.com>
  0 siblings, 1 reply; 2+ messages in thread
From: Wu Zhou @ 2005-06-28  4:03 UTC (permalink / raw)
  To: Fred Krogh; +Cc: gdb

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
> > > >
> > > >  >
> > >    
> 
> 
> 

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: fortran/1880: display of part of an array
       [not found]       ` <42C16389.90705@mathalacarte.com>
@ 2005-06-29  2:26         ` Wu Zhou
  0 siblings, 0 replies; 2+ messages in thread
From: Wu Zhou @ 2005-06-29  2:26 UTC (permalink / raw)
  To: Fred Krogh; +Cc: gdb, gdb-gnats

On Tue, 28 Jun 2005, Fred Krogh wrote:

> I guess I have a different view.  I don't see the printing of a subarray as a
> language extension.  It seems to me just to be a way to view data that is
> sitting in memory.  That's what a debugger does, no?  It should give a
> convenient way of seeing what is going on in a running program.

OK. I buy your view.  

> So I am now at the point where I have the new gdb loaded into ddd.  What do I
> do to use the patch?  Is there a new command?  It is still unclear to me what
> this patch does that I couldn't do before.

With this patch, you can at least print a sub-array in your MAIN__ 
section.

> 
> Thanks,
>    Fred

Cheers
- Wu Zhou

P.S: Would you please include gdb@sources.redhat.com also in the cc list.  
There might be some others who are also interested in this thread.  If 
somebody add some weight to your view, there will be more chance that your
request fulfilled. :-) 

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2005-06-29  2:26 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <20050627043800.2118.qmail@sourceware.org>
     [not found] ` <Pine.LNX.4.63.0506271650330.30098@wks190384wss.cn.ibm.com>
     [not found]   ` <42C00F60.10401@mathalacarte.com>
2005-06-28  4:03     ` fortran/1880: display of part of an array Wu Zhou
     [not found]       ` <42C16389.90705@mathalacarte.com>
2005-06-29  2:26         ` Wu Zhou

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).