Index: gdb/ada-lang.c =================================================================== RCS file: /cvs/src/src/gdb/ada-lang.c,v retrieving revision 1.50 diff -c -p -r1.50 ada-lang.c *** gdb/ada-lang.c 10 Aug 2004 21:16:12 -0000 1.50 --- gdb/ada-lang.c 20 Aug 2004 13:23:41 -0000 *************** const struct language_defn ada_language_ *** 10166,10171 **** --- 10166,10172 ---- ada_lookup_symbol, ada_lookup_minimal_symbol, #endif /* GNAT_GDB */ + array_row_major, &ada_exp_descriptor, parse, ada_error, Index: gdb/c-lang.c =================================================================== RCS file: /cvs/src/src/gdb/c-lang.c,v retrieving revision 1.31 diff -c -p -r1.31 c-lang.c *** gdb/c-lang.c 28 Jul 2004 15:18:06 -0000 1.31 --- gdb/c-lang.c 20 Aug 2004 13:23:43 -0000 *************** const struct language_defn c_language_de *** 570,575 **** --- 570,576 ---- range_check_off, type_check_off, case_sensitive_on, + array_row_major, &exp_descriptor_standard, c_preprocess_and_parse, c_error, *************** const struct language_defn cplus_languag *** 631,636 **** --- 632,638 ---- range_check_off, type_check_off, case_sensitive_on, + array_row_major, &exp_descriptor_standard, c_preprocess_and_parse, c_error, *************** const struct language_defn asm_language_ *** 669,674 **** --- 671,677 ---- range_check_off, type_check_off, case_sensitive_on, + array_row_major, &exp_descriptor_standard, c_preprocess_and_parse, c_error, *************** const struct language_defn minimal_langu *** 712,717 **** --- 715,721 ---- range_check_off, type_check_off, case_sensitive_on, + array_row_major, &exp_descriptor_standard, c_preprocess_and_parse, c_error, Index: gdb/dwarf2read.c =================================================================== RCS file: /cvs/src/src/gdb/dwarf2read.c,v retrieving revision 1.158 diff -c -p -r1.158 dwarf2read.c *** gdb/dwarf2read.c 2 Aug 2004 01:25:57 -0000 1.158 --- gdb/dwarf2read.c 20 Aug 2004 13:24:01 -0000 *************** static CORE_ADDR decode_locdesc (struct *** 848,853 **** --- 848,856 ---- 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 *, *************** read_array_type (struct die_info *die, s *** 3724,3732 **** /* 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]); /* Understand Dwarf2 support for vector types (like they occur on the PowerPC w/ AltiVec). Gcc just adds another attribute to the --- 3727,3746 ---- /* Dwarf2 dimensions are output from left to right, create the necessary array types in backwards order. */ + type = element_type; ! ! 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 *************** read_array_type (struct die_info *die, s *** 3744,3749 **** --- 3758,3797 ---- 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 arrays are the opposite + way to the dwarf2 specification. + + 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 Index: gdb/eval.c =================================================================== RCS file: /cvs/src/src/gdb/eval.c,v retrieving revision 1.41 diff -c -p -r1.41 eval.c *** gdb/eval.c 8 Apr 2004 21:18:12 -0000 1.41 --- gdb/eval.c 20 Aug 2004 13:24:05 -0000 *************** evaluate_subexp_standard (struct type *e *** 1610,1618 **** 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 ndimensions = 1, i; struct type *tmp_type; int offset_item; /* The array offset where the item lives */ --- 1610,1617 ---- multi_f77_subscript: { ! 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 */ *************** evaluate_subexp_standard (struct type *e *** 1630,1636 **** let us actually find out where this element exists in the array. */ offset_item = 0; ! for (i = 1; i <= nargs; i++) { /* Evaluate each subscript, It must be a legal integer in F77 */ arg2 = evaluate_subexp_with_coercion (exp, pos, noside); --- 1629,1636 ---- let us actually find out where this element exists in the array. */ offset_item = 0; ! /* 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); *************** evaluate_subexp_standard (struct type *e *** 1638,1644 **** --- 1638,1648 ---- /* 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"); *************** evaluate_subexp_standard (struct type *e *** 1647,1657 **** 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; /* If we are at the bottom of a multidimensional array type then keep a ptr to the last ARRAY --- 1651,1661 ---- if (retcode == BOUND_FETCH_ERROR) error ("Cannot obtain dynamic lower bound"); ! array_size_array[nargs - i - 1] = upper - lower + 1; /* Zero-normalize subscripts so that offsetting will work. */ ! 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 *************** evaluate_subexp_standard (struct type *e *** 1661,1677 **** of base element type that we apply a simple offset to. */ ! if (i < nargs) tmp_type = check_typedef (TYPE_TARGET_TYPE (tmp_type)); } /* Now let us calculate the offset for this item */ ! offset_item = subscript_array[ndimensions]; ! for (i = ndimensions - 1; i >= 1; i--) offset_item = ! array_size_array[i] * offset_item + subscript_array[i]; /* Construct a value node with the value of the offset */ --- 1665,1681 ---- of base element type that we apply a simple offset to. */ ! 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 - 1]; ! for (i = ndimensions - 1; i > 0; --i) offset_item = ! array_size_array[i - 1] * offset_item + subscript_array[i - 1]; /* Construct a value node with the value of the offset */ Index: gdb/f-lang.c =================================================================== RCS file: /cvs/src/src/gdb/f-lang.c,v retrieving revision 1.25 diff -c -p -r1.25 f-lang.c *** gdb/f-lang.c 28 Jul 2004 02:46:22 -0000 1.25 --- gdb/f-lang.c 20 Aug 2004 13:24:09 -0000 *************** const struct language_defn f_language_de *** 462,467 **** --- 462,468 ---- range_check_on, type_check_on, case_sensitive_off, + array_column_major, &exp_descriptor_standard, f_parse, /* parser */ f_error, /* parser error function */ Index: gdb/jv-lang.c =================================================================== RCS file: /cvs/src/src/gdb/jv-lang.c,v retrieving revision 1.33 diff -c -p -r1.33 jv-lang.c *** gdb/jv-lang.c 28 Jul 2004 15:18:06 -0000 1.33 --- gdb/jv-lang.c 20 Aug 2004 13:24:10 -0000 *************** const struct language_defn java_language *** 1088,1093 **** --- 1088,1094 ---- range_check_off, type_check_off, case_sensitive_on, + array_row_major, &exp_descriptor_java, java_parse, java_error, Index: gdb/language.c =================================================================== RCS file: /cvs/src/src/gdb/language.c,v retrieving revision 1.48 diff -c -p -r1.48 language.c *** gdb/language.c 28 Jul 2004 04:33:49 -0000 1.48 --- gdb/language.c 20 Aug 2004 13:24:12 -0000 *************** const struct language_defn unknown_langu *** 1294,1299 **** --- 1294,1300 ---- NULL, range_check_off, type_check_off, + array_row_major, case_sensitive_on, &exp_descriptor_standard, unk_lang_parser, *************** const struct language_defn auto_language *** 1333,1338 **** --- 1334,1340 ---- NULL, range_check_off, type_check_off, + array_row_major, case_sensitive_on, &exp_descriptor_standard, unk_lang_parser, *************** const struct language_defn local_languag *** 1372,1377 **** --- 1374,1380 ---- range_check_off, type_check_off, case_sensitive_on, + array_row_major, &exp_descriptor_standard, unk_lang_parser, unk_lang_error, Index: gdb/language.h =================================================================== RCS file: /cvs/src/src/gdb/language.h,v retrieving revision 1.29 diff -c -p -r1.29 language.h *** gdb/language.h 28 Jul 2004 04:33:49 -0000 1.29 --- gdb/language.h 20 Aug 2004 13:24:14 -0000 *************** extern enum case_mode *** 96,101 **** --- 96,112 ---- } 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 */ *************** struct language_defn *** 187,192 **** --- 198,206 ---- /* 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 */ Index: gdb/m2-lang.c =================================================================== RCS file: /cvs/src/src/gdb/m2-lang.c,v retrieving revision 1.18 diff -c -p -r1.18 m2-lang.c *** gdb/m2-lang.c 28 Jul 2004 02:46:23 -0000 1.18 --- gdb/m2-lang.c 20 Aug 2004 13:24:15 -0000 *************** const struct language_defn m2_language_d *** 415,420 **** --- 415,421 ---- range_check_on, type_check_on, case_sensitive_on, + array_row_major, &exp_descriptor_standard, m2_parse, /* parser */ m2_error, /* parser error function */ Index: gdb/objc-lang.c =================================================================== RCS file: /cvs/src/src/gdb/objc-lang.c,v retrieving revision 1.37 diff -c -p -r1.37 objc-lang.c *** gdb/objc-lang.c 28 Jul 2004 02:46:23 -0000 1.37 --- gdb/objc-lang.c 20 Aug 2004 13:24:19 -0000 *************** const struct language_defn objc_language *** 659,664 **** --- 659,665 ---- range_check_off, type_check_off, case_sensitive_on, + array_row_major, &exp_descriptor_standard, objc_parse, objc_error, Index: gdb/p-lang.c =================================================================== RCS file: /cvs/src/src/gdb/p-lang.c,v retrieving revision 1.20 diff -c -p -r1.20 p-lang.c *** gdb/p-lang.c 28 Jul 2004 02:46:23 -0000 1.20 --- gdb/p-lang.c 20 Aug 2004 13:24:20 -0000 *************** const struct language_defn pascal_langua *** 451,456 **** --- 451,457 ---- range_check_on, type_check_on, case_sensitive_on, + array_row_major, &exp_descriptor_standard, pascal_parse, pascal_error, Index: gdb/scm-lang.c =================================================================== RCS file: /cvs/src/src/gdb/scm-lang.c,v retrieving revision 1.26 diff -c -p -r1.26 scm-lang.c *** gdb/scm-lang.c 28 Jul 2004 15:18:06 -0000 1.26 --- gdb/scm-lang.c 20 Aug 2004 13:24:22 -0000 *************** const struct language_defn scm_language_ *** 248,253 **** --- 248,254 ---- range_check_off, type_check_off, case_sensitive_off, + array_row_major, &exp_descriptor_scm, scm_parse, c_error,