summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gdb/ChangeLog23
-rw-r--r--gdb/ada-lang.c1
-rw-r--r--gdb/c-lang.c4
-rw-r--r--gdb/dwarf2read.c53
-rw-r--r--gdb/eval.c24
-rw-r--r--gdb/f-lang.c1
-rw-r--r--gdb/jv-lang.c1
-rw-r--r--gdb/language.c3
-rw-r--r--gdb/language.h14
-rw-r--r--gdb/m2-lang.c1
-rw-r--r--gdb/objc-lang.c1
-rw-r--r--gdb/p-lang.c1
-rw-r--r--gdb/scm-lang.c1
13 files changed, 116 insertions, 12 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index e5fa2245fe1..c141526e603 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,26 @@
+2004-08-29 David Lecomber <david@streamline-computing.com>
+
+ Fix PR gdb/648
+ * language.h (enum array_ordering): New enum.
+ * language.h (struct language_defn): New la_array_ordering
+ attribute.
+ * language.c (unknown_language_defn, auto_language_defn)
+ (local_language_defn): Ditto.
+ * ada-lang.c (ada_language_defn): Ditto.
+ * c-lang.c (c_language_defn, cplus_language_defn)
+ (asm_language_defn, minimal_language_defn): Ditto.
+ * f-lang.c (f_language_defn): Ditto.
+ * jv-lang.c (java_language_defn): Ditto.
+ * m2-lang.c (f_language_defn): Ditto.
+ * objc-lang.c (objc_language_defn): Ditto.
+ * p-lang.c (pascal_language_defn): Ditto.
+ * scm-lang.c (scm_language_defn): Ditto.
+ * eval.c (evaluate_subexp_standard): Assume Fortran arrays are
+ oriented large to small in type structure.
+ * dwarf2read.c (read_array_order): New function.
+ (read_array_type): Use read_array_order to check row/column
+ major ordering.
+
2004-08-27 Nathan J. Williams <nathanw@wasabisystems.com>
* target.c (target_resize_to_sections): Check
diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c
index 1bb3ca09ea2..fd73fc58dae 100644
--- a/gdb/ada-lang.c
+++ b/gdb/ada-lang.c
@@ -10166,6 +10166,7 @@ const struct language_defn ada_language_defn = {
ada_lookup_symbol,
ada_lookup_minimal_symbol,
#endif /* GNAT_GDB */
+ array_row_major,
&ada_exp_descriptor,
parse,
ada_error,
diff --git a/gdb/c-lang.c b/gdb/c-lang.c
index 5ab15b8edf2..ad8fa5c8ebd 100644
--- a/gdb/c-lang.c
+++ b/gdb/c-lang.c
@@ -570,6 +570,7 @@ const struct language_defn c_language_defn =
range_check_off,
type_check_off,
case_sensitive_on,
+ array_row_major,
&exp_descriptor_standard,
c_preprocess_and_parse,
c_error,
@@ -631,6 +632,7 @@ const struct language_defn cplus_language_defn =
range_check_off,
type_check_off,
case_sensitive_on,
+ array_row_major,
&exp_descriptor_standard,
c_preprocess_and_parse,
c_error,
@@ -669,6 +671,7 @@ const struct language_defn asm_language_defn =
range_check_off,
type_check_off,
case_sensitive_on,
+ array_row_major,
&exp_descriptor_standard,
c_preprocess_and_parse,
c_error,
@@ -712,6 +715,7 @@ const struct language_defn minimal_language_defn =
range_check_off,
type_check_off,
case_sensitive_on,
+ array_row_major,
&exp_descriptor_standard,
c_preprocess_and_parse,
c_error,
diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c
index fa11475a691..4e9cdfa89f3 100644
--- a/gdb/dwarf2read.c
+++ b/gdb/dwarf2read.c
@@ -848,6 +848,9 @@ static CORE_ADDR decode_locdesc (struct dwarf_block *, struct dwarf2_cu *);
static void read_array_type (struct die_info *, struct dwarf2_cu *);
+static enum dwarf_array_dim_ordering read_array_order (struct die_info *,
+ struct dwarf2_cu *);
+
static void read_tag_pointer_type (struct die_info *, struct dwarf2_cu *);
static void read_tag_ptr_to_member_type (struct die_info *,
@@ -3724,9 +3727,20 @@ read_array_type (struct die_info *die, struct dwarf2_cu *cu)
/* Dwarf2 dimensions are output from left to right, create the
necessary array types in backwards order. */
+
type = element_type;
- while (ndim-- > 0)
- type = create_array_type (NULL, type, range_types[ndim]);
+
+ if (read_array_order (die, cu) == DW_ORD_col_major)
+ {
+ int i = 0;
+ while (i < ndim)
+ type = create_array_type (NULL, type, range_types[i++]);
+ }
+ else
+ {
+ while (ndim-- > 0)
+ type = create_array_type (NULL, type, range_types[ndim]);
+ }
/* Understand Dwarf2 support for vector types (like they occur on
the PowerPC w/ AltiVec). Gcc just adds another attribute to the
@@ -3744,6 +3758,41 @@ read_array_type (struct die_info *die, struct dwarf2_cu *cu)
die->type = type;
}
+static enum dwarf_array_dim_ordering
+read_array_order (struct die_info *die, struct dwarf2_cu *cu)
+{
+ struct attribute *attr;
+
+ attr = dwarf2_attr (die, DW_AT_ordering, cu);
+
+ if (attr) return DW_SND (attr);
+
+ /*
+ GNU F77 is a special case, as at 08/2004 array type info is the
+ opposite order to the dwarf2 specification, but data is still
+ laid out as per normal fortran.
+
+ FIXME: dsl/2004-8-20: If G77 is ever fixed, this will also need
+ version checking.
+ */
+
+ if (cu->language == language_fortran &&
+ cu->producer && strstr (cu->producer, "GNU F77"))
+ {
+ return DW_ORD_row_major;
+ }
+
+ switch (cu->language_defn->la_array_ordering)
+ {
+ case array_column_major:
+ return DW_ORD_col_major;
+ case array_row_major:
+ default:
+ return DW_ORD_row_major;
+ };
+}
+
+
/* First cut: install each common block member as a global variable. */
static void
diff --git a/gdb/eval.c b/gdb/eval.c
index b690a78da09..4418e0ad29b 100644
--- a/gdb/eval.c
+++ b/gdb/eval.c
@@ -1610,9 +1610,8 @@ evaluate_subexp_standard (struct type *expect_type,
multi_f77_subscript:
{
- int subscript_array[MAX_FORTRAN_DIMS + 1]; /* 1-based array of
- subscripts, max == 7 */
- int array_size_array[MAX_FORTRAN_DIMS + 1];
+ int subscript_array[MAX_FORTRAN_DIMS];
+ int array_size_array[MAX_FORTRAN_DIMS];
int ndimensions = 1, i;
struct type *tmp_type;
int offset_item; /* The array offset where the item lives */
@@ -1630,7 +1629,8 @@ evaluate_subexp_standard (struct type *expect_type,
let us actually find out where this element exists in the array. */
offset_item = 0;
- for (i = 1; i <= nargs; i++)
+ /* Take array indices left to right */
+ for (i = 0; i < nargs; i++)
{
/* Evaluate each subscript, It must be a legal integer in F77 */
arg2 = evaluate_subexp_with_coercion (exp, pos, noside);
@@ -1638,7 +1638,11 @@ evaluate_subexp_standard (struct type *expect_type,
/* Fill in the subscript and array size arrays */
subscript_array[i] = value_as_long (arg2);
+ }
+ /* Internal type of array is arranged right to left */
+ for (i = 0; i < nargs; i++)
+ {
retcode = f77_get_dynamic_upperbound (tmp_type, &upper);
if (retcode == BOUND_FETCH_ERROR)
error ("Cannot obtain dynamic upper bound");
@@ -1647,11 +1651,11 @@ evaluate_subexp_standard (struct type *expect_type,
if (retcode == BOUND_FETCH_ERROR)
error ("Cannot obtain dynamic lower bound");
- array_size_array[i] = upper - lower + 1;
+ array_size_array[nargs - i - 1] = upper - lower + 1;
/* Zero-normalize subscripts so that offsetting will work. */
- subscript_array[i] -= lower;
+ subscript_array[nargs - i - 1] -= lower;
/* If we are at the bottom of a multidimensional
array type then keep a ptr to the last ARRAY
@@ -1661,17 +1665,17 @@ evaluate_subexp_standard (struct type *expect_type,
of base element type that we apply a simple
offset to. */
- if (i < nargs)
+ if (i < nargs - 1)
tmp_type = check_typedef (TYPE_TARGET_TYPE (tmp_type));
}
/* Now let us calculate the offset for this item */
- offset_item = subscript_array[ndimensions];
+ offset_item = subscript_array[ndimensions - 1];
- for (i = ndimensions - 1; i >= 1; i--)
+ for (i = ndimensions - 1; i > 0; --i)
offset_item =
- array_size_array[i] * offset_item + subscript_array[i];
+ array_size_array[i - 1] * offset_item + subscript_array[i - 1];
/* Construct a value node with the value of the offset */
diff --git a/gdb/f-lang.c b/gdb/f-lang.c
index e354cad00e5..8430c97bdae 100644
--- a/gdb/f-lang.c
+++ b/gdb/f-lang.c
@@ -462,6 +462,7 @@ const struct language_defn f_language_defn =
range_check_on,
type_check_on,
case_sensitive_off,
+ array_column_major,
&exp_descriptor_standard,
f_parse, /* parser */
f_error, /* parser error function */
diff --git a/gdb/jv-lang.c b/gdb/jv-lang.c
index 30a75c077ad..fd0e712415c 100644
--- a/gdb/jv-lang.c
+++ b/gdb/jv-lang.c
@@ -1088,6 +1088,7 @@ const struct language_defn java_language_defn =
range_check_off,
type_check_off,
case_sensitive_on,
+ array_row_major,
&exp_descriptor_java,
java_parse,
java_error,
diff --git a/gdb/language.c b/gdb/language.c
index d1a1fb9aa6a..dfbfa3a6d26 100644
--- a/gdb/language.c
+++ b/gdb/language.c
@@ -1294,6 +1294,7 @@ const struct language_defn unknown_language_defn =
NULL,
range_check_off,
type_check_off,
+ array_row_major,
case_sensitive_on,
&exp_descriptor_standard,
unk_lang_parser,
@@ -1333,6 +1334,7 @@ const struct language_defn auto_language_defn =
NULL,
range_check_off,
type_check_off,
+ array_row_major,
case_sensitive_on,
&exp_descriptor_standard,
unk_lang_parser,
@@ -1372,6 +1374,7 @@ const struct language_defn local_language_defn =
range_check_off,
type_check_off,
case_sensitive_on,
+ array_row_major,
&exp_descriptor_standard,
unk_lang_parser,
unk_lang_error,
diff --git a/gdb/language.h b/gdb/language.h
index 489ca238634..98bdc3e1db9 100644
--- a/gdb/language.h
+++ b/gdb/language.h
@@ -96,6 +96,17 @@ extern enum case_mode
}
case_mode;
+/* array_ordering ==
+ array_row_major: Arrays are in row major order
+ array_column_major: Arrays are in column major order.*/
+
+extern enum array_ordering
+ {
+ array_row_major, array_column_major
+ }
+array_ordering;
+
+
/* case_sensitivity ==
case_sensitive_on: Case sensitivity in name matching is used
case_sensitive_off: Case sensitivity in name matching is not used */
@@ -187,6 +198,9 @@ struct language_defn
/* Default case sensitivity */
enum case_sensitivity la_case_sensitivity;
+ /* Multi-dimensional array ordering */
+ enum array_ordering la_array_ordering;
+
/* Definitions related to expression printing, prefixifying, and
dumping */
diff --git a/gdb/m2-lang.c b/gdb/m2-lang.c
index 722805e2faf..746b2f4785e 100644
--- a/gdb/m2-lang.c
+++ b/gdb/m2-lang.c
@@ -415,6 +415,7 @@ const struct language_defn m2_language_defn =
range_check_on,
type_check_on,
case_sensitive_on,
+ array_row_major,
&exp_descriptor_standard,
m2_parse, /* parser */
m2_error, /* parser error function */
diff --git a/gdb/objc-lang.c b/gdb/objc-lang.c
index b9e48971533..b02af1c2361 100644
--- a/gdb/objc-lang.c
+++ b/gdb/objc-lang.c
@@ -659,6 +659,7 @@ const struct language_defn objc_language_defn = {
range_check_off,
type_check_off,
case_sensitive_on,
+ array_row_major,
&exp_descriptor_standard,
objc_parse,
objc_error,
diff --git a/gdb/p-lang.c b/gdb/p-lang.c
index 115bfe106fa..296a0ba51b9 100644
--- a/gdb/p-lang.c
+++ b/gdb/p-lang.c
@@ -451,6 +451,7 @@ const struct language_defn pascal_language_defn =
range_check_on,
type_check_on,
case_sensitive_on,
+ array_row_major,
&exp_descriptor_standard,
pascal_parse,
pascal_error,
diff --git a/gdb/scm-lang.c b/gdb/scm-lang.c
index 4b1db1547ef..c459b813d99 100644
--- a/gdb/scm-lang.c
+++ b/gdb/scm-lang.c
@@ -248,6 +248,7 @@ const struct language_defn scm_language_defn =
range_check_off,
type_check_off,
case_sensitive_off,
+ array_row_major,
&exp_descriptor_scm,
scm_parse,
c_error,