* lib/gdb.exp (gdb_compile): Add support for Windows DLLs.
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.base / solib-weak.exp
CommitLineData
6aba47ca 1# Copyright 2006, 2007 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
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
93f02886
DJ
21if {[skip_shlib_tests]} {
22 return 0
23}
24
25# These targets have shared libraries, but weak symbols are not meaningful.
26if {([istarget arm*-*-symbianelf*]
27 || [istarget *-*-mingw*]
28 || [istarget *-*-cygwin*]
29 || [istarget *-*-pe*])} {
08232497
DJ
30 return 0
31}
32
33# This test uses GCC-specific syntax.
34if [get_compiler_info not-used] {
35 return -1
36}
37
38if {![test_compiler_info "gcc-*"]} {
39 return 0
40}
41
42proc do_test { lib1opts lib2opts lib1first } {
43 global objdir srcdir subdir
44
45 set testopts ""
46 if {$lib1opts == ""} {
47 append testopts "lib1 nodebug, "
48 } else {
49 append testopts "lib1 debug, "
50 }
51 if {$lib2opts == ""} {
52 append testopts "lib2 nodebug, "
53 } else {
54 append testopts "lib2 debug, "
55 }
56 if {$lib1first} {
57 append testopts "lib1 first"
58 } else {
59 append testopts "lib2 first"
60 }
61
62 set testfile "solib-weak"
63 set srcfile ${testfile}.c
64 set binfile ${objdir}/${subdir}/${testfile}
65
66 set libfile1 "weaklib1"
67 set libfile2 "weaklib2"
68 set lib1src ${srcdir}/${subdir}/${libfile1}.c
69 set lib2src ${srcdir}/${subdir}/${libfile2}.c
70 set lib1 ${objdir}/${subdir}/${libfile1}.sl
71 set lib2 ${objdir}/${subdir}/${libfile2}.sl
72
73 if $lib1first {
74 set exec_opts [list debug shlib=${lib1} shlib=${lib2}]
75 set expected_file ${libfile1}
76 } else {
77 set exec_opts [list debug shlib=${lib2} shlib=${lib1}]
78 set expected_file ${libfile2}
79 }
80
81 if { [gdb_compile_shlib ${lib1src} ${lib1} ${lib1opts}] != ""
82 || [gdb_compile_shlib ${lib2src} ${lib2} ${lib2opts}] != ""
83 || [gdb_compile "${srcdir}/${subdir}/${srcfile}" ${binfile} executable $exec_opts] != ""} {
84 return -1
85 }
86
87 gdb_exit
88 gdb_start
89 gdb_reinitialize_dir $srcdir/$subdir
90 gdb_load ${binfile}
93f02886 91 gdb_load_shlibs $lib1 $lib2
08232497
DJ
92
93 runto_main
94
95 gdb_breakpoint "bar"
96
97 # If the library which will be used is compiled without debugging
98 # information, GDB will pick the wrong copy of "bar", i.e. the one
99 # with debugging information.
100
101 if {(${lib1opts} == "" && ${lib2opts} != "" && ${lib1first} == 1)
102 || (${lib1opts} != "" && ${lib2opts} == "" && ${lib1first} == 0)} {
103 setup_kfail *-*-* gdb/1824
104 }
105
106 gdb_test "continue" "Breakpoint .* bar .*${expected_file}\\..*" \
107 "run to breakpoint - $testopts"
108}
109
110foreach lib1opts {{} {debug}} {
111 foreach lib2opts {{} {debug}} {
112 foreach lib1first {1 0} {
113 do_test $lib1opts $lib2opts $lib1first
114 }
115 }
116}
This page took 0.067699 seconds and 4 git commands to generate.