1 # Copyright
2016-2021 Free Software Foundation
, Inc.
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.
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.
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
/>.
16 # This testcase is supposed to test DWARF static link which is usually
17 # used together with nested functions.
19 if { [skip_fortran_tests
] } { return -1 }
21 standard_testfile .f90
22 load_lib
"fortran.exp"
24 if {[prepare_for_testing
"failed to prepare" $testfile $srcfile {debug f90}]} {
28 if ![fortran_runto_main
] then {
29 perror
"couldn't run to main"
33 # Test
if we can
set a breakpoint in a nested function
34 gdb_breakpoint
"testnestedfuncs::sub_nested_outer"
35 gdb_continue_to_breakpoint
"testnestedfuncs::sub_nested_outer" \
38 # Test
if we can access local and
39 # non
-local variables defined one level up.
40 gdb_breakpoint
[gdb_get_line_number
"! BP_outer"]
41 gdb_continue_to_breakpoint
"! BP_outer" ".*! BP_outer"
42 gdb_test
"print index" "= 13" "print index at BP_outer"
43 gdb_test_no_output
"set variable index = 42"
44 gdb_test
"print index" "= 42" "print index at BP_outer, manipulated"
45 gdb_test
"print local_int" "= 19" "print local_int in outer function"
47 # Non
-local
variable should be affected in one frame up as well.
49 gdb_test
"print index" "= 42" "print index at BP1, one frame up"
51 # Test
if we can
set a breakpoint in a nested function
52 gdb_breakpoint
"testnestedfuncs::sub_nested_inner"
53 gdb_continue_to_breakpoint
"testnestedfuncs::sub_nested_inner" \
56 # Test
if we can access local and
57 # non
-local variables defined two level up.
58 gdb_breakpoint
[gdb_get_line_number
"! BP_inner"]
59 gdb_continue_to_breakpoint
"! BP_inner" ".*! BP_inner"
60 gdb_test
"print index" "= 42" "print index at BP_inner"
61 gdb_test
"print v_state%code" "= 61" "print v_state%code at BP_inner"
62 gdb_test
"print local_int" "= 17" "print local_int in inner function"
64 # Test
if local
variable is still correct.
65 gdb_breakpoint
[gdb_get_line_number
"! BP_outer_2"]
66 gdb_continue_to_breakpoint
"! BP_outer_2" ".*! BP_outer_2"
67 gdb_test
"print local_int" "= 19" \
68 "print local_int in outer function, after sub_nested_inner"
70 # Test
if we can
set a breakpoint in public routine with the same
name
72 gdb_breakpoint
"sub_nested_outer"
73 gdb_continue_to_breakpoint
"sub_nested_outer" \
74 ".*name = 'sub_nested_outer external'"
76 # Test
if we can
set a breakpoint in public routine with the same
name
78 gdb_breakpoint
"sub_with_sub_nested_outer::sub_nested_outer"
79 gdb_continue_to_breakpoint \
80 "sub_with_sub_nested_outer::sub_nested_outer" ".*local_int = 11"
82 # Test
if we can
set a breakpoint in public routine with the same
name
84 gdb_breakpoint
"mod1::sub_nested_outer"
85 gdb_continue_to_breakpoint
"mod1::sub_nested_outer" \
86 ".*name = 'sub_nested_outer_mod1'"
88 # Sanity check in main.
89 gdb_breakpoint
[gdb_get_line_number
"! BP_main"]
90 gdb_continue_to_breakpoint
"! BP_main" ".*! BP_main"
91 gdb_test
"print index" "= 42" "print index at BP_main"
92 gdb_test
"print v_state%code" "= 59" "print v_state%code at BP_main"