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