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.
This commit is contained in:
David Lecomber 2004-08-29 10:12:24 +00:00
parent 47e35c11d6
commit 7ca2d3a371
13 changed files with 116 additions and 12 deletions

View file

@ -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> 2004-08-27 Nathan J. Williams <nathanw@wasabisystems.com>
* target.c (target_resize_to_sections): Check * target.c (target_resize_to_sections): Check

View file

@ -10166,6 +10166,7 @@ const struct language_defn ada_language_defn = {
ada_lookup_symbol, ada_lookup_symbol,
ada_lookup_minimal_symbol, ada_lookup_minimal_symbol,
#endif /* GNAT_GDB */ #endif /* GNAT_GDB */
array_row_major,
&ada_exp_descriptor, &ada_exp_descriptor,
parse, parse,
ada_error, ada_error,

View file

@ -570,6 +570,7 @@ const struct language_defn c_language_defn =
range_check_off, range_check_off,
type_check_off, type_check_off,
case_sensitive_on, case_sensitive_on,
array_row_major,
&exp_descriptor_standard, &exp_descriptor_standard,
c_preprocess_and_parse, c_preprocess_and_parse,
c_error, c_error,
@ -631,6 +632,7 @@ const struct language_defn cplus_language_defn =
range_check_off, range_check_off,
type_check_off, type_check_off,
case_sensitive_on, case_sensitive_on,
array_row_major,
&exp_descriptor_standard, &exp_descriptor_standard,
c_preprocess_and_parse, c_preprocess_and_parse,
c_error, c_error,
@ -669,6 +671,7 @@ const struct language_defn asm_language_defn =
range_check_off, range_check_off,
type_check_off, type_check_off,
case_sensitive_on, case_sensitive_on,
array_row_major,
&exp_descriptor_standard, &exp_descriptor_standard,
c_preprocess_and_parse, c_preprocess_and_parse,
c_error, c_error,
@ -712,6 +715,7 @@ const struct language_defn minimal_language_defn =
range_check_off, range_check_off,
type_check_off, type_check_off,
case_sensitive_on, case_sensitive_on,
array_row_major,
&exp_descriptor_standard, &exp_descriptor_standard,
c_preprocess_and_parse, c_preprocess_and_parse,
c_error, c_error,

View file

@ -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 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_pointer_type (struct die_info *, struct dwarf2_cu *);
static void read_tag_ptr_to_member_type (struct die_info *, 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 /* Dwarf2 dimensions are output from left to right, create the
necessary array types in backwards order. */ necessary array types in backwards order. */
type = element_type; 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) while (ndim-- > 0)
type = create_array_type (NULL, type, range_types[ndim]); type = create_array_type (NULL, type, range_types[ndim]);
}
/* Understand Dwarf2 support for vector types (like they occur on /* Understand Dwarf2 support for vector types (like they occur on
the PowerPC w/ AltiVec). Gcc just adds another attribute to the 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; 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. */ /* First cut: install each common block member as a global variable. */
static void static void

View file

