xref: /netbsd-src/external/gpl3/gdb.old/dist/gdb/testsuite/gdb.fortran/vla-value-sub.exp (revision c38e7cc395b1472a774ff828e46123de44c628e9)
1# Copyright 2015-2016 Free Software Foundation, Inc.
2
3# This program is free software; you can redistribute it and/or modify
4# it under the terms of the GNU General Public License as published by
5# the Free Software Foundation; either version 3 of the License, or
6# (at your option) any later version.
7#
8# This program is distributed in the hope that it will be useful,
9# but WITHOUT ANY WARRANTY; without even the implied warranty of
10# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11# GNU General Public License for more details.
12#
13# You should have received a copy of the GNU General Public License
14# along with this program.  If not, see <http://www.gnu.org/licenses/>.
15
16standard_testfile "vla-sub.f90"
17
18if { [prepare_for_testing ${testfile}.exp ${testfile} ${srcfile} \
19    {debug f90 quiet}] } {
20    return -1
21}
22
23if ![runto_main] {
24    untested "could not run to main"
25    return -1
26}
27
28# Check the values of VLA's in subroutine can be evaluated correctly
29
30# Try to access values from a fixed array handled as VLA in subroutine.
31gdb_breakpoint [gdb_get_line_number "not-filled"]
32gdb_continue_to_breakpoint "not-filled (1st)"
33gdb_test "print array1" " = \\(\[()1, .\]*\\)" \
34  "print passed array1 in foo (passed fixed array)"
35
36gdb_breakpoint [gdb_get_line_number "array1-filled"]
37gdb_continue_to_breakpoint "array1-filled (1st)"
38gdb_test "print array1(5, 7)" " = 5" \
39  "print array1(5, 7) after filled in foo (passed fixed array)"
40gdb_test "print array1(1, 1)" " = 30" \
41  "print array1(1, 1) after filled in foo (passed fixed array)"
42
43gdb_breakpoint [gdb_get_line_number "array2-almost-filled"]
44gdb_continue_to_breakpoint "array2-almost-filled (1st)"
45# array2 size is 296352 bytes.
46gdb_test_no_output "set max-value-size 1024*1024"
47gdb_test "print array2" " = \\( *\\( *\\( *30, *3, *3,\[()3, .\]*\\)" \
48  "print array2 in foo after it was filled (passed fixed array)"
49gdb_test "print array2(2,1,1)=20" " = 20" \
50  "set array(2,2,2) to 20 in subroutine (passed fixed array)"
51gdb_test "print array2" " = \\( *\\( *\\( *30, *20, *3,\[()3, .\]*\\)" \
52  "print array2 in foo after it was mofified in debugger (passed fixed array)"
53
54
55# Try to access values from a fixed sub-array handled as VLA in subroutine.
56gdb_continue_to_breakpoint "not-filled (2nd)"
57gdb_test "print array1" " = \\(\[()5, .\]*\\)" \
58  "print passed array1 in foo (passed sub-array)"
59
60gdb_continue_to_breakpoint "array1-filled (2nd)"
61gdb_test "print array1(5, 5)" " = 5" \
62  "print array1(5, 5) after filled in foo (passed sub-array)"
63gdb_test "print array1(1, 1)" " = 30" \
64  "print array1(1, 1) after filled in foo (passed sub-array)"
65
66gdb_continue_to_breakpoint "array2-almost-filled (2nd)"
67gdb_test "print array2" " = \\( *\\( *\\( *30, *3, *3,\[()3, .\]*\\)" \
68  "print array2 in foo after it was filled (passed sub-array)"
69gdb_test "print array2(2,1,1)=20" " = 20" \
70  "set array(2,2,2) to 20 in subroutine (passed sub-array)"
71gdb_test "print array2" " = \\( *\\( *\\( *30, *20, *3,\[()3, .\]*\\)" \
72  "print array2 in foo after it was mofified in debugger (passed sub-array)"
73
74
75# Try to access values from a VLA passed to subroutine.
76gdb_continue_to_breakpoint "not-filled (3rd)"
77gdb_test "print array1" " = \\(\[()42, .\]*\\)" \
78  "print passed array1 in foo (passed vla)"
79
80gdb_continue_to_breakpoint "array1-filled (3rd)"
81gdb_test "print array1(5, 5)" " = 5" \
82  "print array1(5, 5) after filled in foo (passed vla)"
83gdb_test "print array1(1, 1)" " = 30" \
84  "print array1(1, 1) after filled in foo (passed vla)"
85
86gdb_continue_to_breakpoint "array2-almost-filled (3rd)"
87gdb_test "print array2" " = \\( *\\( *\\( *30, *3, *3,\[()3, .\]*\\)" \
88  "print array2 in foo after it was filled (passed vla)"
89gdb_test "print array2(2,1,1)=20" " = 20" \
90  "set array(2,2,2) to 20 in subroutine (passed vla)"
91gdb_test "print array2" " = \\( *\\( *\\( *30, *20, *3,\[()3, .\]*\\)" \
92  "print array2 in foo after it was mofified in debugger (passed vla)"
93