public inbox for gdb-prs@sourceware.org help / color / mirror / Atom feed
From: "mat dot yeates at gmail dot com" <sourceware-bugzilla@sourceware.org> To: gdb-prs@sourceware.org Subject: [Bug fortran/12044] New: Fortran indexing does not work Date: Mon, 20 Sep 2010 21:04:00 -0000 [thread overview] Message-ID: <20100920210429.12044.mat.yeates@gmail.com> (raw) The following code was compiled with gfortran -g3 -gdwarf-2 try1.f90 -o try1. This gdb-7.2 with a patch applied (see the bottom of this post) -------------------code---------------- subroutine foo(Num_tau, Num_mixture,Gridded_resid_mask) logical, intent(out), dimension(Num_tau, Num_mixture) :: & Gridded_resid_mask Gridded_resid_mask(:,:) = .TRUE. if (Gridded_resid_mask(4,4)) then write(*,*) 'Boo' endif end program goo logical, dimension(100,100) :: & Gridded_resid_mask call foo(100,100,Gridded_resid_mask) end -----------------------code-------------- here is my gdb session gdb try1 (gdb) b try1.f90:5 (gdb) run (gdb) set Gridded_resid_mask(4,4)=.FALSE. (gdb) n 6 write(*,*) 'Boo' (gdb) quit here is a session that works gdb try1 gdb) b try1.f90:5 run (gdb)p &Gridded_resid_mask $1 = (PTR TO -> ( logical(kind=4) (*,*))) 0x601280 (gdb) set *(int)(0x601280 + 4*(3*100+3))=.FALSE. (gdb) n 8 end (gdb) quit ---The following patch was applied to 7.2------------ diff -rcp gdb-7.2-clean/gdb/ChangeLog gdb-7.2/gdb/ChangeLog *** gdb-7.2-clean/gdb/ChangeLog 2010-09-03 00:37:25.000000000 +0100 --- gdb-7.2/gdb/ChangeLog 2010-09-07 22:58:01.229977481 +0100 *************** *** 1,3 **** --- 1,13 ---- + 2010-09-07 Andrew Burgess <aburgess@broadcom.com> + + * valarith.c (value_subscripted_rvalue) Walk through + multi-dimensional arrays to find the element type for the + array. Allows the upper bound check to work with multi-dimensional + arrays. + * eval.c (evaluate_subexp_standard) Remove hack from + multi_f77_subscript case now that multi-dimensional arrays are + supported in valarith.c + 2010-09-02 Joel Brobecker <brobecker@adacore.com> * NEWS: Replace "Changes since GDB 7.1" by "Changes in GDB 7.2". diff -rcp gdb-7.2-clean/gdb/eval.c gdb-7.2/gdb/eval.c *** gdb-7.2-clean/gdb/eval.c 2010-07-07 17:15:15.000000000 +0100 --- gdb-7.2/gdb/eval.c 2010-09-07 22:44:31.493976944 +0100 *************** evaluate_subexp_standard (struct type *e *** 2296,2311 **** 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 ! type around for use when calling value_subscript() ! below. This is done because we pretend to value_subscript ! that we actually have a one-dimensional array ! 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 */ --- 2296,2302 ---- subscript_array[nargs - i - 1] -= lower; ! tmp_type = check_typedef (TYPE_TARGET_TYPE (tmp_type)); } /* Now let us calculate the offset for this item */ *************** evaluate_subexp_standard (struct type *e *** 2316,2329 **** offset_item = array_size_array[i - 1] * offset_item + subscript_array[i - 1]; - /* 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 - that it is actually a array of the final element - type, this will ensure that value_subscript() - returns the correct type value */ - - deprecated_set_value_type (arg1, tmp_type); return value_subscripted_rvalue (arg1, offset_item, 0); } --- 2307,2312 ---- diff -rcp gdb-7.2-clean/gdb/valarith.c gdb-7.2/gdb/valarith.c *** gdb-7.2-clean/gdb/valarith.c 2010-06-07 17:11:31.000000000 +0100 --- gdb-7.2/gdb/valarith.c 2010-09-07 22:52:25.154057798 +0100 *************** struct value * *** 193,199 **** value_subscripted_rvalue (struct value *array, LONGEST index, int lowerbound) { struct type *array_type = check_typedef (value_type (array)); ! struct type *elt_type = check_typedef (TYPE_TARGET_TYPE (array_type)); unsigned int elt_size = TYPE_LENGTH (elt_type); unsigned int elt_offs = elt_size * longest_to_int (index - lowerbound); struct value *v; --- 193,208 ---- value_subscripted_rvalue (struct value *array, LONGEST index, int lowerbound) { struct type *array_type = check_typedef (value_type (array)); ! struct type *elt_type = array_type; ! ! /* Peel of the array indices until we reach the array element type */ ! do { ! elt_type = TYPE_TARGET_TYPE(elt_type); ! } ! while ( TYPE_CODE(elt_type) == TYPE_CODE_ARRAY); ! ! elt_type = check_typedef(elt_type); ! unsigned int elt_size = TYPE_LENGTH (elt_type); unsigned int elt_offs = elt_size * longest_to_int (index - lowerbound); struct value *v; -- Summary: Fortran indexing does not work Product: gdb Version: 7.2 Status: UNCONFIRMED Severity: normal Priority: P2 Component: fortran AssignedTo: unassigned at sourceware dot org ReportedBy: mat dot yeates at gmail dot com CC: gdb-prs at sourceware dot org http://sourceware.org/bugzilla/show_bug.cgi?id=12044 ------- You are receiving this mail because: ------- You are on the CC list for the bug, or are watching someone who is.
next reply other threads:[~2010-09-20 21:04 UTC|newest] Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top 2010-09-20 21:04 mat dot yeates at gmail dot com [this message] 2010-09-20 23:18 ` [Bug fortran/12044] " mat dot yeates at gmail dot com 2010-09-23 17:29 ` mat dot yeates at gmail dot com 2010-09-29 21:48 ` mat dot yeates at gmail dot com
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20100920210429.12044.mat.yeates@gmail.com \ --to=sourceware-bugzilla@sourceware.org \ --cc=gdb-prs@sourceware.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).