]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blob - gdb/testsuite/gdb.fortran/vla-value-sub.exp
8ea769f12dfc304e21a0171ea3fbbc0427768813
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.fortran / vla-value-sub.exp
1 # Copyright 2015-2019 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
16 standard_testfile "vla-sub.f90"
17
18 if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} \
19 {debug f90 quiet}] } {
20 return -1
21 }
22
23 if ![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.
31 gdb_breakpoint [gdb_get_line_number "not-filled"]
32 gdb_continue_to_breakpoint "not-filled (1st)"
33 gdb_test "print array1" " = \\(\[()1, .\]*\\)" \
34 "print passed array1 in foo (passed fixed array)"
35
36 gdb_breakpoint [gdb_get_line_number "array1-filled"]
37 gdb_continue_to_breakpoint "array1-filled (1st)"
38 gdb_test "print array1(5, 7)" " = 5" \
39 "print array1(5, 7) after filled in foo (passed fixed array)"
40 gdb_test "print array1(1, 1)" " = 30" \
41 "print array1(1, 1) after filled in foo (passed fixed array)"
42
43 gdb_breakpoint [gdb_get_line_number "array2-almost-filled"]
44 gdb_continue_to_breakpoint "array2-almost-filled (1st)"
45 # array2 size is 296352 bytes.
46 gdb_test_no_output "set max-value-size 1024*1024"
47 gdb_test "print array2" " = \\( *\\( *\\( *30, *3, *3,\[()3, .\]*\\)" \
48 "print array2 in foo after it was filled (passed fixed array)"
49 gdb_test "print array2(2,1,1)=20" " = 20" \
50 "set array(2,2,2) to 20 in subroutine (passed fixed array)"
51 gdb_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.
56 gdb_continue_to_breakpoint "not-filled (2nd)"
57 gdb_test "print array1" " = \\(\[()5, .\]*\\)" \
58 "print passed array1 in foo (passed sub-array)"
59
60 gdb_continue_to_breakpoint "array1-filled (2nd)"
61 gdb_test "print array1(5, 5)" " = 5" \
62 "print array1(5, 5) after filled in foo (passed sub-array)"
63 gdb_test "print array1(1, 1)" " = 30" \
64 "print array1(1, 1) after filled in foo (passed sub-array)"
65
66 gdb_continue_to_breakpoint "array2-almost-filled (2nd)"
67 gdb_test "print array2" " = \\( *\\( *\\( *30, *3, *3,\[()3, .\]*\\)" \
68 "print array2 in foo after it was filled (passed sub-array)"
69 gdb_test "print array2(2,1,1)=20" " = 20" \
70 "set array(2,2,2) to 20 in subroutine (passed sub-array)"
71 gdb_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.
76 gdb_continue_to_breakpoint "not-filled (3rd)"
77 gdb_test "print array1" " = \\(\[()42, .\]*\\)" \
78 "print passed array1 in foo (passed vla)"
79
80 gdb_continue_to_breakpoint "array1-filled (3rd)"
81 gdb_test "print array1(5, 5)" " = 5" \
82 "print array1(5, 5) after filled in foo (passed vla)"
83 gdb_test "print array1(1, 1)" " = 30" \
84 "print array1(1, 1) after filled in foo (passed vla)"
85
86 gdb_continue_to_breakpoint "array2-almost-filled (3rd)"
87 gdb_test "print array2" " = \\( *\\( *\\( *30, *3, *3,\[()3, .\]*\\)" \
88 "print array2 in foo after it was filled (passed vla)"
89 gdb_test "print array2(2,1,1)=20" " = 20" \
90 "set array(2,2,2) to 20 in subroutine (passed vla)"
91 gdb_test "print array2" " = \\( *\\( *\\( *30, *20, *3,\[()3, .\]*\\)" \
92 "print array2 in foo after it was mofified in debugger (passed vla)"