Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Andy Vaught <andy@maxwell.la.asu.edu>
To: gdb-patches@cygnus.com
Subject: Fortran array patch
Date: Mon, 04 Jan 1999 17:09:00 -0000	[thread overview]
Message-ID: <Pine.SGI.3.96.990104174412.27104A-100000@maxwell.la.asu.edu> (raw)

There is a bad bug in the code that prints array elements of a fortran
program-- the upper and lower array bounds are extracted in the opposite
order from that of the subscripts, meaning that a bad address is
calculated.  The patch is against the stable gdb-4.17 release. 


--- eval.c.orig	Mon Jan  4 16:48:13 1999
+++ eval.c	Mon Jan  4 17:41:31 1999
@@ -1188,6 +1188,7 @@
 	int subscript_array[MAX_FORTRAN_DIMS+1]; /* 1-based array of 
 						    subscripts, max == 7 */
 	int array_size_array[MAX_FORTRAN_DIMS+1];
+	int upper_bound[MAX_FORTRAN_DIMS+1], lower_bound[MAX_FORTRAN_DIMS+1];
 	int ndimensions=1,i;
 	struct type *tmp_type; 
 	int offset_item;   /* The array offset where the item lives */ 
@@ -1222,11 +1223,10 @@
 	    if (retcode == BOUND_FETCH_ERROR)
 	      error("Cannot obtain dynamic lower bound"); 
 
-	    array_size_array[i] = upper - lower + 1;
-               
-	    /* Zero-normalize subscripts so that offsetting will work. */ 
-               
-	    subscript_array[i] -= lower;
+	    /* Bounds are fetched in reverse order of the subscripts */
+
+	    upper_bound[nargs + 1 - i] = upper;
+	    lower_bound[nargs + 1 - i] = lower;
 
 	    /* If we are at the bottom of a multidimensional 
 	       array type then keep a ptr to the last ARRAY
@@ -1238,6 +1238,17 @@
 
 	    if (i < nargs) 
 	      tmp_type = check_typedef (TYPE_TARGET_TYPE (tmp_type)); 
+	  }
+
+	/* Calculate size of each dimension */
+
+	for (i = 1; i <= nargs; i++)
+	  {
+	    array_size_array[i] = upper_bound[i] - lower_bound[i] + 1;
+               
+	    /* Zero-normalize subscripts so that offsetting will work. */ 
+               
+	    subscript_array[i] -= lower_bound[i];
 	  }
 
 	/* Now let us calculate the offset for this item */



       Andy


-----------------                        XOLD(K,IC,I)=
Andy Vaught               ....        DO ITERS=1, 10  XOLD(K,IC,I)
andy@maxwell.la.asu.edu   |  |   /CALLMSOLVE(A,B,X,I,ITERS,TOL)+(RANNYU(0)
Arizona State University  ======|WRITE(6,'(I5,2X,F12.6)')ITERS,TOL -HALF)
Tempe, Arizona USA        OOOOOO \ENDDORETURN PARAMETER(ZERO=1.D0)*TENTH*DELTA




WARNING: multiple messages have this Message-ID
From: Andy Vaught <andy@maxwell.la.asu.edu>
To: gdb-patches@cygnus.com
Subject: Fortran array patch
Date: Thu, 01 Apr 1999 00:00:00 -0000	[thread overview]
Message-ID: <Pine.SGI.3.96.990104174412.27104A-100000@maxwell.la.asu.edu> (raw)
Message-ID: <19990401000000.UtO_3DISh8omMrbOpEuY0zCn5NMqOr9T9C3q9ORRJ7s@z> (raw)

There is a bad bug in the code that prints array elements of a fortran
program-- the upper and lower array bounds are extracted in the opposite
order from that of the subscripts, meaning that a bad address is
calculated.  The patch is against the stable gdb-4.17 release. 


--- eval.c.orig	Mon Jan  4 16:48:13 1999
+++ eval.c	Mon Jan  4 17:41:31 1999
@@ -1188,6 +1188,7 @@
 	int subscript_array[MAX_FORTRAN_DIMS+1]; /* 1-based array of 
 						    subscripts, max == 7 */
 	int array_size_array[MAX_FORTRAN_DIMS+1];
+	int upper_bound[MAX_FORTRAN_DIMS+1], lower_bound[MAX_FORTRAN_DIMS+1];
 	int ndimensions=1,i;
 	struct type *tmp_type; 
 	int offset_item;   /* The array offset where the item lives */ 
@@ -1222,11 +1223,10 @@
 	    if (retcode == BOUND_FETCH_ERROR)
 	      error("Cannot obtain dynamic lower bound"); 
 
-	    array_size_array[i] = upper - lower + 1;
-               
-	    /* Zero-normalize subscripts so that offsetting will work. */ 
-               
-	    subscript_array[i] -= lower;
+	    /* Bounds are fetched in reverse order of the subscripts */
+
+	    upper_bound[nargs + 1 - i] = upper;
+	    lower_bound[nargs + 1 - i] = lower;
 
 	    /* If we are at the bottom of a multidimensional 
 	       array type then keep a ptr to the last ARRAY
@@ -1238,6 +1238,17 @@
 
 	    if (i < nargs) 
 	      tmp_type = check_typedef (TYPE_TARGET_TYPE (tmp_type)); 
+	  }
+
+	/* Calculate size of each dimension */
+
+	for (i = 1; i <= nargs; i++)
+	  {
+	    array_size_array[i] = upper_bound[i] - lower_bound[i] + 1;
+               
+	    /* Zero-normalize subscripts so that offsetting will work. */ 
+               
+	    subscript_array[i] -= lower_bound[i];
 	  }
 
 	/* Now let us calculate the offset for this item */



       Andy


-----------------                        XOLD(K,IC,I)=
Andy Vaught               ....        DO ITERS=1, 10  XOLD(K,IC,I)
andy@maxwell.la.asu.edu   |  |   /CALLMSOLVE(A,B,X,I,ITERS,TOL)+(RANNYU(0)
Arizona State University  ======|WRITE(6,'(I5,2X,F12.6)')ITERS,TOL -HALF)
Tempe, Arizona USA        OOOOOO \ENDDORETURN PARAMETER(ZERO=1.D0)*TENTH*DELTA




             reply	other threads:[~1999-01-04 17:09 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1999-01-04 17:09 Andy Vaught [this message]
1999-04-01  0:00 ` Andy Vaught

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Pine.SGI.3.96.990104174412.27104A-100000@maxwell.la.asu.edu \
    --to=andy@maxwell.la.asu.edu \
    --cc=gdb-patches@cygnus.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox