Commit | Line | Data |
---|---|---|
32d0add0 | 1 | # Copyright 2010-2015 Free Software Foundation, Inc. |
f55ee35c JK |
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 | ||
cf09b3e4 | 16 | standard_testfile library-module-main.f90 |
f55ee35c | 17 | set srclibfile ${testfile}-lib.f90 |
cf09b3e4 | 18 | set libfile [standard_output_file ${testfile}-lib.so] |
f55ee35c JK |
19 | |
20 | # Required for -fPIC by gdb_compile_shlib. | |
4c93b1db | 21 | if [get_compiler_info] { |
f55ee35c JK |
22 | warning "Could not get compiler info" |
23 | return -1 | |
24 | } | |
25 | ||
cf09b3e4 | 26 | if { [gdb_compile_shlib "${srcdir}/${subdir}/${srclibfile}" $libfile {debug f90}] != "" } { |
f55ee35c JK |
27 | untested "Couldn't compile ${srclibfile}" |
28 | return -1 | |
29 | } | |
30 | ||
31 | # prepare_for_testing cannot be used as linking with $libfile cannot be passed | |
32 | # just for the linking phase (and not the source compilation phase). And any | |
33 | # warnings on ignored $libfile abort the process. | |
34 | ||
cf09b3e4 | 35 | if { [gdb_compile $srcdir/$subdir/$srcfile $binfile executable [list debug f90 shlib=$libfile]] != "" } { |
f55ee35c JK |
36 | untested "Couldn't compile ${srcfile}" |
37 | return -1 | |
38 | } | |
39 | ||
cf09b3e4 | 40 | clean_restart $testfile |
f55ee35c | 41 | |
cf09b3e4 | 42 | gdb_load_shlibs $libfile |
4255c8d2 | 43 | |
f55ee35c JK |
44 | if ![runto MAIN__] then { |
45 | perror "couldn't run to breakpoint MAIN__" | |
46 | continue | |
47 | } | |
48 | ||
49 | gdb_breakpoint $srclibfile:[gdb_get_line_number "i-is-2-in-lib" $srclibfile] | |
50 | gdb_continue_to_breakpoint "i-is-2-in-lib" ".*i-is-2-in-lib.*" | |
51 | gdb_test "print var_i" " = 2" "print var_i in lib" | |
52 | ||
53 | gdb_breakpoint $srcfile:[gdb_get_line_number "i-is-2-in-main" $srcfile] | |
54 | gdb_continue_to_breakpoint "i-is-2-in-main" ".*i-is-2-in-main.*" | |
55 | gdb_test "print var_i" " = 2" "print var_i in main" | |
56 | ||
57 | gdb_test "print var_j" " = 3" | |
58 | gdb_test "print var_k" "No symbol \"var_k\" in current context\\." |