From: "Andrew Burgess" <aburgess@broadcom.com>
To: "gdb-patches@sourceware.org" <gdb-patches@sourceware.org>
Cc: "Jan Kratochvil" <jan.kratochvil@redhat.com>
Subject: RE: [PATCH] Multi-dimensional Fortran arrays issue PR11104
Date: Tue, 19 Oct 2010 16:23:00 -0000 [thread overview]
Message-ID: <89AE14E37D740B4796DC14566DF6325ECB7F1F6E81@SJEXCHCCR02.corp.ad.broadcom.com> (raw)
In-Reply-To: <20101018211952.GA16206@host1.dyn.jankratochvil.net>
[-- Attachment #1: Type: text/plain, Size: 1156 bytes --]
Jan, thanks for taking the time to look through the original patch.
> On 18 October 2010 22:20, Jan Kratochvil wrote:
>
> multi-dim.tar.bz2 (.exp + .f90) should be submitted as a normal patch,
Done.
>
> ChangeLog should be submitted as a text, not as patch.
>
I've included the ChangeLog entries within the patch file as plain text before the start of that patch content, this seems to be what others have done, but I can pull them out if this is not correct.
> There are several minor issues with formatting:
> http://www.gnu.org/prep/standards/
I believe that these have all been addressed. If I've still missed anything then please let me know.
>
> This functionality is implemented by archer-jankratochvil-vla from:
> http://sourceware.org/gdb/wiki/ArcherBranchManagement
>
> (out of bounds access is not detected by the VLA patchset though)
>
> which is currently not submitted for a review as it has more
> prerequisites.
As I had the patch pretty much ready I cleaned it up anyway. I guess it's up to someone else to decide to merge this or wait for the Archer branch to land.
Thanks,
Andrew
[-- Attachment #2: arrays.test.patch --]
[-- Type: application/octet-stream, Size: 4232 bytes --]
gdb/testsuite/ChangeLog:
2010-10-19 Andrew Burgess <aburgess@broadcom.com>
* gdb.fortran/multi-dim.f90: New test program.
* gdb.fortran/multi-dim.exp: Run new test to check basic printing
of multi-dimensional fortran arrays. Tests PR gdb/11104.
diff -uNr clean/gdb-7.2.50.20101019/gdb/testsuite/gdb.fortran/multi-dim.exp working/gdb-7.2.50.20101019/gdb/testsuite/gdb.fortran/multi-dim.exp
--- clean/gdb-7.2.50.20101019/gdb/testsuite/gdb.fortran/multi-dim.exp 1970-01-01 01:00:00.000000000 +0100
+++ working/gdb-7.2.50.20101019/gdb/testsuite/gdb.fortran/multi-dim.exp 2010-10-19 15:53:13.928699000 +0100
@@ -0,0 +1,79 @@
+# Copyright 2010 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+# This file was written by Wu Zhou. (woodzltc@cn.ibm.com)
+
+# This file is part of the gdb testsuite. It contains tests for evaluating
+# Fortran subarray expression.
+
+if $tracelevel then {
+ strace $tracelevel
+}
+
+if { [skip_fortran_tests] } { return -1 }
+
+set testfile "multi-dim"
+set srcfile ${testfile}.f90
+set binfile ${objdir}/${subdir}/${testfile}
+
+if {[gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" \
+ executable {debug f77}] != ""} {
+ return -1
+}
+
+gdb_exit
+gdb_start
+gdb_reinitialize_dir $srcdir/$subdir
+gdb_load ${binfile}
+
+if ![runto MAIN__] then {
+ perror "Couldn't run to MAIN__"
+ continue
+}
+
+gdb_test "break 20" \
+ "Breakpoint.*at.* file .*$srcfile, line 20\\." \
+ "breakpoint at line 20"
+
+gdb_test "continue" \
+ "Breakpoint 2, test \(\).*at.*multi-dim\.f90:20.*" \
+ "Continue to breakpoint"
+
+gdb_test "print foo(2,3,4)" \
+ "\\\$1 = 20" \
+ "print the contents of the array"
+
+gdb_test "print foo(0,0,0)" \
+ "no such vector element" \
+ "print an invalid array index (0,0,0)"
+
+gdb_test "print foo(2,3,5)" \
+ "no such vector element" \
+ "print an invalid array index (2,3,5)"
+
+gdb_test "print foo(2,4,4)" \
+ "no such vector element" \
+ "print an invalid array index (2,4,4)"
+
+gdb_test "print foo(3,3,4)" \
+ "no such vector element" \
+ "print an invalid array index (3,3,4)"
+
+gdb_test "print foo" \
+ "\\\$2 = \\(\\( \\( 10, 10\\) \\( 10, 10\\) \\( 10, 10\\) \\) \\( \\( 10, 10\\) \\( 10, 10\\) \\( 10, 10\\) \\) \\( \\( 10, 10\\) \\( 10, 10\\) \\( 10, 10\\) \\) \\( \\( 10, 10\\) \\( 10, 10\\) \\( 10, 20\\) \\) \\)" \
+ "print full contents of the array"
+
+gdb_exit
+
diff -uNr clean/gdb-7.2.50.20101019/gdb/testsuite/gdb.fortran/multi-dim.f90 working/gdb-7.2.50.20101019/gdb/testsuite/gdb.fortran/multi-dim.f90
--- clean/gdb-7.2.50.20101019/gdb/testsuite/gdb.fortran/multi-dim.f90 1970-01-01 01:00:00.000000000 +0100
+++ working/gdb-7.2.50.20101019/gdb/testsuite/gdb.fortran/multi-dim.f90 2010-10-19 15:53:13.972696000 +0100
@@ -0,0 +1,21 @@
+! Copyright 2010 Free Software Foundation, Inc.
+!
+! This program is free software; you can redistribute it and/or modify
+! it under the terms of the GNU General Public License as published by
+! the Free Software Foundation; either version 3 of the License, or
+! (at your option) any later version.
+!
+! This program is distributed in the hope that it will be useful,
+! but WITHOUT ANY WARRANTY; without even the implied warranty of
+! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+! GNU General Public License for more details.
+!
+! You should have received a copy of the GNU General Public License
+! along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+program test
+ integer :: foo (2, 3, 4)
+ foo (:, :, :) = 10
+ foo (2, 3, 4) = 20
+ foo (2, 3, 4) = 20
+end
[-- Attachment #3: arrays.patch --]
[-- Type: application/octet-stream, Size: 3113 bytes --]
gdb/ChangeLog:
2010-10-19 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. Fix PR gdb/11104.
* eval.c (evaluate_subexp_standard) Remove hack from
multi_f77_subscript case now that multi-dimensional arrays are
supported. Fix PR gdb/11104.
Index: gdb/eval.c
===================================================================
RCS file: /cvs/src/src/gdb/eval.c,v
retrieving revision 1.139
diff -u -r1.139 eval.c
--- gdb/eval.c 11 Aug 2010 16:48:26 -0000 1.139
+++ gdb/eval.c 19 Oct 2010 08:15:37 -0000
@@ -2306,16 +2306,7 @@
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));
+ tmp_type = check_typedef (TYPE_TARGET_TYPE (tmp_type));
}
/* Now let us calculate the offset for this item */
@@ -2326,14 +2317,6 @@
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);
}
Index: gdb/valarith.c
===================================================================
RCS file: /cvs/src/src/gdb/valarith.c,v
retrieving revision 1.87
diff -u -r1.87 valarith.c
--- gdb/valarith.c 8 Oct 2010 16:50:53 -0000 1.87
+++ gdb/valarith.c 19 Oct 2010 08:15:40 -0000
@@ -193,10 +193,20 @@
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 type *elt_type = array_type;
+ unsigned int elt_size, elt_offs;
struct value *v;
+
+ /* 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);
+ elt_size = TYPE_LENGTH (elt_type);
+ elt_offs = elt_size * longest_to_int (index - lowerbound);
if (index < lowerbound || (!TYPE_ARRAY_UPPER_BOUND_IS_UNDEFINED (array_type)
&& elt_offs >= TYPE_LENGTH (array_type)))
next prev parent reply other threads:[~2010-10-19 16:23 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-09-16 17:26 Andrew Burgess
2010-10-18 7:53 ` Andrew Burgess
2010-10-18 21:20 ` Jan Kratochvil
2010-10-19 16:23 ` Andrew Burgess [this message]
2010-11-17 8:45 ` Andrew Burgess
2010-11-22 7:10 ` Jan Kratochvil
2010-11-23 8:02 ` Jan Kratochvil
2010-11-23 10:04 ` Andrew Burgess
2010-11-23 17:23 ` Jan Kratochvil
2010-11-23 19:10 ` Jan Kratochvil
2010-10-18 21:21 ` Jan Kratochvil
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=89AE14E37D740B4796DC14566DF6325ECB7F1F6E81@SJEXCHCCR02.corp.ad.broadcom.com \
--to=aburgess@broadcom.com \
--cc=gdb-patches@sourceware.org \
--cc=jan.kratochvil@redhat.com \
/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: link
Be 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).