@ -1610,9 +1610,8 @@ evaluate_subexp_standard (struct type *expect_type,
multi_f77_subscript: multi_f77_subscript:
{ {
int subscript_array[MAX_FORTRAN_DIMS + 1]; /* 1-based array of int subscript_array[MAX_FORTRAN_DIMS];
subscripts, max == 7 */ int array_size_array[MAX_FORTRAN_DIMS];
int array_size_array[MAX_FORTRAN_DIMS + 1];
int ndimensions = 1, i; int ndimensions = 1, i;
struct type *tmp_type; struct type *tmp_type;
int offset_item; /* The array offset where the item lives */ 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. */ let us actually find out where this element exists in the array. */
offset_item = 0; 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 */ /* Evaluate each subscript, It must be a legal integer in F77 */
arg2 = evaluate_subexp_with_coercion (exp, pos, noside); 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 */ /* Fill in the subscript and array size arrays */
subscript_array[i] = value_as_long (arg2); 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); retcode = f77_get_dynamic_upperbound (tmp_type, &upper);
if (retcode == BOUND_FETCH_ERROR) if (retcode == BOUND_FETCH_ERROR)
error ("Cannot obtain dynamic upper bound"); error ("Cannot obtain dynamic upper bound");
@ -1647,11 +1651,11 @@ evaluate_subexp_standard (struct type *expect_type,
if (retcode == BOUND_FETCH_ERROR) if (retcode == BOUND_FETCH_ERROR)
error ("Cannot obtain dynamic lower bound"); 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. */ /* 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 /* If we are at the bottom of a multidimensional
array type then keep a ptr to the last ARRAY 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 of base element type that we apply a simple
offset to. */ offset to. */
if (i < nargs) if (i < nargs - 1)
tmp_type = check_typedef (TYPE_TARGET_TYPE (tmp_type)); tmp_type = check_typedef (TYPE_TARGET_TYPE (tmp_type));
} }
/* Now let us calculate the offset for this item */ /* 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 = 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 */ /* Construct a value node with the value of the offset */

View file

@ -462,6 +462,7 @@ const struct language_defn f_language_defn =
range_check_on, range_check_on,
type_check_on, type_check_on,
case_sensitive_off, case_sensitive_off,
array_column_major,
&exp_descriptor_standard, &exp_descriptor_standard,
f_parse, /* parser */ f_parse, /* parser */
f_error, /* parser error function */ f_error, /* parser error function */

View file

@ -1088,6 +1088,7 @@ const struct language_defn java_language_defn =
range_check_off, range_check_off,
type_check_off, type_check_off,
case_sensitive_on, case_sensitive_on,
array_row_major,
&exp_descriptor_java, &exp_descriptor_java,
java_parse, java_parse,
java_error, java_error,

View file

@ -1294,6 +1294,7 @@ const struct language_defn unknown_language_defn =
NULL, NULL,
range_check_off, range_check_off,
type_check_off, type_check_off,
array_row_major,
case_sensitive_on, case_sensitive_on,
&exp_descriptor_standard, &exp_descriptor_standard,
unk_lang_parser, unk_lang_parser,
@ -1333,6 +1334,7 @@ const struct language_defn auto_language_defn =
NULL, NULL,
range_check_off, range_check_off,
type_check_off, type_check_off,
array_row_major,
case_sensitive_on, case_sensitive_on,
&exp_descriptor_standard, &exp_descriptor_standard,
unk_lang_parser, unk_lang_parser,
@ -1372,6 +1374,7 @@ const struct language_defn local_language_defn =
range_check_off, range_check_off,
type_check_off, type_check_off,
case_sensitive_on, case_sensitive_on,
array_row_major,
&exp_descriptor_standard, &exp_descriptor_standard,
unk_lang_parser, unk_lang_parser,
unk_lang_error, unk_lang_error,

View file

@ -96,6 +96,17 @@ extern enum case_mode
} }
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_sensitivity ==
case_sensitive_on: Case sensitivity in name matching is used case_sensitive_on: Case sensitivity in name matching is used
case_sensitive_off: Case sensitivity in name matching is not used */ case_sensitive_off: Case sensitivity in name matching is not used */
@ -187,6 +198,9 @@ struct language_defn
/* Default case sensitivity */ /* Default case sensitivity */
enum case_sensitivity la_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 /* Definitions related to expression printing, prefixifying, and
dumping */ dumping */

View file

@ -415,6 +415,7 @@ const struct language_defn m2_language_defn =
range_check_on, range_check_on,
type_check_on, type_check_on,
case_sensitive_on, case_sensitive_on,
array_row_major,
&exp_descriptor_standard, &exp_descriptor_standard,
m2_parse, /* parser */ m2_parse, /* parser */
m2_error, /* parser error function */ m2_error, /* parser error function */

View file

@ -659,6 +659,7 @@ const struct language_defn objc_language_defn = {
range_check_off, range_check_off,
type_check_off, type_check_off,
case_sensitive_on, case_sensitive_on,
array_row_major,
&exp_descriptor_standard, &exp_descriptor_standard,
objc_parse, objc_parse,
objc_error, objc_error,

View file

@ -451,6 +451,7 @@ const struct language_defn pascal_language_defn =
range_check_on, range_check_on,
type_check_on, type_check_on,
case_sensitive_on, case_sensitive_on,
array_row_major,
&exp_descriptor_standard, &exp_descriptor_standard,
pascal_parse, pascal_parse,
pascal_error, pascal_error,

View file

@ -248,6 +248,7 @@ const struct language_defn scm_language_defn =
range_check_off, range_check_off,
type_check_off, type_check_off,
case_sensitive_off, case_sensitive_off,
array_row_major,
&exp_descriptor_scm, &exp_descriptor_scm,
scm_parse, scm_parse,
c_error, c_error,