fortran/1880: display of part of an array (fwd)

Wu Zhou woodzltc@cn.ibm.com
Tue Jun 28 03:18:00 GMT 2005


The following reply was made to PR fortran/1880; it has been noted by GNATS.

From: Wu Zhou <woodzltc@cn.ibm.com>
To: gdb-gnats@sources.redhat.com
Cc:  
Subject: Re: fortran/1880: display of part of an array (fwd)
Date: Tue, 28 Jun 2005 01:44:23 +0800 (CST)

 To let PR system record related correspondence.  Thanks.
 
 ---------- Forwarded message ----------
 Date: Mon, 27 Jun 2005 16:57:28 +0800 (CST)
 From: Wu Zhou <woodzltc@cn.ibm.com>
 To: Fred Krogh <fkrogh@mathalacarte.com>
 Cc: gdb-prs@sources.redhat.com
 Subject: Re: fortran/1880: display of part of an array
 
 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
 >  >
 >  >  
 >  >
 >  Hi --
 >      I'm certainly happy to see someone with an interest in this.  First 
 >  of all ddd is working sort of.  If I move the mouse pointer too much in 
 >  the source window it crashes and this is easy to make happen.   But if I 
 >  don't move the mouse too much I can still get useful work done.
 >  
 >  The gdb problem is that I simply don't seem to have any way to print 
 >  dummy arrays in Fortran.  Thus if an array X() is passed into a 
 >  subroutine and I want to print locations X(3:7) there seems no way to do 
 >  this without going up a level and doing
 >  
 >  p x(3)@5
 >  
 >  Things are even worse for printing an arbitrary region of a two 
 >  dimensional array.
 >  I'm frequently in a position where I want to display small parts of very 
 >  large arrays.  If I could do this in gdb, I think there is a reasonable 
 >  chance I could figure out how to accomplish the same thing in ddd.
 >  
 >  Let me know if you would like more input from me.
 >  
 >  Many thanks,
 >      Fred
 > 
 > 



More information about the Gdb-prs mailing list