- [vla] Fox Fortran vector slices for allocated arrays (for BZ 609782).

This commit is contained in:
Jan Kratochvil 2011-02-18 01:22:14 +01:00
parent 1faf245e87
commit 33f3958adb
3 changed files with 161 additions and 1 deletions

View File

@ -0,0 +1,90 @@
From 3f323125c4c8d9c4c00cb8941149ac36443dac26 Mon Sep 17 00:00:00 2001
From: Jan Kratochvil <jan.kratochvil@redhat.com>
Date: Fri, 18 Feb 2011 00:17:35 +0100
Subject: [PATCH 1/2] Fix subranges bug http://sourceware.org/bugzilla/show_bug.cgi?id=9395#c5
reported by Joachim Protze.
---
gdb/eval.c | 1 +
gdb/testsuite/gdb.fortran/subrange.exp | 31 ++++++++++++++++++++-----------
gdb/testsuite/gdb.fortran/subrange.f90 | 7 ++++++-
3 files changed, 27 insertions(+), 12 deletions(-)
diff --git a/gdb/eval.c b/gdb/eval.c
index f21ae38..6f37f2c 100644
--- a/gdb/eval.c
+++ b/gdb/eval.c
@@ -563,6 +563,7 @@ value_f90_subarray (struct value *array, struct expression *exp, int *pos,
value_byte_address = (TYPE_DATA_LOCATION_ADDR (type)
+ value_offset (array));
TYPE_DATA_LOCATION_IS_ADDR (type) = 0;
+ TYPE_DATA_LOCATION_DWARF_BLOCK (type) = NULL;
}
else
value_byte_address = value_address (array);
diff --git a/gdb/testsuite/gdb.fortran/subrange.exp b/gdb/testsuite/gdb.fortran/subrange.exp
index 55598f9..be372c1 100644
--- a/gdb/testsuite/gdb.fortran/subrange.exp
+++ b/gdb/testsuite/gdb.fortran/subrange.exp
@@ -34,17 +34,26 @@ set int4 "(int4|integer\\(kind=4\\))"
gdb_breakpoint [gdb_get_line_number "break-static"]
gdb_continue_to_breakpoint "break-static" ".*break-static.*"
-gdb_test "p a (2, 2:3)" { = \(22, 32\)}
-gdb_test "p a (2:3, 3)" { = \(32, 33\)}
-gdb_test "p a (1, 2:)" { = \(21, 31\)}
-gdb_test "p a (2, :2)" { = \(12, 22\)}
-gdb_test "p a (3, 2:2)" { = \(23\)}
-gdb_test "ptype a (3, 2:2)" " = $int4 \\(2:2\\)"
-gdb_test "p a (4, :)" { = \(14, 24, 34\)}
-gdb_test "p a (:, :)" { = \(\( *11, 12, 13, 14\) \( *21, 22, 23, 24\) \( *31, 32, 33, 34\) *\)}
-gdb_test "ptype a (:, :)" " = $int4 \\(4,3\\)"
-gdb_test "p a (:)" "Wrong number of subscripts"
-gdb_test "p a (:, :, :)" "Wrong number of subscripts"
+foreach var {a alloc ptr} {
+ global pf_prefix
+ set old_prefix $pf_prefix
+ lappend pf_prefix "$var:"
+
+ gdb_test "p $var (2, 2:3)" { = \(22, 32\)}
+ gdb_test "p $var (2:3, 3)" { = \(32, 33\)}
+ gdb_test "p $var (1, 2:)" { = \(21, 31\)}
+ gdb_test "p $var (2, :2)" { = \(12, 22\)}
+ gdb_test "p $var (3, 2:2)" { = \(23\)}
+ gdb_test "ptype $var (3, 2:2)" " = $int4 \\(2:2\\)"
+ gdb_test "p $var (4, :)" { = \(14, 24, 34\)}
+ gdb_test "p $var (:, :)" { = \(\( *11, 12, 13, 14\) \( *21, 22, 23, 24\) \( *31, 32, 33, 34\) *\)}
+ gdb_test "ptype $var (:, :)" " = $int4 \\(4,3\\)"
+ gdb_test "p $var (:)" "Wrong number of subscripts"
+ gdb_test "p $var (:, :, :)" "Wrong number of subscripts"
+
+ set pf_prefix $old_prefix
+}
+
gdb_test_no_output {set $a=a}
delete_breakpoints
gdb_unload
diff --git a/gdb/testsuite/gdb.fortran/subrange.f90 b/gdb/testsuite/gdb.fortran/subrange.f90
index fe33c2c..4747ea9 100644
--- a/gdb/testsuite/gdb.fortran/subrange.f90
+++ b/gdb/testsuite/gdb.fortran/subrange.f90
@@ -14,10 +14,15 @@
! along with this program. If not, see <http://www.gnu.org/licenses/>.
program test
- integer :: a (4, 3)
+ integer, target :: a (4, 3)
+ integer, allocatable :: alloc (:, :)
+ integer, pointer :: ptr (:, :)
do 1 i = 1, 4
do 1 j = 1, 3
a (i, j) = j * 10 + i
1 continue
+ allocate (alloc (4, 3))
+ alloc = a
+ ptr => a
write (*,*) a ! break-static
end
--
1.7.4

