]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blob - gdb/testsuite/gdb.base/solib-weak.exp
Copyright updates for 2007.
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.base / solib-weak.exp
1 # Copyright 2006, 2007 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 2 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, write to the Free Software
15 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
16
17 # Test setting breakpoints on shared library functions provided by more
18 # than one shared library, when one of the implementations is a "weak"
19 # symbol. GDB should set a breakpoint at the first copy it finds.
20
21 # Don't try to run shared library test cases on a remote target for now.
22 if ![isnative] then {
23 return 0
24 }
25
26 # This test uses GCC-specific syntax.
27 if [get_compiler_info not-used] {
28 return -1
29 }
30
31 if {![test_compiler_info "gcc-*"]} {
32 return 0
33 }
34
35 proc do_test { lib1opts lib2opts lib1first } {
36 global objdir srcdir subdir
37
38 set testopts ""
39 if {$lib1opts == ""} {
40 append testopts "lib1 nodebug, "
41 } else {
42 append testopts "lib1 debug, "
43 }
44 if {$lib2opts == ""} {
45 append testopts "lib2 nodebug, "
46 } else {
47 append testopts "lib2 debug, "
48 }
49 if {$lib1first} {
50 append testopts "lib1 first"
51 } else {
52 append testopts "lib2 first"
53 }
54
55 set testfile "solib-weak"
56 set srcfile ${testfile}.c
57 set binfile ${objdir}/${subdir}/${testfile}
58
59 set libfile1 "weaklib1"
60 set libfile2 "weaklib2"
61 set lib1src ${srcdir}/${subdir}/${libfile1}.c
62 set lib2src ${srcdir}/${subdir}/${libfile2}.c
63 set lib1 ${objdir}/${subdir}/${libfile1}.sl
64 set lib2 ${objdir}/${subdir}/${libfile2}.sl
65
66 if $lib1first {
67 set exec_opts [list debug shlib=${lib1} shlib=${lib2}]
68 set expected_file ${libfile1}
69 } else {
70 set exec_opts [list debug shlib=${lib2} shlib=${lib1}]
71 set expected_file ${libfile2}
72 }
73
74 if { [gdb_compile_shlib ${lib1src} ${lib1} ${lib1opts}] != ""
75 || [gdb_compile_shlib ${lib2src} ${lib2} ${lib2opts}] != ""
76 || [gdb_compile "${srcdir}/${subdir}/${srcfile}" ${binfile} executable $exec_opts] != ""} {
77 return -1
78 }
79
80 gdb_exit
81 gdb_start
82 gdb_reinitialize_dir $srcdir/$subdir
83 gdb_load ${binfile}
84
85 runto_main
86
87 gdb_breakpoint "bar"
88
89 # If the library which will be used is compiled without debugging
90 # information, GDB will pick the wrong copy of "bar", i.e. the one
91 # with debugging information.
92
93 if {(${lib1opts} == "" && ${lib2opts} != "" && ${lib1first} == 1)
94 || (${lib1opts} != "" && ${lib2opts} == "" && ${lib1first} == 0)} {
95 setup_kfail *-*-* gdb/1824
96 }
97
98 gdb_test "continue" "Breakpoint .* bar .*${expected_file}\\..*" \
99 "run to breakpoint - $testopts"
100 }
101
102 foreach lib1opts {{} {debug}} {
103 foreach lib2opts {{} {debug}} {
104 foreach lib1first {1 0} {
105 do_test $lib1opts $lib2opts $lib1first
106 }
107 }
108 }