OLD | NEW |
1 # Copyright 2010-2012 Free Software Foundation, Inc. | 1 # Copyright 2010-2012 Free Software Foundation, Inc. |
2 | 2 |
3 # This program is free software; you can redistribute it and/or modify | 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 | 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 | 5 # the Free Software Foundation; either version 3 of the License, or |
6 # (at your option) any later version. | 6 # (at your option) any later version. |
7 # | 7 # |
8 # This program is distributed in the hope that it will be useful, | 8 # This program is distributed in the hope that it will be useful, |
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of | 9 # but WITHOUT ANY WARRANTY; without even the implied warranty of |
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
11 # GNU General Public License for more details. | 11 # GNU General Public License for more details. |
12 # | 12 # |
13 # You should have received a copy of the GNU General Public License | 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/>. | 14 # along with this program. If not, see <http://www.gnu.org/licenses/>. |
15 | 15 |
16 set testfile "library-module" | 16 standard_testfile library-module-main.f90 |
17 set srcfile ${testfile}-main.f90 | |
18 set srclibfile ${testfile}-lib.f90 | 17 set srclibfile ${testfile}-lib.f90 |
19 set libfile ${testfile}-lib.so | 18 set libfile [standard_output_file ${testfile}-lib.so] |
20 set binfile ${testfile} | |
21 | 19 |
22 # Required for -fPIC by gdb_compile_shlib. | 20 # Required for -fPIC by gdb_compile_shlib. |
23 if [get_compiler_info not-used] { | 21 if [get_compiler_info] { |
24 warning "Could not get compiler info" | 22 warning "Could not get compiler info" |
25 return -1 | 23 return -1 |
26 } | 24 } |
27 | 25 |
28 if { [gdb_compile_shlib "${srcdir}/${subdir}/${srclibfile}" $objdir/$subdir/$li
bfile {debug f90}] != "" } { | 26 if { [gdb_compile_shlib "${srcdir}/${subdir}/${srclibfile}" $libfile {debug f90
}] != "" } { |
29 untested "Couldn't compile ${srclibfile}" | 27 untested "Couldn't compile ${srclibfile}" |
30 return -1 | 28 return -1 |
31 } | 29 } |
32 | 30 |
33 # prepare_for_testing cannot be used as linking with $libfile cannot be passed | 31 # prepare_for_testing cannot be used as linking with $libfile cannot be passed |
34 # just for the linking phase (and not the source compilation phase). And any | 32 # just for the linking phase (and not the source compilation phase). And any |
35 # warnings on ignored $libfile abort the process. | 33 # warnings on ignored $libfile abort the process. |
36 | 34 |
37 if { [gdb_compile $srcdir/$subdir/$srcfile $objdir/$subdir/$binfile executable
[list debug f90 shlib=$objdir/$subdir/$libfile]] != "" } { | 35 if { [gdb_compile $srcdir/$subdir/$srcfile $binfile executable [list debug f90
shlib=$libfile]] != "" } { |
38 untested "Couldn't compile ${srcfile}" | 36 untested "Couldn't compile ${srcfile}" |
39 return -1 | 37 return -1 |
40 } | 38 } |
41 | 39 |
42 clean_restart $binfile | 40 clean_restart $testfile |
43 | 41 |
44 gdb_load_shlibs $objdir/$subdir/$libfile | 42 gdb_load_shlibs $libfile |
45 | 43 |
46 if ![runto MAIN__] then { | 44 if ![runto MAIN__] then { |
47 perror "couldn't run to breakpoint MAIN__" | 45 perror "couldn't run to breakpoint MAIN__" |
48 continue | 46 continue |
49 } | 47 } |
50 | 48 |
51 gdb_breakpoint $srclibfile:[gdb_get_line_number "i-is-2-in-lib" $srclibfile] | 49 gdb_breakpoint $srclibfile:[gdb_get_line_number "i-is-2-in-lib" $srclibfile] |
52 gdb_continue_to_breakpoint "i-is-2-in-lib" ".*i-is-2-in-lib.*" | 50 gdb_continue_to_breakpoint "i-is-2-in-lib" ".*i-is-2-in-lib.*" |
53 gdb_test "print var_i" " = 2" "print var_i in lib" | 51 gdb_test "print var_i" " = 2" "print var_i in lib" |
54 | 52 |
55 gdb_breakpoint $srcfile:[gdb_get_line_number "i-is-2-in-main" $srcfile] | 53 gdb_breakpoint $srcfile:[gdb_get_line_number "i-is-2-in-main" $srcfile] |
56 gdb_continue_to_breakpoint "i-is-2-in-main" ".*i-is-2-in-main.*" | 54 gdb_continue_to_breakpoint "i-is-2-in-main" ".*i-is-2-in-main.*" |
57 gdb_test "print var_i" " = 2" "print var_i in main" | 55 gdb_test "print var_i" " = 2" "print var_i in main" |
58 | 56 |
59 gdb_test "print var_j" " = 3" | 57 gdb_test "print var_j" " = 3" |
60 gdb_test "print var_k" "No symbol \"var_k\" in current context\\." | 58 gdb_test "print var_k" "No symbol \"var_k\" in current context\\." |
OLD | NEW |