]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blobdiff - gdb/testsuite/gdb.fortran/nested-funcs.exp
Fortran: Testsuite, non-local references in nested functions.
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.fortran / nested-funcs.exp
diff --git a/gdb/testsuite/gdb.fortran/nested-funcs.exp b/gdb/testsuite/gdb.fortran/nested-funcs.exp
new file mode 100755 (executable)
index 0000000..976aa22
--- /dev/null
@@ -0,0 +1,64 @@
+# Copyright 2016 Free Software Foundation, Inc.\r
+\r
+# This program is free software; you can redistribute it and/or modify\r
+# it under the terms of the GNU General Public License as published by\r
+# the Free Software Foundation; either version 3 of the License, or\r
+# (at your option) any later version.\r
+#\r
+# This program is distributed in the hope that it will be useful,\r
+# but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
+# GNU General Public License for more details.\r
+#\r
+# You should have received a copy of the GNU General Public License\r
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.\r
+\r
+# This testcase is supposed to test DWARF static link which is usually\r
+# used together with nested functions.  \r
+\r
+if { [skip_fortran_tests] } { return -1 }\r
+\r
+standard_testfile .f90\r
+load_lib "fortran.exp"\r
+\r
+if {[prepare_for_testing $testfile.exp $testfile $srcfile {debug f90}]} {\r
+    return -1\r
+}\r
+\r
+if ![runto MAIN__] then {\r
+    perror "couldn't run to breakpoint MAIN__"\r
+    continue\r
+}\r
+\r
+# Test if we can access local and\r
+# non-local variables defined one level up.\r
+gdb_breakpoint [gdb_get_line_number "! BP_outer"]\r
+gdb_continue_to_breakpoint "! BP_outer" ".*! BP_outer"\r
+gdb_test "print index" "= 13" "print index at BP_outer"\r
+gdb_test "set index = 42"\r
+gdb_test "print index" "= 42" "print index at BP_outer, manipulated"\r
+gdb_test "print local_int" "= 19" "print local_int in outer function"\r
+\r
+# Non-local variable should be affected in one frame up as well.\r
+gdb_test "up"\r
+gdb_test "print index" "= 42" "print index at BP1, one frame up"\r
+\r
+# Test if we can access local and\r
+# non-local variables defined two level up.\r
+gdb_breakpoint [gdb_get_line_number "! BP_inner"]\r
+gdb_continue_to_breakpoint "! BP_inner" ".*! BP_inner"\r
+gdb_test "print index" "= 42" "print index at BP_inner"\r
+gdb_test "print v_state%code" "= 61" "print v_state%code at BP_inner"\r
+gdb_test "print local_int" "= 17" "print local_int in inner function"\r
+\r
+# Test if local variable is still correct.\r
+gdb_breakpoint [gdb_get_line_number "! BP_outer_2"]\r
+gdb_continue_to_breakpoint "! BP_outer_2" ".*! BP_outer_2"\r
+gdb_test "print local_int" "= 19" \\r
+  "print local_int in outer function, after sub_nested_inner"\r
+\r
+# Sanity check in main.\r
+gdb_breakpoint [gdb_get_line_number "! BP_main"]\r
+gdb_continue_to_breakpoint "! BP_main" ".*! BP_main"\r
+gdb_test "print index" "= 42" "print index at BP_main"\r
+gdb_test "print v_state%code" "= 59" "print v_state%code at BP_main"\r