gdb/
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.base / solib-weak.exp
1 # Copyright 2006
2 # Free Software Foundation, Inc.
3
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.
8 #
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.
13 #
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.
17
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.
21
22 # Don't try to run shared library test cases on a remote target for now.
23 if ![isnative] then {
24 return 0
25 }
26
27 # This test uses GCC-specific syntax.
28 if [get_compiler_info not-used] {
29 return -1
30 }
31
32 if {![test_compiler_info "gcc-*"]} {
33 return 0
34 }
35
36 proc do_test { lib1opts lib2opts lib1first } {
37 global objdir srcdir subdir
38
39 set testopts ""
40 if {$lib1opts == ""} {
41 append testopts "lib1 nodebug, "
42 } else {
43 append testopts "lib1 debug, "
44 }
45 if {$lib2opts == ""} {
46 append testopts "lib2 nodebug, "
47 } else {
48 append testopts "lib2 debug, "
49 }
50 if {$lib1first} {
51 append testopts "lib1 first"
52 } else {
53 append testopts "lib2 first"
54 }
55
56 set testfile "solib-weak"
57 set srcfile ${testfile}.c
58 set binfile ${objdir}/${subdir}/${testfile}
59
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
66
67 if $lib1first {
68 set exec_opts [list debug shlib=${lib1} shlib=${lib2}]
69 set expected_file ${libfile1}
70 } else {
71 set exec_opts [list debug shlib=${lib2} shlib=${lib1}]
72 set expected_file ${libfile2}
73 }
74
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] != ""} {
78 return -1
79 }
80
81 gdb_exit
82 gdb_start
83 gdb_reinitialize_dir $srcdir/$subdir
84 gdb_load ${binfile}
85
86 runto_main
87
88 gdb_breakpoint "bar"
89
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.
93
94 if {(${lib1opts} == "" && ${lib2opts} != "" && ${lib1first} == 1)
95 || (${lib1opts} != "" && ${lib2opts} == "" && ${lib1first} == 0)} {
96 setup_kfail *-*-* gdb/1824
97 }
98
99 gdb_test "continue" "Breakpoint .* bar .*${expected_file}\\..*" \
100 "run to breakpoint - $testopts"
101 }
102
103 foreach lib1opts {{} {debug}} {
104 foreach lib2opts {{} {debug}} {
105 foreach lib1first {1 0} {
106 do_test $lib1opts $lib2opts $lib1first
107 }
108 }
109 }
This page took 0.033014 seconds and 5 git commands to generate.