xref: /netbsd-src/external/gpl3/gdb.old/dist/gdb/testsuite/gdb.fortran/library-module.exp (revision 8b657b0747480f8989760d71343d6dd33f8d4cf9)
1# Copyright 2010-2023 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
16load_lib fortran.exp
17
18if {[skip_fortran_tests]} { return -1 }
19
20standard_testfile library-module-main.f90
21set srclibfile ${testfile}-lib.f90
22set libfile [standard_output_file ${testfile}-lib.so]
23
24if  { [gdb_compile_shlib "${srcdir}/${subdir}/${srclibfile}" $libfile {debug f90}] != "" } {
25    untested "failed to compile shared library"
26    return -1
27}
28
29# prepare_for_testing cannot be used as linking with $libfile cannot be passed
30# just for the linking phase (and not the source compilation phase).  And any
31# warnings on ignored $libfile abort the process.
32
33if  { [gdb_compile $srcdir/$subdir/$srcfile $binfile executable [list debug f90 shlib=$libfile]] != "" } {
34    untested "failed to compile"
35    return -1
36}
37
38clean_restart $testfile
39
40gdb_load_shlib $libfile
41
42if {![fortran_runto_main]} {
43    return
44}
45
46gdb_breakpoint $srclibfile:[gdb_get_line_number "i-is-2-in-lib" $srclibfile]
47gdb_continue_to_breakpoint "i-is-2-in-lib" ".*i-is-2-in-lib.*"
48gdb_test "print var_i" " = 2" "print var_i in lib"
49
50gdb_breakpoint $srcfile:[gdb_get_line_number "i-is-2-in-main" $srcfile]
51gdb_continue_to_breakpoint "i-is-2-in-main" ".*i-is-2-in-main.*"
52gdb_test "print var_i" " = 2" "print var_i in main"
53
54gdb_test "print var_j" " = 3"
55gdb_test "print var_k" "No symbol \"var_k\" in current context\\."
56