From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 10946 invoked by alias); 16 Aug 2004 12:38:21 -0000 Mailing-List: contact gdb-patches-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sources.redhat.com Received: (qmail 10909 invoked from network); 16 Aug 2004 12:38:14 -0000 Received: from unknown (HELO black-watch.firstnet.net.uk) (212.103.224.244) by sourceware.org with SMTP; 16 Aug 2004 12:38:14 -0000 Received: (qmail 26789 invoked from network); 16 Aug 2004 12:39:23 -0000 Received: from unknown (HELO localhost.localdomain) (212.103.239.121) by black-watch.first with SMTP; 16 Aug 2004 12:39:23 -0000 Received: from localhost (castle.priv.wark.uk.streamline-computing.com [192.168.1.249]) by localhost.localdomain (8.12.8/8.12.8) with ESMTP id i7GCc9XY004441; Mon, 16 Aug 2004 13:38:09 +0100 Subject: Re: [PATCH/RFA] PR gdb/648 From: David Lecomber To: Jim Blandy Cc: patches In-Reply-To: References: <1091830216.4188.23.camel@localhost> Content-Type: multipart/mixed; boundary="=-dAnnpS3xJu33lFkKOk02" Message-Id: <1092659964.5816.5.camel@localhost> Mime-Version: 1.0 Date: Mon, 16 Aug 2004 12:38:00 -0000 X-SW-Source: 2004-08/txt/msg00536.txt.bz2 --=-dAnnpS3xJu33lFkKOk02 Content-Type: text/plain Content-Transfer-Encoding: 7bit Content-length: 1734 > - Rather than recognizing Fortran specially in read_array_type, I'd > rather have a new member of 'struct language_defn' giving the array > ordering for that language. > > - I'd like to have the logic that chooses a byte order pulled out of > read_array_type into its own function that takes a die, a cu, and > returns a DW_ORD_ value. That function would take care of looking > for a DW_AT_ordering attribute, recognizing the appropriate versions > of GNU F77, and so on. read_array_type should call that function > and build the type appropriately. Ok, here's round two! It passes my Fortran test case ok, but I haven't run through the normal tests. I've had to guess that all other languages are row major (where it actually is relevant..) and I cannot think of any exceptions other than Fortran. 2004-08-16 David Lecomber 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. --=-dAnnpS3xJu33lFkKOk02 Content-Disposition: attachment; filename=lang.patches Content-Type: text/x-patch; name=lang.patches; charset=UTF-8 Content-Transfer-Encoding: 7bit Content-length: 13623 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 16 Aug 2004 12:01:57 -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 16 Aug 2004 12:01:58 -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 16 Aug 2004 12:02:11 -0000 *************** static CORE_ADDR decode_locdesc (struct *** 848,853 **** --- 848,855 ---- static void read_array_type (struct die_info *, struct dwarf2_cu *); + static int 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 --- 3726,3745 ---- /* 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 **** --- 3757,3788 ---- die->type = type; } + static int + 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); + + 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 16 Aug 2004 12:02:15 -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 16 Aug 2004 12:02:18 -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 16 Aug 2004 12:02:20 -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 16 Aug 2004 12:02:23 -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 16 Aug 2004 12:02:24 -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 16 Aug 2004 12:02:25 -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 16 Aug 2004 12:02:27 -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 16 Aug 2004 12:02:28 -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 16 Aug 2004 12:02:29 -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, --=-dAnnpS3xJu33lFkKOk02--