2 # Free Software Foundation, Inc.
4 # This program is free software; you can redistribute it and/or modify
5 # it under the terms of the GNU General Public License as published by
6 # the Free Software Foundation; either version 2 of the License, or
7 # (at your option) any later version.
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
14 # You should have received a copy of the GNU General Public License
15 # along with this program; if not, write to the Free Software
16 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 # Test setting breakpoints on shared library functions provided by more
19 # than one shared library, when one of the implementations is a "weak"
20 # symbol. GDB should set a breakpoint at the first copy it finds.
22 # Don't try to run shared library test cases on a remote target for now.
27 # This test uses GCC-specific syntax.
28 if [get_compiler_info not-used] {
32 if {![test_compiler_info "gcc-*"]} {
36 proc do_test { lib1opts lib2opts lib1first } {
37 global objdir srcdir subdir
40 if {$lib1opts == ""} {
41 append testopts "lib1 nodebug, "
43 append testopts "lib1 debug, "
45 if {$lib2opts == ""} {
46 append testopts "lib2 nodebug, "
48 append testopts "lib2 debug, "
51 append testopts "lib1 first"
53 append testopts "lib2 first"
56 set testfile "solib-weak"
57 set srcfile ${testfile}.c
58 set binfile ${objdir}/${subdir}/${testfile}
60 set libfile1 "weaklib1"
61 set libfile2 "weaklib2"
62 set lib1src ${srcdir}/${subdir}/${libfile1}.c
63 set lib2src ${srcdir}/${subdir}/${libfile2}.c
64 set lib1 ${objdir}/${subdir}/${libfile1}.sl
65 set lib2 ${objdir}/${subdir}/${libfile2}.sl
68 set exec_opts [list debug shlib=${lib1} shlib=${lib2}]
69 set expected_file ${libfile1}
71 set exec_opts [list debug shlib=${lib2} shlib=${lib1}]
72 set expected_file ${libfile2}
75 if { [gdb_compile_shlib ${lib1src} ${lib1} ${lib1opts}] != ""
76 || [gdb_compile_shlib ${lib2src} ${lib2} ${lib2opts}] != ""
77 || [gdb_compile "${srcdir}/${subdir}/${srcfile}" ${binfile} executable $exec_opts] != ""} {
83 gdb_reinitialize_dir $srcdir/$subdir
90 # If the library which will be used is compiled without debugging
91 # information, GDB will pick the wrong copy of "bar", i.e. the one
92 # with debugging information.
94 if {(${lib1opts} == "" && ${lib2opts} != "" && ${lib1first} == 1)
95 || (${lib1opts} != "" && ${lib2opts} == "" && ${lib1first} == 0)} {
96 setup_kfail *-*-* gdb/1824
99 gdb_test "continue" "Breakpoint .* bar .*${expected_file}\\..*" \
100 "run to breakpoint - $testopts"
103 foreach lib1opts {{} {debug}} {
104 foreach lib2opts {{} {debug}} {
105 foreach lib1first {1 0} {
106 do_test $lib1opts $lib2opts $lib1first