aboutsummaryrefslogtreecommitdiff
path: root/gdb/eval.c
diff options
context:
space:
mode:
authorDavid Lecomber <david@lecomber.net>2003-09-09 16:51:54 +0000
committerDavid Lecomber <david@lecomber.net>2003-09-09 16:51:54 +0000
commitcd859a2010670cdeaf184903224ae2fac65afd6a (patch)
tree6fa7c150b0bf40548ae92e1179b9cc591caf79f3 /gdb/eval.c
parente8a7b686ffab6f15e4d30df4abbb1ed7096122b9 (diff)
downloadfsf-binutils-gdb-cd859a2010670cdeaf184903224ae2fac65afd6a.zip
fsf-binutils-gdb-cd859a2010670cdeaf184903224ae2fac65afd6a.tar.gz
fsf-binutils-gdb-cd859a2010670cdeaf184903224ae2fac65afd6a.tar.bz2
Change array element access to something similar to way C works.
The old method would drag in the entire array, then look for the single element. This method just gets the right element out instead. Saves memory, and saves a crash for array with (*) as one of the dimensions when it would previously have allocated (unsigned int) -1 bytes.
Diffstat (limited to 'gdb/eval.c')
-rw-r--r--gdb/eval.c14
1 files changed, 9 insertions, 5 deletions
diff --git a/gdb/eval.c b/gdb/eval.c
index 914a552..7b18723 100644
--- a/gdb/eval.c
+++ b/gdb/eval.c
@@ -1666,10 +1666,6 @@ evaluate_subexp_standard (struct type *expect_type,
offset_item =
array_size_array[i] * offset_item + subscript_array[i];
- /* Construct a value node with the value of the offset */
-
- arg2 = value_from_longest (builtin_type_f_integer, offset_item);
-
/* Let us now play a dirty trick: we will take arg1
which is a value node pointing to the topmost level
of the multidimensional array-set and pretend
@@ -1678,7 +1674,15 @@ evaluate_subexp_standard (struct type *expect_type,
returns the correct type value */
VALUE_TYPE (arg1) = tmp_type;
- return value_ind (value_add (value_coerce_array (arg1), arg2));
+
+ f77_get_dynamic_lowerbound (tmp_type, &lower);
+
+ /* Construct a value node with the value of the offset */
+ /* lower will get subtracted off in value_subscript, hence add it here */
+
+ arg2 = value_from_longest (builtin_type_f_integer, offset_item + lower);
+
+ return value_subscript(arg1, arg2);
}
case BINOP_LOGICAL_AND: