# Copyright 2023-2025 Free Software Foundation, Inc. # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . # # Test Fortran entry points for subroutines. require allow_fortran_tests standard_testfile .f90 load_lib "fortran.exp" if { [prepare_for_testing $testfile.exp $testfile $srcfile {debug f90}] } { return -1 } if { ![fortran_runto_main] } { untested "could not run to main" return -1 } # Test if we can set a breakpoint via the entry-point name. set entry_point_name "foo" gdb_breakpoint $entry_point_name gdb_continue_to_breakpoint "continue to breakpoint: $entry_point_name" \ ".*entry foo\\(J,K,L,I1\\).*" gdb_test "print j" "= 11" "print j, entered via $entry_point_name" gdb_test "print k" "= 22" "print k, entered via $entry_point_name" gdb_test "print l" "= 33" "print l, entered via $entry_point_name" gdb_test "print i1" "= 44" "print i1, entered via $entry_point_name" gdb_test "info args" \ [multi_line "j = 11" \ "k = 22" \ "l = 33" \ "i1 = 44"] \ "info args, entered via $entry_point_name" # Test if we can set a breakpoint via the function name. set entry_point_name "bar" gdb_breakpoint $entry_point_name gdb_continue_to_breakpoint "continue to breakpoint: $entry_point_name" \ ".*subroutine bar\\(I,J,K,I1\\).*" gdb_test "print i" "= 444" "print i, entered via $entry_point_name" gdb_test "print j" "= 555" "print j, entered via $entry_point_name" gdb_test "print k" "= 666" "print k, entered via $entry_point_name" gdb_test "print i1" "= 777" "print i1, entered via $entry_point_name" # Test a second entry point. set entry_point_name "foobar" gdb_breakpoint $entry_point_name gdb_continue_to_breakpoint "continue to breakpoint: $entry_point_name" \ ".* entry foobar\\(J\\).*" gdb_test "print j" "= 1" "print j, entered via $entry_point_name" gdb_test "info args" "j = 1" "info args, entered via $entry_point_name" # Test breaking at the entrypoint defined inside the module mod via its # scoped name. set entry_point_name "mod::mod_foo" # GCC moves subroutines with entry points out of the module scope into the # compile unit scope. if {[test_compiler_info {gcc-*}] || [test_compiler_info {clang-*}]} { setup_xfail "gcc/105272" "*-*-*" } gdb_breakpoint $entry_point_name if {[test_compiler_info {gcc-*}] || [test_compiler_info {clang-*}]} { setup_xfail "gcc/105272" "*-*-*" } gdb_continue_to_breakpoint "continue to breakpoint: $entry_point_name" \ ".* entry mod_foo\\(\\).*"