]>
Commit | Line | Data |
---|---|---|
7b6bb8da JB |
1 | # Copyright 2006, 2007, 2008, 2009, 2010, 2011 |
2 | # Free Software Foundation, Inc. | |
08232497 DJ |
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 | |
e22f8b7c | 6 | # the Free Software Foundation; either version 3 of the License, or |
08232497 | 7 | # (at your option) any later version. |
e22f8b7c | 8 | # |
08232497 DJ |
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. | |
e22f8b7c | 13 | # |
08232497 | 14 | # You should have received a copy of the GNU General Public License |
e22f8b7c | 15 | # along with this program. If not, see <http://www.gnu.org/licenses/>. |
08232497 DJ |
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 |
21 | if {[skip_shlib_tests]} { |
22 | return 0 | |
23 | } | |
24 | ||
25 | # These targets have shared libraries, but weak symbols are not meaningful. | |
26 | if {([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. | |
34 | if [get_compiler_info not-used] { | |
35 | return -1 | |
36 | } | |
37 | ||
38 | if {![test_compiler_info "gcc-*"]} { | |
39 | return 0 | |
40 | } | |
41 | ||
42 | proc do_test { lib1opts lib2opts lib1first } { | |
43 | global objdir srcdir subdir | |
44 | ||
40b53987 DJ |
45 | set testfile "solib-weak" |
46 | set srcfile ${testfile}.c | |
47 | ||
48 | set libfile1 "weaklib1" | |
49 | set libfile2 "weaklib2" | |
50 | set lib1src ${srcdir}/${subdir}/${libfile1}.c | |
51 | set lib2src ${srcdir}/${subdir}/${libfile2}.c | |
52 | ||
53 | # Select a unique name for this test. Give each library and | |
54 | # executable a name reflecting its options, so that file caching | |
55 | # on the target system does not pick up the wrong file. | |
08232497 DJ |
56 | set testopts "" |
57 | if {$lib1opts == ""} { | |
58 | append testopts "lib1 nodebug, " | |
59 | } else { | |
60 | append testopts "lib1 debug, " | |
40b53987 | 61 | append lib1 "-dbg" |
08232497 DJ |
62 | } |
63 | if {$lib2opts == ""} { | |
64 | append testopts "lib2 nodebug, " | |
65 | } else { | |
66 | append testopts "lib2 debug, " | |
40b53987 | 67 | append lib2 "-dbg" |
08232497 DJ |
68 | } |
69 | if {$lib1first} { | |
70 | append testopts "lib1 first" | |
71 | } else { | |
72 | append testopts "lib2 first" | |
40b53987 | 73 | append testfile "-lib2" |
08232497 DJ |
74 | } |
75 | ||
08232497 | 76 | set binfile ${objdir}/${subdir}/${testfile} |
08232497 DJ |
77 | set lib1 ${objdir}/${subdir}/${libfile1}.sl |
78 | set lib2 ${objdir}/${subdir}/${libfile2}.sl | |
79 | ||
80 | if $lib1first { | |
81 | set exec_opts [list debug shlib=${lib1} shlib=${lib2}] | |
82 | set expected_file ${libfile1} | |
83 | } else { | |
84 | set exec_opts [list debug shlib=${lib2} shlib=${lib1}] | |
85 | set expected_file ${libfile2} | |
86 | } | |
87 | ||
88 | if { [gdb_compile_shlib ${lib1src} ${lib1} ${lib1opts}] != "" | |
89 | || [gdb_compile_shlib ${lib2src} ${lib2} ${lib2opts}] != "" | |
90 | || [gdb_compile "${srcdir}/${subdir}/${srcfile}" ${binfile} executable $exec_opts] != ""} { | |
91 | return -1 | |
92 | } | |
93 | ||
94 | gdb_exit | |
95 | gdb_start | |
96 | gdb_reinitialize_dir $srcdir/$subdir | |
97 | gdb_load ${binfile} | |
93f02886 | 98 | gdb_load_shlibs $lib1 $lib2 |
08232497 DJ |
99 | |
100 | runto_main | |
101 | ||
102 | gdb_breakpoint "bar" | |
103 | ||
104 | # If the library which will be used is compiled without debugging | |
105 | # information, GDB will pick the wrong copy of "bar", i.e. the one | |
106 | # with debugging information. | |
107 | ||
108 | if {(${lib1opts} == "" && ${lib2opts} != "" && ${lib1first} == 1) | |
109 | || (${lib1opts} != "" && ${lib2opts} == "" && ${lib1first} == 0)} { | |
bbc8b958 | 110 | setup_kfail gdb/1824 *-*-* |
08232497 DJ |
111 | } |
112 | ||
176400c3 | 113 | gdb_test "continue" "Breakpoint .* \\.?bar .*${expected_file}\\..*" \ |
08232497 DJ |
114 | "run to breakpoint - $testopts" |
115 | } | |
116 | ||
117 | foreach lib1opts {{} {debug}} { | |
118 | foreach lib2opts {{} {debug}} { | |
119 | foreach lib1first {1 0} { | |
120 | do_test $lib1opts $lib2opts $lib1first | |
121 | } | |
122 | } | |
123 | } |