1 # Copyright 2016-2019 Free Software Foundation, Inc.
\r
3 # This program is free software; you can redistribute it and/or modify
\r
4 # it under the terms of the GNU General Public License as published by
\r
5 # the Free Software Foundation; either version 3 of the License, or
\r
6 # (at your option) any later version.
\r
8 # This program is distributed in the hope that it will be useful,
\r
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
\r
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
\r
11 # GNU General Public License for more details.
\r
13 # You should have received a copy of the GNU General Public License
\r
14 # along with this program. If not, see <http://www.gnu.org/licenses/>.
\r
16 # This testcase is supposed to test DWARF static link which is usually
\r
17 # used together with nested functions.
\r
19 if { [skip_fortran_tests] } { return -1 }
\r
21 standard_testfile .f90
\r
22 load_lib "fortran.exp"
\r
24 if {[prepare_for_testing "failed to prepare" $testfile $srcfile {debug f90}]} {
\r
28 if ![runto MAIN__] then {
\r
29 perror "couldn't run to breakpoint MAIN__"
\r
33 # Test if we can access local and
\r
34 # non-local variables defined one level up.
\r
35 gdb_breakpoint [gdb_get_line_number "! BP_outer"]
\r
36 gdb_continue_to_breakpoint "! BP_outer" ".*! BP_outer"
\r
37 gdb_test "print index" "= 13" "print index at BP_outer"
\r
38 gdb_test_no_output "set variable index = 42"
\r
39 gdb_test "print index" "= 42" "print index at BP_outer, manipulated"
\r
40 gdb_test "print local_int" "= 19" "print local_int in outer function"
\r
42 # Non-local variable should be affected in one frame up as well.
\r
44 gdb_test "print index" "= 42" "print index at BP1, one frame up"
\r
46 # Test if we can access local and
\r
47 # non-local variables defined two level up.
\r
48 gdb_breakpoint [gdb_get_line_number "! BP_inner"]
\r
49 gdb_continue_to_breakpoint "! BP_inner" ".*! BP_inner"
\r
50 gdb_test "print index" "= 42" "print index at BP_inner"
\r
51 gdb_test "print v_state%code" "= 61" "print v_state%code at BP_inner"
\r
52 gdb_test "print local_int" "= 17" "print local_int in inner function"
\r
54 # Test if local variable is still correct.
\r
55 gdb_breakpoint [gdb_get_line_number "! BP_outer_2"]
\r
56 gdb_continue_to_breakpoint "! BP_outer_2" ".*! BP_outer_2"
\r
57 gdb_test "print local_int" "= 19" \
\r
58 "print local_int in outer function, after sub_nested_inner"
\r
60 # Sanity check in main.
\r
61 gdb_breakpoint [gdb_get_line_number "! BP_main"]
\r
62 gdb_continue_to_breakpoint "! BP_main" ".*! BP_main"
\r
63 gdb_test "print index" "= 42" "print index at BP_main"
\r
64 gdb_test "print v_state%code" "= 59" "print v_state%code at BP_main"
\r