Home | History | Annotate | Line # | Download | only in gdb.fortran
      1 # Copyright 2016-2024 Free Software Foundation, Inc.
      2 #
      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.
      7 #
      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.
     12 #
     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/>.
     15 
     16 # Test anonymous block-data statements.
     17 
     18 # A name for BLOCK DATA in Fortran is optional.  BLOCK DATA is used
     19 # for one-time initialization of non-pointer variables in named common
     20 # blocks.  GDB used to crash with 'Intel ifort'-generated code, which
     21 # outputs nameless DW_TAG_module, unlike with gfortran which just
     22 # doesn't emit DW_TAG_module in this case.
     23 
     24 require allow_fortran_tests
     25 
     26 standard_testfile .f
     27 load_lib "fortran.exp"
     28 
     29 if {[prepare_for_testing $testfile.exp $testfile $srcfile {debug f90}]} {
     30     return -1
     31 }
     32 
     33 if {![fortran_runto_main]} {
     34     return -1
     35 }
     36 
     37 with_test_prefix "default values" {
     38     gdb_test "print doub1" "= 1\.11\\d+"
     39     gdb_test "print doub2" "= 2\.22\\d+"
     40     gdb_test "print char1" "= 'abcdef'"
     41     gdb_test "print char2" "= 'ghijkl'"
     42 }
     43 
     44 gdb_breakpoint [gdb_get_line_number "! BP_BEFORE_SUB"]
     45 gdb_continue_to_breakpoint "! BP_BEFORE_SUB" ".*! BP_BEFORE_SUB.*"
     46 
     47 with_test_prefix "before sub" {
     48     gdb_test "print doub1" "= 11\.11\\d+"
     49     gdb_test "print doub2" "= 22\.22\\d+"
     50     gdb_test "print char1" "= 'ABCDEF'"
     51     gdb_test "print char2" "= 'GHIJKL'"
     52 }
     53 
     54 gdb_breakpoint [gdb_get_line_number "! BP_SUB"]
     55 gdb_continue_to_breakpoint "! BP_SUB" ".*! BP_SUB.*"
     56 
     57 with_test_prefix "in sub" {
     58     gdb_test "print doub1" "= 11\.11\\d+"
     59     gdb_test "print doub2" "= 22\.22\\d+"
     60     gdb_test "print char1" "= 'ABCDEF'"
     61     gdb_test "print char2" "= 'GHIJKL'"
     62 }
     63