]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - gdb/testsuite/gdb.base/solib-weak.exp
Update copyright year range in all GDB files
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.base / solib-weak.exp
CommitLineData
e2882c85 1# Copyright 2006-2018 Free Software Foundation, Inc.
08232497
DJ
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
e22f8b7c 5# the Free Software Foundation; either version 3 of the License, or
08232497 6# (at your option) any later version.
e22f8b7c 7#
08232497
DJ
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.
e22f8b7c 12#
08232497 13# You should have received a copy of the GNU General Public License
e22f8b7c 14# along with this program. If not, see <http://www.gnu.org/licenses/>.
08232497
DJ
15
16# Test setting breakpoints on shared library functions provided by more
17# than one shared library, when one of the implementations is a "weak"
18# symbol. GDB should set a breakpoint at the first copy it finds.
19
93f02886
DJ
20if {[skip_shlib_tests]} {
21 return 0
22}
23
24# These targets have shared libraries, but weak symbols are not meaningful.
25if {([istarget arm*-*-symbianelf*]
26 || [istarget *-*-mingw*]
27 || [istarget *-*-cygwin*]
28 || [istarget *-*-pe*])} {
08232497
DJ
29 return 0
30}
31
32# This test uses GCC-specific syntax.
4c93b1db 33if [get_compiler_info] {
08232497
DJ
34 return -1
35}
36
37if {![test_compiler_info "gcc-*"]} {
38 return 0
39}
40
41proc do_test { lib1opts lib2opts lib1first } {
0ab77f5f 42 global srcdir subdir
08232497 43
40b53987
DJ
44 set testfile "solib-weak"
45 set srcfile ${testfile}.c
46
47 set libfile1 "weaklib1"
48 set libfile2 "weaklib2"
49 set lib1src ${srcdir}/${subdir}/${libfile1}.c
50 set lib2src ${srcdir}/${subdir}/${libfile2}.c
51
52 # Select a unique name for this test. Give each library and
53 # executable a name reflecting its options, so that file caching
54 # on the target system does not pick up the wrong file.
08232497
DJ
55 set testopts ""
56 if {$lib1opts == ""} {
57 append testopts "lib1 nodebug, "
58 } else {
59 append testopts "lib1 debug, "
40b53987 60 append lib1 "-dbg"
08232497
DJ
61 }
62 if {$lib2opts == ""} {
63 append testopts "lib2 nodebug, "
64 } else {
65 append testopts "lib2 debug, "
40b53987 66 append lib2 "-dbg"
08232497
DJ
67 }
68 if {$lib1first} {
69 append testopts "lib1 first"
70 } else {
71 append testopts "lib2 first"
40b53987 72 append testfile "-lib2"
08232497
DJ
73 }
74
0ab77f5f
TT
75 set binfile [standard_output_file ${testfile}]
76 set lib1 [standard_output_file ${libfile1}.sl]
77 set lib2 [standard_output_file ${libfile2}.sl]
08232497
DJ
78
79 if $lib1first {
80 set exec_opts [list debug shlib=${lib1} shlib=${lib2}]
81 set expected_file ${libfile1}
82 } else {
83 set exec_opts [list debug shlib=${lib2} shlib=${lib1}]
84 set expected_file ${libfile2}
85 }
86
87 if { [gdb_compile_shlib ${lib1src} ${lib1} ${lib1opts}] != ""
88 || [gdb_compile_shlib ${lib2src} ${lib2} ${lib2opts}] != ""
89 || [gdb_compile "${srcdir}/${subdir}/${srcfile}" ${binfile} executable $exec_opts] != ""} {
90 return -1
91 }
92
93 gdb_exit
94 gdb_start
95 gdb_reinitialize_dir $srcdir/$subdir
96 gdb_load ${binfile}
d9019901
SM
97 gdb_load_shlib $lib1
98 gdb_load_shlib $lib2
08232497
DJ
99
100 runto_main
101
102 gdb_breakpoint "bar"
103
176400c3 104 gdb_test "continue" "Breakpoint .* \\.?bar .*${expected_file}\\..*" \
08232497
DJ
105 "run to breakpoint - $testopts"
106}
107
108foreach lib1opts {{} {debug}} {
109 foreach lib2opts {{} {debug}} {
110 foreach lib1first {1 0} {
111 do_test $lib1opts $lib2opts $lib1first
112 }
113 }
114}