1# Copyright 2015-2023 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" 17load_lib fortran.exp 18 19if {[skip_fortran_tests]} { return -1 } 20 21if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} \ 22 {debug f90 quiet}] } { 23 return -1 24} 25 26if ![fortran_runto_main] { 27 return -1 28} 29 30# Check the values of VLA's in subroutine can be evaluated correctly 31 32gdb_test_no_output "set print repeats unlimited" 33 34# Try to access values from a fixed array handled as VLA in subroutine. 35gdb_breakpoint [gdb_get_line_number "not-filled"] 36gdb_continue_to_breakpoint "not-filled (1st)" 37gdb_test "print array1" " = \\(\[()1, .\]*\\)" \ 38 "print passed array1 in foo (passed fixed array)" 39 40gdb_breakpoint [gdb_get_line_number "array1-filled"] 41gdb_continue_to_breakpoint "array1-filled (1st)" 42gdb_test "print array1(5, 7)" " = 5" \ 43 "print array1(5, 7) after filled in foo (passed fixed array)" 44gdb_test "print array1(1, 1)" " = 30" \ 45 "print array1(1, 1) after filled in foo (passed fixed array)" 46 47gdb_breakpoint [gdb_get_line_number "array2-almost-filled"] 48gdb_continue_to_breakpoint "array2-almost-filled (1st)" 49# array2 size is 296352 bytes. 50gdb_test_no_output "set max-value-size 1024*1024" 51gdb_test "print array2" " = \\( *\\( *\\( *30, *3, *3,\[()3, .\]*\\)" \ 52 "print array2 in foo after it was filled (passed fixed array)" 53gdb_test "print array2(2,1,1)=20" " = 20" \ 54 "set array(2,2,2) to 20 in subroutine (passed fixed array)" 55gdb_test "print array2" " = \\( *\\( *\\( *30, *20, *3,\[()3, .\]*\\)" \ 56 "print array2 in foo after it was mofified in debugger (passed fixed array)" 57 58 59# Try to access values from a fixed sub-array handled as VLA in subroutine. 60gdb_continue_to_breakpoint "not-filled (2nd)" 61gdb_test "print array1" " = \\(\[()5, .\]*\\)" \ 62 "print passed array1 in foo (passed sub-array)" 63 64gdb_continue_to_breakpoint "array1-filled (2nd)" 65gdb_test "print array1(5, 5)" " = 5" \ 66 "print array1(5, 5) after filled in foo (passed sub-array)" 67gdb_test "print array1(1, 1)" " = 30" \ 68 "print array1(1, 1) after filled in foo (passed sub-array)" 69 70gdb_continue_to_breakpoint "array2-almost-filled (2nd)" 71gdb_test "print array2" " = \\( *\\( *\\( *30, *3, *3,\[()3, .\]*\\)" \ 72 "print array2 in foo after it was filled (passed sub-array)" 73gdb_test "print array2(2,1,1)=20" " = 20" \ 74 "set array(2,2,2) to 20 in subroutine (passed sub-array)" 75gdb_test "print array2" " = \\( *\\( *\\( *30, *20, *3,\[()3, .\]*\\)" \ 76 "print array2 in foo after it was mofified in debugger (passed sub-array)" 77 78 79# Try to access values from a VLA passed to subroutine. 80gdb_continue_to_breakpoint "not-filled (3rd)" 81gdb_test "print array1" " = \\(\[()42, .\]*\\)" \ 82 "print passed array1 in foo (passed vla)" 83 84gdb_continue_to_breakpoint "array1-filled (3rd)" 85gdb_test "print array1(5, 5)" " = 5" \ 86 "print array1(5, 5) after filled in foo (passed vla)" 87gdb_test "print array1(1, 1)" " = 30" \ 88 "print array1(1, 1) after filled in foo (passed vla)" 89 90gdb_continue_to_breakpoint "array2-almost-filled (3rd)" 91gdb_test "print array2" " = \\( *\\( *\\( *30, *3, *3,\[()3, .\]*\\)" \ 92 "print array2 in foo after it was filled (passed vla)" 93gdb_test "print array2(2,1,1)=20" " = 20" \ 94 "set array(2,2,2) to 20 in subroutine (passed vla)" 95gdb_test "print array2" " = \\( *\\( *\\( *30, *20, *3,\[()3, .\]*\\)" \ 96 "print array2 in foo after it was mofified in debugger (passed vla)" 97