aboutsummaryrefslogtreecommitdiff
path: root/gdb/testsuite
diff options
context:
space:
mode:
Diffstat (limited to 'gdb/testsuite')
-rw-r--r--gdb/testsuite/ChangeLog5
-rwxr-xr-xgdb/testsuite/gdb.fortran/vla-type.exp102
-rwxr-xr-xgdb/testsuite/gdb.fortran/vla-type.f9088
3 files changed, 195 insertions, 0 deletions
diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog
index c919c47..bb52582 100644
--- a/gdb/testsuite/ChangeLog
+++ b/gdb/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2016-04-26 Bernhard Heckel <bernhard.heckel@intel.com>
+
+ * gdb.fortran/vla-type.f90: New file.
+ * gdb.fortran/vla-type.exp: New file.
+
2016-04-25 Yao Qi <yao.qi@linaro.org>
* gdb.base/branch-to-self.c: New file.
diff --git a/gdb/testsuite/gdb.fortran/vla-type.exp b/gdb/testsuite/gdb.fortran/vla-type.exp
new file mode 100755
index 0000000..24191fe
--- /dev/null
+++ b/gdb/testsuite/gdb.fortran/vla-type.exp
@@ -0,0 +1,102 @@
+# Copyright 2016 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/>.
+
+standard_testfile ".f90"
+load_lib "fortran.exp"
+
+if { [prepare_for_testing ${testfile}.exp ${testfile} ${srcfile} \
+ {debug f90 quiet}] } {
+ return -1
+}
+
+if ![runto_main] {
+ untested "could not run to main"
+ return -1
+}
+
+# Depending on the compiler being used, the type names can be printed differently.
+set int [fortran_int4]
+
+# Check if not allocated VLA in type does not break
+# the debugger when accessing it.
+gdb_breakpoint [gdb_get_line_number "before-allocated"]
+gdb_continue_to_breakpoint "before-allocated"
+gdb_test "print twov" " = \\\( <not allocated>, <not allocated> \\\)" \
+ "print twov before allocated"
+gdb_test "print twov%ivla1" " = <not allocated>" \
+ "print twov%ivla1 before allocated"
+
+# Check type with one VLA's inside
+gdb_breakpoint [gdb_get_line_number "onev-filled"]
+gdb_continue_to_breakpoint "onev-filled"
+gdb_test "print onev%ivla(5, 11, 23)" " = 1"
+gdb_test "print onev%ivla(1, 2, 3)" " = 123"
+gdb_test "print onev%ivla(3, 2, 1)" " = 321"
+gdb_test "ptype onev" \
+ [multi_line "type = Type one" \
+ "\\s+$int :: ivla\\\(11,22,33\\\)" \
+ "End Type one" ]
+
+# Check type with two VLA's inside
+gdb_breakpoint [gdb_get_line_number "twov-filled"]
+gdb_continue_to_breakpoint "twov-filled"
+gdb_test "print twov%ivla1(5, 11, 23)" " = 1"
+gdb_test "print twov%ivla1(1, 2, 3)" " = 123"
+gdb_test "print twov%ivla1(3, 2, 1)" " = 321"
+gdb_test "ptype twov" \
+ [multi_line "type = Type two" \
+ "\\s+$int :: ivla1\\\(5,12,99\\\)" \
+ "\\s+$int :: ivla2\\\(9,12\\\)" \
+ "End Type two" ]
+
+# Check type with attribute at beginn of type
+gdb_breakpoint [gdb_get_line_number "threev-filled"]
+gdb_continue_to_breakpoint "threev-filled"
+gdb_test "print threev%ivla(1)" " = 1"
+gdb_test "print threev%ivla(5)" " = 42"
+gdb_test "print threev%ivla(14)" " = 24"
+gdb_test "print threev%ivar" " = 3"
+gdb_test "ptype threev" \
+ [multi_line "type = Type three" \
+ "\\s+$int :: ivar" \
+ "\\s+$int :: ivla\\\(20\\\)" \
+ "End Type three" ]
+
+# Check type with attribute at end of type
+gdb_breakpoint [gdb_get_line_number "fourv-filled"]
+gdb_continue_to_breakpoint "fourv-filled"
+gdb_test "print fourv%ivla(1)" " = 1"
+gdb_test "print fourv%ivla(2)" " = 2"
+gdb_test "print fourv%ivla(7)" " = 7"
+gdb_test "print fourv%ivla(12)" "no such vector element"
+gdb_test "print fourv%ivar" " = 3"
+gdb_test "ptype fourv" \
+ [multi_line "type = Type four" \
+ "\\s+$int :: ivla\\\(10\\\)" \
+ "\\s+$int :: ivar" \
+ "End Type four" ]
+
+# Check nested types containing a VLA
+gdb_breakpoint [gdb_get_line_number "fivev-filled"]
+gdb_continue_to_breakpoint "fivev-filled"
+gdb_test "print fivev%tone%ivla(5, 5, 1)" " = 1"
+gdb_test "print fivev%tone%ivla(1, 2, 3)" " = 123"
+gdb_test "print fivev%tone%ivla(3, 2, 1)" " = 321"
+gdb_test "ptype fivev" \
+ [multi_line "type = Type five" \
+ "\\s+Type one" \
+ "\\s+$int :: ivla\\\(10,10,10\\\)" \
+ "\\s+End Type one :: tone" \
+ "End Type five" ]
diff --git a/gdb/testsuite/gdb.fortran/vla-type.f90 b/gdb/testsuite/gdb.fortran/vla-type.f90
new file mode 100755
index 0000000..a106617
--- /dev/null
+++ b/gdb/testsuite/gdb.fortran/vla-type.f90
@@ -0,0 +1,88 @@
+! Copyright 2016 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 vla_struct
+ type :: one
+ integer, allocatable :: ivla (:, :, :)
+ end type one
+ type :: two
+ integer, allocatable :: ivla1 (:, :, :)
+ integer, allocatable :: ivla2 (:, :)
+ end type two
+ type :: three
+ integer :: ivar
+ integer, allocatable :: ivla (:)
+ end type three
+ type :: four
+ integer, allocatable :: ivla (:)
+ integer :: ivar
+ end type four
+ type :: five
+ type(one) :: tone
+ end type five
+
+ type(one), target :: onev
+ type(two) :: twov
+ type(three) :: threev
+ type(four) :: fourv
+ type(five) :: fivev
+ logical :: l
+ integer :: i, j
+
+ allocate (onev%ivla (11,22,33)) ! before-allocated
+ l = allocated(onev%ivla)
+
+ onev%ivla(:, :, :) = 1
+ onev%ivla(1, 2, 3) = 123
+ onev%ivla(3, 2, 1) = 321
+
+ allocate (twov%ivla1 (5,12,99)) ! onev-filled
+ l = allocated(twov%ivla1)
+ allocate (twov%ivla2 (9,12))
+ l = allocated(twov%ivla2)
+
+ twov%ivla1(:, :, :) = 1
+ twov%ivla1(1, 2, 3) = 123
+ twov%ivla1(3, 2, 1) = 321
+
+ twov%ivla2(:, :) = 1
+ twov%ivla2(1, 2) = 12
+ twov%ivla2(2, 1) = 21
+
+ threev%ivar = 3 ! twov-filled
+ allocate (threev%ivla (20))
+ l = allocated(threev%ivla)
+
+ threev%ivla(:) = 1
+ threev%ivla(5) = 42
+ threev%ivla(14) = 24
+
+ allocate (fourv%ivla (10)) ! threev-filled
+ l = allocated(fourv%ivla)
+
+ fourv%ivar = 3
+ fourv%ivla(:) = 1
+ fourv%ivla(2) = 2
+ fourv%ivla(7) = 7
+
+ allocate (fivev%tone%ivla (10, 10, 10)) ! fourv-filled
+ l = allocated(fivev%tone%ivla)
+ fivev%tone%ivla(:, :, :) = 1
+ fivev%tone%ivla(1, 2, 3) = 123
+ fivev%tone%ivla(3, 2, 1) = 321
+
+ ! dummy statement for bp
+ l = allocated(fivev%tone%ivla) ! fivev-filled
+end program vla_struct