View File

@ -0,0 +1,61 @@
From 678cbb7340d8edfa92ce6de931d8d4e9c3b86c06 Mon Sep 17 00:00:00 2001
From: Jan Kratochvil <jan.kratochvil@redhat.com>
Date: Fri, 18 Feb 2011 00:46:12 +0100
Subject: [PATCH 2/2] Fix the remaining two FAILing subrange testcases.
---
gdb/dwarf2read.c | 14 ++++++++------
gdb/eval.c | 5 ++++-
2 files changed, 12 insertions(+), 7 deletions(-)
diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c
index 89d15d1..a9099be 100644
--- a/gdb/dwarf2read.c
+++ b/gdb/dwarf2read.c
@@ -7416,6 +7416,14 @@ read_array_type (struct die_info *die, struct dwarf2_cu *cu)
for (i = ndim - 1; i >= 0; i--)
type = create_single_array_dimension (type, range_types[i], die, cu);
+ /* Data locations should be set only for the outermost dimension as they
+ would be confusing for the dereferenced offset on the inner ones. */
+ attr = dwarf2_attr (die, DW_AT_data_location, cu);
+ if (attr_form_is_block (attr))
+ TYPE_DATA_LOCATION_DWARF_BLOCK (type)
+ = dwarf2_attr_to_locexpr_baton (attr, cu);
+ gdb_assert (!TYPE_DATA_LOCATION_IS_ADDR (type));
+
/* Understand Dwarf2 support for vector types (like they occur on
the PowerPC w/ AltiVec). Gcc just adds another attribute to the
array type. This is not part of the Dwarf2/3 standard yet, but a
@@ -15072,12 +15080,6 @@ fetch_die_type_attrs (struct die_info *die, struct type *type,
{
struct attribute *attr;
- attr = dwarf2_attr (die, DW_AT_data_location, cu);
- if (attr_form_is_block (attr))
- TYPE_DATA_LOCATION_DWARF_BLOCK (type) = dwarf2_attr_to_locexpr_baton (attr,
- cu);
- gdb_assert (!TYPE_DATA_LOCATION_IS_ADDR (type));
-
attr = dwarf2_attr (die, DW_AT_allocated, cu);
if (attr_form_is_block (attr))
TYPE_ALLOCATED (type) = dwarf2_attr_to_locexpr_baton (attr, cu);
diff --git a/gdb/eval.c b/gdb/eval.c
index 6f37f2c..f4ccc89 100644
--- a/gdb/eval.c
+++ b/gdb/eval.c
@@ -566,7 +566,10 @@ value_f90_subarray (struct value *array, struct expression *exp, int *pos,
TYPE_DATA_LOCATION_DWARF_BLOCK (type) = NULL;
}
else
- value_byte_address = value_address (array);
+ {
+ gdb_assert (TYPE_DATA_LOCATION_DWARF_BLOCK (type) == NULL);
+ value_byte_address = value_address (array);
+ }
new_array_type = type;
--
1.7.4

View File

@ -27,7 +27,7 @@ Version: 7.2
# The release always contains a leading reserved number, start it at 1.
# `upstream' is not a part of `name' to stay fully rpm dependencies compatible for the testing.
Release: 42%{?_with_upstream:.upstream}%{dist}
Release: 43%{?_with_upstream:.upstream}%{dist}
License: GPLv3+ and GPLv3+ with exceptions and GPLv2+ and GPLv2+ with exceptions and GPL+ and LGPLv2+ and GFDL and BSD and Public Domain
Group: Development/Debuggers
@ -704,6 +704,10 @@ Patch548: gdb-test-expr-cumulative-archer.patch
Patch549: gdb-archer-vla-misc.patch
# =drop
Patch550: gdb-archer-vla-subarray.patch
# =drop
Patch569: gdb-archer-vla-subarray-alloc-1of2.patch
# =drop
Patch570: gdb-archer-vla-subarray-alloc-2of2.patch
# Fix discontiguous address ranges in .gdb_index - v3->v4 (BZ 672281).
# =drop
@ -1031,6 +1035,8 @@ rm -f gdb/jv-exp.c gdb/m2-exp.c gdb/objc-exp.c gdb/p-exp.c
%patch548 -p1
%patch549 -p1
%patch550 -p1
%patch569 -p1
%patch570 -p1
%patch551 -p1
%patch552 -p1
%patch553 -p1
@ -1441,6 +1447,9 @@ fi
%endif
%changelog
* Fri Feb 18 2011 Jan Kratochvil <jan.kratochvil@redhat.com> - 7.2-43.fc14
- [vla] Fox Fortran vector slices for allocated arrays (for BZ 609782).
* Sun Feb 13 2011 Jan Kratochvil <jan.kratochvil@redhat.com> - 7.2-42.fc14
- Fix occasionall unfound source lines (affecting at least glibc debugging).
- Fix const/volatile qualifiers of C++ types (PR c++/12328).