1# Copyright 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 16# This testcase is supposed to test DWARF static link which is usually 17# used together with nested functions. 18 19if { [skip_fortran_tests] } { return -1 } 20 21standard_testfile .f90 22load_lib "fortran.exp" 23 24if {[prepare_for_testing $testfile.exp $testfile $srcfile {debug f90}]} { 25 return -1 26} 27 28if ![runto MAIN__] then { 29 perror "couldn't run to breakpoint MAIN__" 30 continue 31} 32 33# Test if we can access local and 34# non-local variables defined one level up. 35gdb_breakpoint [gdb_get_line_number "! BP_outer"] 36gdb_continue_to_breakpoint "! BP_outer" ".*! BP_outer" 37gdb_test "print index" "= 13" "print index at BP_outer" 38gdb_test "set index = 42" 39gdb_test "print index" "= 42" "print index at BP_outer, manipulated" 40gdb_test "print local_int" "= 19" "print local_int in outer function" 41 42# Non-local variable should be affected in one frame up as well. 43gdb_test "up" 44gdb_test "print index" "= 42" "print index at BP1, one frame up" 45 46# Test if we can access local and 47# non-local variables defined two level up. 48gdb_breakpoint [gdb_get_line_number "! BP_inner"] 49gdb_continue_to_breakpoint "! BP_inner" ".*! BP_inner" 50gdb_test "print index" "= 42" "print index at BP_inner" 51gdb_test "print v_state%code" "= 61" "print v_state%code at BP_inner" 52gdb_test "print local_int" "= 17" "print local_int in inner function" 53 54# Test if local variable is still correct. 55gdb_breakpoint [gdb_get_line_number "! BP_outer_2"] 56gdb_continue_to_breakpoint "! BP_outer_2" ".*! BP_outer_2" 57gdb_test "print local_int" "= 19" \ 58 "print local_int in outer function, after sub_nested_inner" 59 60# Sanity check in main. 61gdb_breakpoint [gdb_get_line_number "! BP_main"] 62gdb_continue_to_breakpoint "! BP_main" ".*! BP_main" 63gdb_test "print index" "= 42" "print index at BP_main" 64gdb_test "print v_state%code" "= 59" "print v_state%code at BP_main" 65