gdb/fortran: Nested subroutine support
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.fortran / nested-funcs.exp
CommitLineData
42a4f53d 1# Copyright 2016-2019 Free Software Foundation, Inc.\r
5e13cf25
BH
2\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
7#\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
12#\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
15\r
16# This testcase is supposed to test DWARF static link which is usually\r
17# used together with nested functions. \r
18\r
19if { [skip_fortran_tests] } { return -1 }\r
20\r
21standard_testfile .f90\r
22load_lib "fortran.exp"\r
23\r
5b362f04 24if {[prepare_for_testing "failed to prepare" $testfile $srcfile {debug f90}]} {\r
5e13cf25
BH
25 return -1\r
26}\r
27\r
28if ![runto MAIN__] then {\r
29 perror "couldn't run to breakpoint MAIN__"\r
30 continue\r
31}\r
32\r
0a4b0913
AB
33# Test if we can set a breakpoint in a nested function\r
34gdb_breakpoint "testnestedfuncs::sub_nested_outer"\r
35gdb_continue_to_breakpoint "testnestedfuncs::sub_nested_outer" \\r
36 ".*local_int = 19"\r
37\r
5e13cf25
BH
38# Test if we can access local and\r
39# non-local variables defined one level up.\r
40gdb_breakpoint [gdb_get_line_number "! BP_outer"]\r
41gdb_continue_to_breakpoint "! BP_outer" ".*! BP_outer"\r
42gdb_test "print index" "= 13" "print index at BP_outer"\r
045cf012 43gdb_test_no_output "set variable index = 42"\r
5e13cf25
BH
44gdb_test "print index" "= 42" "print index at BP_outer, manipulated"\r
45gdb_test "print local_int" "= 19" "print local_int in outer function"\r
46\r
47# Non-local variable should be affected in one frame up as well.\r
48gdb_test "up"\r
49gdb_test "print index" "= 42" "print index at BP1, one frame up"\r
50\r
0a4b0913
AB
51# Test if we can set a breakpoint in a nested function\r
52gdb_breakpoint "testnestedfuncs::sub_nested_inner"\r
53gdb_continue_to_breakpoint "testnestedfuncs::sub_nested_inner" \\r
54 ".*local_int = 17"\r
55\r
5e13cf25
BH
56# Test if we can access local and\r
57# non-local variables defined two level up.\r
58gdb_breakpoint [gdb_get_line_number "! BP_inner"]\r
59gdb_continue_to_breakpoint "! BP_inner" ".*! BP_inner"\r
60gdb_test "print index" "= 42" "print index at BP_inner"\r
61gdb_test "print v_state%code" "= 61" "print v_state%code at BP_inner"\r
62gdb_test "print local_int" "= 17" "print local_int in inner function"\r
63\r
64# Test if local variable is still correct.\r
65gdb_breakpoint [gdb_get_line_number "! BP_outer_2"]\r
66gdb_continue_to_breakpoint "! BP_outer_2" ".*! BP_outer_2"\r
67gdb_test "print local_int" "= 19" \\r
68 "print local_int in outer function, after sub_nested_inner"\r
69\r
0a4b0913
AB
70# Test if we can set a breakpoint in public routine with the same name\r
71# as the internal\r
72gdb_breakpoint "sub_nested_outer"\r
73gdb_continue_to_breakpoint "sub_nested_outer" \\r
74 ".*name = 'sub_nested_outer external'"\r
75\r
76# Test if we can set a breakpoint in public routine with the same name\r
77# as the internal\r
78gdb_breakpoint "sub_with_sub_nested_outer::sub_nested_outer"\r
79gdb_continue_to_breakpoint \\r
80 "sub_with_sub_nested_outer::sub_nested_outer" ".*local_int = 11"\r
81\r
82# Test if we can set a breakpoint in public routine with the same name\r
83# as the internal\r
84gdb_breakpoint "mod1::sub_nested_outer"\r
85gdb_continue_to_breakpoint "mod1::sub_nested_outer" \\r
86 ".*name = 'sub_nested_outer_mod1'"\r
87\r
5e13cf25
BH
88# Sanity check in main.\r
89gdb_breakpoint [gdb_get_line_number "! BP_main"]\r
90gdb_continue_to_breakpoint "! BP_main" ".*! BP_main"\r
91gdb_test "print index" "= 42" "print index at BP_main"\r
92gdb_test "print v_state%code" "= 59" "print v_state%code at BP_main"\r
This page took 0.552529 seconds and 4 git commands to generate.