xref: /netbsd-src/external/gpl3/gdb.old/dist/gdb/testsuite/gdb.fortran/block-data.exp (revision 2dd295436a0082eb4f8d294f4aa73c223413d0f2)
1# Copyright 2016-2020 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
24if { [skip_fortran_tests] } { return -1 }
25
26standard_testfile .f
27load_lib "fortran.exp"
28
29if {[prepare_for_testing $testfile.exp $testfile $srcfile {debug f90}]} {
30    return -1
31}
32
33if ![fortran_runto_main] then {
34    untested "couldn't run to main"
35    return -1
36}
37
38with_test_prefix "default values" {
39    gdb_test "print doub1" "= 1\.11\\d+"
40    gdb_test "print doub2" "= 2\.22\\d+"
41    gdb_test "print char1" "= 'abcdef'"
42    gdb_test "print char2" "= 'ghijkl'"
43}
44
45gdb_breakpoint [gdb_get_line_number "! BP_BEFORE_SUB"]
46gdb_continue_to_breakpoint "! BP_BEFORE_SUB" ".*! BP_BEFORE_SUB.*"
47
48with_test_prefix "before sub" {
49    gdb_test "print doub1" "= 11\.11\\d+"
50    gdb_test "print doub2" "= 22\.22\\d+"
51    gdb_test "print char1" "= 'ABCDEF'"
52    gdb_test "print char2" "= 'GHIJKL'"
53}
54
55gdb_breakpoint [gdb_get_line_number "! BP_SUB"]
56gdb_continue_to_breakpoint "! BP_SUB" ".*! BP_SUB.*"
57
58with_test_prefix "in sub" {
59    gdb_test "print doub1" "= 11\.11\\d+"
60    gdb_test "print doub2" "= 22\.22\\d+"
61    gdb_test "print char1" "= 'ABCDEF'"
62    gdb_test "print char2" "= 'GHIJKL'"
63}
64