Commit | Line | Data |
---|---|---|
88b9d363 | 1 | # Copyright 2006-2022 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 | |
e22f8b7c | 5 | # the Free Software Foundation; either version 3 of the License, or |
08232497 | 6 | # (at your option) any later version. |
e22f8b7c | 7 | # |
08232497 DJ |
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. | |
e22f8b7c | 12 | # |
08232497 | 13 | # You should have received a copy of the GNU General Public License |
e22f8b7c | 14 | # along with this program. If not, see <http://www.gnu.org/licenses/>. |
08232497 DJ |
15 | |
16 | # Test setting breakpoints on shared library functions provided by more | |
17 | # than one shared library, when one of the implementations is a "weak" | |
18 | # symbol. GDB should set a breakpoint at the first copy it finds. | |
19 | ||
93f02886 DJ |
20 | if {[skip_shlib_tests]} { |
21 | return 0 | |
22 | } | |
23 | ||
24 | # These targets have shared libraries, but weak symbols are not meaningful. | |
18b8df43 | 25 | if {([istarget *-*-mingw*] |
93f02886 DJ |
26 | || [istarget *-*-cygwin*] |
27 | || [istarget *-*-pe*])} { | |
08232497 DJ |
28 | return 0 |
29 | } | |
30 | ||
31 | # This test uses GCC-specific syntax. | |
4c93b1db | 32 | if [get_compiler_info] { |
08232497 DJ |
33 | return -1 |
34 | } | |
35 | ||
36 | if {![test_compiler_info "gcc-*"]} { | |
37 | return 0 | |
38 | } | |
39 | ||
40 | proc do_test { lib1opts lib2opts lib1first } { | |
0ab77f5f | 41 | global srcdir subdir |
08232497 | 42 | |
40b53987 DJ |
43 | set testfile "solib-weak" |
44 | set srcfile ${testfile}.c | |
45 | ||
46 | set libfile1 "weaklib1" | |
47 | set libfile2 "weaklib2" | |
48 | set lib1src ${srcdir}/${subdir}/${libfile1}.c | |
49 | set lib2src ${srcdir}/${subdir}/${libfile2}.c | |
50 | ||
51 | # Select a unique name for this test. Give each library and | |
52 | # executable a name reflecting its options, so that file caching | |
53 | # on the target system does not pick up the wrong file. | |
08232497 DJ |
54 | set testopts "" |
55 | if {$lib1opts == ""} { | |
56 | append testopts "lib1 nodebug, " | |
57 | } else { | |
58 | append testopts "lib1 debug, " | |
40b53987 | 59 | append lib1 "-dbg" |
08232497 DJ |
60 | } |
61 | if {$lib2opts == ""} { | |
62 | append testopts "lib2 nodebug, " | |
63 | } else { | |
64 | append testopts "lib2 debug, " | |
40b53987 | 65 | append lib2 "-dbg" |
08232497 DJ |
66 | } |
67 | if {$lib1first} { | |
68 | append testopts "lib1 first" | |
69 | } else { | |
70 | append testopts "lib2 first" | |
40b53987 | 71 | append testfile "-lib2" |
08232497 DJ |
72 | } |
73 | ||
0ab77f5f TT |
74 | set binfile [standard_output_file ${testfile}] |
75 | set lib1 [standard_output_file ${libfile1}.sl] | |
76 | set lib2 [standard_output_file ${libfile2}.sl] | |
08232497 DJ |
77 | |
78 | if $lib1first { | |
79 | set exec_opts [list debug shlib=${lib1} shlib=${lib2}] | |
80 | set expected_file ${libfile1} | |
81 | } else { | |
82 | set exec_opts [list debug shlib=${lib2} shlib=${lib1}] | |
83 | set expected_file ${libfile2} | |
84 | } | |
85 | ||
86 | if { [gdb_compile_shlib ${lib1src} ${lib1} ${lib1opts}] != "" | |
87 | || [gdb_compile_shlib ${lib2src} ${lib2} ${lib2opts}] != "" | |
88 | || [gdb_compile "${srcdir}/${subdir}/${srcfile}" ${binfile} executable $exec_opts] != ""} { | |
89 | return -1 | |
90 | } | |
91 | ||
92 | gdb_exit | |
93 | gdb_start | |
94 | gdb_reinitialize_dir $srcdir/$subdir | |
95 | gdb_load ${binfile} | |
d9019901 SM |
96 | gdb_load_shlib $lib1 |
97 | gdb_load_shlib $lib2 | |
08232497 DJ |
98 | |
99 | runto_main | |
100 | ||
101 | gdb_breakpoint "bar" | |
102 | ||
176400c3 | 103 | gdb_test "continue" "Breakpoint .* \\.?bar .*${expected_file}\\..*" \ |
08232497 DJ |
104 | "run to breakpoint - $testopts" |
105 | } | |
106 | ||
107 | foreach lib1opts {{} {debug}} { | |
108 | foreach lib2opts {{} {debug}} { | |
109 | foreach lib1first {1 0} { | |
110 | do_test $lib1opts $lib2opts $lib1first | |
111 | } | |
112 | } | |
113 | } |