Remove references to HP CC/aCC compiler from testsuite
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.base / solib.exp
1 # Copyright 1997-2015 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 3 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, see <http://www.gnu.org/licenses/>. */
15
16
17 # are we on a target board
18 if ![isnative] then {
19 return
20 }
21
22 # This test is presently only valid on HP-UX. It verifies GDB's
23 # ability to catch loads and unloads of shared libraries.
24 #
25
26 #setup_xfail "*-*-*"
27 #clear_xfail "hppa*-*-*hpux*"
28 if {![istarget "hppa*-*-hpux*"]} {
29 return 0
30 }
31
32 set testfile "solib"
33 set srcfile ${testfile}.c
34 set binfile ${objdir}/${subdir}/${testfile}
35
36 # build the first test case
37 if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
38 untested solib.exp
39 return -1
40 }
41
42 if [get_compiler_info] {
43 return -1
44 }
45
46 # Build the shared libraries this test case needs.
47 #
48 #cd ${subdir}
49 #remote_exec build "$CC -g +z -c ${testfile}1.c -o ${testfile}1.o"
50 #remote_exec build "$CC -g +z -c ${testfile}2.c -o ${testfile}2.o"
51
52 if {$gcc_compiled == 0} {
53 if [istarget "hppa*-hp-hpux*"] then {
54 set additional_flags "additional_flags=+z"
55 } else {
56 # don't know what the compiler is...
57 set additional_flags ""
58 }
59 } else {
60 set additional_flags "additional_flags=-fpic"
61 }
62
63 if {[gdb_compile "${srcdir}/${subdir}/${testfile}1.c" "${binfile}1.o" object [list debug $additional_flags]] != ""} {
64 perror "Couldn't compile ${testfile}1.c"
65 #return -1
66 }
67 if {[gdb_compile "${srcdir}/${subdir}/${testfile}2.c" "${binfile}2.o" object [list debug, $additional_flags]] != ""} {
68 perror "Couldn't compile ${testfile}2.c"
69 #return -1
70 }
71
72 if [istarget "hppa*-*-hpux*"] {
73 remote_exec build "ld -b ${binfile}1.o -o ${binfile}1.sl"
74 remote_exec build "ld -b ${binfile}2.o -o ${binfile}2.sl"
75 } else {
76 set additional_flags "additional_flags=-shared"
77 gdb_compile "${binfile}1.o" "${binfile}1.sl" executable [list debug $additional_flags]
78 gdb_compile "${binfile}2.o" "${binfile}2.sl" executable [list debug $additional_flags]
79 }
80
81 # Build a version where the main program is in a shared library. For
82 # testing an indirect call made in a shared library.
83
84 if {[gdb_compile "${srcdir}/${subdir}/${testfile}.c" "${binfile}_sl.o" object [list debug $additional_flags]] != ""} {
85 perror "Couldn't compile ${testfile}.c for ${binfile}_sl.o"
86 #return -1
87 }
88
89 if { [istarget "hppa*-*-hpux*"] } {
90 remote_exec build "ld -b ${binfile}_sl.o -o ${binfile}_sl.sl"
91 } else {
92 set additional_flags "additional_flags=-shared"
93 gdb_compile "${binfile}_sl.o" "${binfile}_sl.sl" executable [list debug $additional_flags]
94 }
95
96 if { [istarget "hppa*-*-hpux*"] } {
97 set additional_flags "-Wl,-u,main"
98 if { [gdb_compile "${binfile}_sl.sl" "${binfile}_sl" executable [list debug $additional_flags]] != "" } {
99 untested solib.exp
100 return -1
101 }
102 } else {
103 # FIXME: need to fill this part in for non-HP build
104 }
105
106 #cd ..
107
108 # Start with a fresh gdb
109
110 gdb_exit
111 gdb_start
112 gdb_reinitialize_dir $srcdir/$subdir
113 gdb_load ${binfile}
114
115 # This program manually loads and unloads SOM shared libraries, via calls
116 # to shl_load and shl_unload.
117 #
118 if ![runto_main] then { fail "catch load/unload tests suppressed" }
119
120 # Verify that we complain if the user tells us to catch something we
121 # don't understand.
122 #
123 send_gdb "catch a_cold\n"
124 gdb_expect {
125 -re "Unknown event kind specified for catch.*$gdb_prompt $"\
126 {pass "bogus catch kind is disallowed"}
127 -re "$gdb_prompt $"\
128 {fail "bogus catch kind is disallowed"}
129 timeout {fail "(timeout) bogus catch kind is disallowed"}
130 }
131
132 # Verify that we can set a generic catchpoint on shlib loads. I.e., that
133 # we can catch any shlib load, without specifying the name.
134 #
135 send_gdb "catch load\n"
136 gdb_expect {
137 -re "Catchpoint \[0-9\]* .load <any library>.*$gdb_prompt $"\
138 {pass "set generic catch load"}
139 -re "$gdb_prompt $"\
140 {fail "set generic catch load"}
141 timeout {fail "(timeout) set generic catch load"}
142 }
143
144 send_gdb "continue\n"
145 gdb_expect {
146 -re "Catchpoint \[0-9\] .loaded gdb.base/solib1.sl.*$gdb_prompt $"\
147 {pass "caught generic solib load"}
148 -re "$gdb_prompt $"\
149 {fail "caught generic solib load"}
150 timeout {fail "(timeout) caught generic solib load"}
151 }
152
153 # Set a breakpoint on the line following the shl_load call, and
154 # continue.
155 #
156 # ??rehrauer: It appears that we can't just say "finish" from here;
157 # GDB is getting confused by the dld's presense on the stack.
158 #
159 send_gdb "break 27\n"
160 gdb_expect {
161 -re "Breakpoint \[0-9\]* at.*$gdb_prompt $"\
162 {pass "set break after shl_load"}
163 -re "$gdb_prompt $"\
164 {fail "set break after shl_load"}
165 timeout {fail "(timeout) set break after shl_load"}
166 }
167
168 send_gdb "continue\n"
169 gdb_expect {
170 -re "Breakpoint \[0-9\]*, main .. at .*solib.c:27.*$gdb_prompt $"\
171 {pass "continue after generic catch load"}
172 -re "$gdb_prompt $"\
173 {fail "continue after generic catch load"}
174 timeout {fail "(timeout) continue after generic catch load"}
175 }
176
177 # Step over the call to shl_findsym.
178 #
179 # ??rehrauer: In theory, since the call to shl_load asked for
180 # immediate binding of the shlib's symbols, and since the
181 # shlib's symbols should have been auto-loaded, we ought to
182 # be able to set a breakpoint on solib_main now. However,
183 # that seems not to be the case. Dunno why for sure; perhaps
184 # the breakpoint wants to be set on an import stub in the
185 # main program for solib_main? There wouldn't be one, in
186 # this case...
187 #
188 send_gdb "next\n"
189 gdb_expect {
190 -re "$gdb_prompt $"\
191 {pass "step over shl_findsym"}
192 timeout {fail "(timeout) step over shl_findsym"}
193 }
194
195 # Verify that we can catch an unload of any library.
196 #
197 send_gdb "catch unload\n"
198 gdb_expect {
199 -re "Catchpoint \[0-9\]* .unload <any library>.*$gdb_prompt $"\
200 {pass "set generic catch unload"}
201 -re "$gdb_prompt $"\
202 {fail "set generic catch unload"}
203 timeout {fail "(timeout) set generic catch load"}
204 }
205
206 send_gdb "continue\n"
207 gdb_expect {
208 -re "Catchpoint \[0-9\] .unloaded gdb.base/solib1.sl.*$gdb_prompt $"\
209 {pass "caught generic solib unload"}
210 -re "$gdb_prompt $"\
211 {fail "caught generic solib unload"}
212 timeout {fail "(timeout) caught generic solib unload"}
213 }
214
215 # Verify that we can catch a load of a specific library. (Delete
216 # all the other catchpoints first, so that the generic catchpoints
217 # we've previously set don't trigger.)
218 #
219 send_gdb "delete\n"
220 gdb_expect {
221 -re "Delete all breakpoints.*y or n.*"\
222 {send_gdb "y\n"
223 gdb_expect {
224 -re "$gdb_prompt $"\
225 {pass "delete all catchpoints"}
226 timeout {fail "(timeout) delete all catchpoints"}
227 }
228 }
229 -re "$gdb_prompt $"\
230 {fail "delete all catchpoints"}
231 timeout {fail "(timeout) delete all catchpoints"}
232 }
233
234 send_gdb "catch load gdb.base/solib2.sl\n"
235 gdb_expect {
236 -re "Catchpoint \[0-9\]* .load gdb.base/solib2.sl.*$gdb_prompt $"\
237 {pass "set specific catch load"}
238 -re "$gdb_prompt $"\
239 {fail "set specific catch load"}
240 timeout {fail "(timeout) set specific catch load"}
241 }
242
243 send_gdb "continue\n"
244 gdb_expect {
245 -re "Catchpoint \[0-9\] .loaded gdb.base/solib2.sl.*$gdb_prompt $"\
246 {pass "caught specific solib load"}
247 -re "$gdb_prompt $"\
248 {fail "caught specific solib load"}
249 timeout {fail "(timeout) caught specific solib load"}
250 }
251
252 # Verify that we can catch an unload of a specific library.
253 #
254 send_gdb "catch unload gdb.base/solib2.sl\n"
255 gdb_expect {
256 -re "Catchpoint \[0-9\]* .unload gdb.base/solib2.sl.*$gdb_prompt $"\
257 {pass "set specific catch unload"}
258 -re "$gdb_prompt $"\
259 {fail "set specific catch unload"}
260 timeout {fail "(timeout) set specific catch unload"}
261 }
262
263 send_gdb "continue\n"
264 gdb_expect {
265 -re "Catchpoint \[0-9\] .unloaded gdb.base/solib2.sl.*$gdb_prompt $"\
266 {pass "caught specific solib unload"}
267 -re "$gdb_prompt $"\
268 {fail "caught specific solib unload"}
269 timeout {fail "(timeout) caught specific solib unload"}
270 }
271
272 # Verify that we can set a catchpoint on a specific library that
273 # happens not to be loaded by the program. And, that this catchpoint
274 # won't trigger inappropriately when other shlibs are loaded.
275 #
276 send_gdb "break 55\n"
277 gdb_expect {
278 -re "Breakpoint \[0-9\]* at.*$gdb_prompt $"\
279 {pass "set break on shl_unload"}
280 -re "$gdb_prompt $"\
281 {fail "set break on shl_unload"}
282 timeout {fail "(timeout) set break on shl_unload"}
283 }
284
285 send_gdb "break 58\n"
286 gdb_expect {
287 -re "Breakpoint \[0-9\]* at.*$gdb_prompt $"\
288 {pass "set break after shl_unload"}
289 -re "$gdb_prompt $"\
290 {fail "set break after shl_unload"}
291 timeout {fail "(timeout) set break after shl_unload"}
292 }
293
294 send_gdb "catch load foobar.sl\n"
295 gdb_expect {
296 -re "Catchpoint \[0-9\]* .load foobar.sl.*$gdb_prompt $"\
297 {pass "set specific catch load for nonloaded shlib"}
298 -re "$gdb_prompt $"\
299 {fail "set specific catch load for nonloaded shlib"}
300 timeout {fail "(timeout) set specific catch load for nonloaded shlib"}
301 }
302
303 send_gdb "catch unload foobar.sl\n"
304 gdb_expect {
305 -re "Catchpoint \[0-9\]* .unload foobar.sl.*$gdb_prompt $"\
306 {pass "set specific catch unload for nonloaded shlib"}
307 -re "$gdb_prompt $"\
308 {fail "set specific catch unload for nonloaded shlib"}
309 timeout {fail "(timeout) set specific catch unload for nonloaded shlib"}
310 }
311
312 send_gdb "continue\n"
313 gdb_expect {
314 -re "Breakpoint \[0-9\]*.*$gdb_prompt $"\
315 {pass "specific catch load doesn't trigger inappropriately"}
316 -re "$gdb_prompt $"\
317 {fail "specific catch load doesn't trigger inappropriately"}
318 timeout {fail "(timeout) specific catch load doesn't trigger inappropriately"}
319 }
320
321 send_gdb "continue\n"
322 gdb_expect {
323 -re "Breakpoint \[0-9\]*.*$gdb_prompt $"\
324 {pass "specific catch unload doesn't trigger inappropriately"}
325 -re "$gdb_prompt $"\
326 {fail "specific catch unload doesn't trigger inappropriately"}
327 timeout {fail "(timeout) specific catch unload doesn't trigger inappropriately"}
328 }
329
330 # ??rehrauer: There ought to be testpoints here that verify that
331 # load/unload catchpoints can use conditionals, can be temporary,
332 # self-disabling, etc etc.
333 #
334
335 gdb_exit
336
337 #
338 # Test stepping into an indirect call in a shared library.
339 #
340
341 gdb_start
342 gdb_load ${binfile}_sl
343 gdb_test "break main" ".*deferred. at .main..*" "break on main"
344 gdb_test "run" ".*Breakpoint.*main.*solib.c.*" "hit breakpoint at main"
345 gdb_test "break 45" "Breakpoint.*solib.c, line 45.*" "break on indirect call"
346 gdb_test "continue" "Continuing.*solib.c:45.*" \
347 "continue to break on indirect call"
348 gdb_test "step" "solib_main.*solib1.c:17.*return arg.arg.*" \
349 "step into indirect call from a shared library"
350 gdb_exit
351
352 return 0
This page took 0.039197 seconds and 4 git commands to generate.