* Fortran array patch
@ 1999-01-04 17:09 Andy Vaught
1999-04-01 0:00 ` Andy Vaught
0 siblings, 1 reply; 2+ messages in thread
From: Andy Vaught @ 1999-01-04 17:09 UTC (permalink / raw)
To: gdb-patches
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
^ permalink raw reply [flat|nested] 2+ messages in thread
* Fortran array patch
1999-01-04 17:09 Fortran array patch Andy Vaught
@ 1999-04-01 0:00 ` Andy Vaught
0 siblings, 0 replies; 2+ messages in thread
From: Andy Vaught @ 1999-04-01 0:00 UTC (permalink / raw)
To: gdb-patches
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
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~1999-04-01 0:00 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1999-01-04 17:09 Fortran array patch Andy Vaught
1999-04-01 0:00 ` Andy Vaught
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox