1 # Copyright
1997, 1998, 1999, 2007 Free Software Foundation
, Inc.
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.
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.
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
/>.
*/
16 # Please email
any bugs
, comments
, and
/or additions to this file to
:
17 # bug
-gdb@prep.ai.mit.edu
26 # are we
on a target board
31 # This test is presently only valid
on HP
-UX. It verifies GDB
's
32 # ability to catch loads and unloads of shared libraries.
36 #clear_xfail "hppa*-*-*hpux*"
37 if {![istarget "hppa*-*-hpux*"]} {
42 set srcfile ${testfile}.c
43 set binfile ${objdir}/${subdir}/${testfile}
45 # build the first test case
46 if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
51 if [get_compiler_info ${binfile}] {
55 # Build the shared libraries this test case needs.
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"
61 if {$gcc_compiled == 0} {
62 if [istarget "hppa*-hp-hpux*"] then {
63 set additional_flags "additional_flags=+z"
65 # don't know what the compiler is...
66 set additional_flags
""
69 set additional_flags
"additional_flags=-fpic"
72 if {[gdb_compile
"${srcdir}/${subdir}/${testfile}1.c" "${binfile}1.o" object [list debug $additional_flags]] != ""} {
73 perror
"Couldn't compile ${testfile}1.c"
76 if {[gdb_compile
"${srcdir}/${subdir}/${testfile}2.c" "${binfile}2.o" object [list debug, $additional_flags]] != ""} {
77 perror
"Couldn't compile ${testfile}2.c"
81 if [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"
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]
90 # Build a version where the main
program is in a shared library.
For
91 # testing an indirect
call made in a shared library.
93 if {[gdb_compile
"${srcdir}/${subdir}/${testfile}.c" "${binfile}_sl.o" object [list debug $additional_flags]] != ""} {
94 perror
"Couldn't compile ${testfile}.c for ${binfile}_sl.o"
98 if { [istarget
"hppa*-*-hpux*"] } {
99 remote_exec build
"ld -b ${binfile}_sl.o -o ${binfile}_sl.sl"
101 set additional_flags
"additional_flags=-shared"
102 gdb_compile
"${binfile}_sl.o" "${binfile}_sl.sl" executable [list debug $additional_flags]
105 if { [istarget
"hppa*-*-hpux*"] } {
106 set additional_flags
"-Wl,-u,main"
107 if { [gdb_compile
"${binfile}_sl.sl" "${binfile}_sl" executable [list debug $additional_flags]] != "" } {
112 # FIXME
: need to fill this part in
for non
-HP build
117 # Start with a fresh gdb
121 gdb_reinitialize_dir $srcdir
/$subdir
124 # This
program manually loads and unloads SOM shared libraries
, via calls
125 # to shl_load and shl_unload.
127 if ![runto_main
] then { fail
"catch load/unload tests suppressed" }
129 # Verify that we complain
if the user tells us to catch something we
132 send_gdb "catch a_cold\n"
134 -re "Unknown event kind specified for catch.*$gdb_prompt $"\
135 {pass "bogus catch kind is disallowed"}
137 {fail "bogus catch kind is disallowed"}
138 timeout {fail "(timeout) bogus catch kind is disallowed"}
141 # Verify that we can set a generic catchpoint on shlib loads. I.e., that
142 # we can catch any shlib load, without specifying the name.
144 send_gdb "catch load\n"
146 -re "Catchpoint \[0-9\]* .load <any library>.*$gdb_prompt $"\
147 {pass "set generic catch load"}
149 {fail "set generic catch load"}
150 timeout {fail "(timeout) set generic catch load"}
153 send_gdb "continue\n"
155 -re "Catchpoint \[0-9\] .loaded gdb.base/solib1.sl.*$gdb_prompt $"\
156 {pass "caught generic solib load"}
158 {fail "caught generic solib load"}
159 timeout {fail "(timeout) caught generic solib load"}
162 # Set a breakpoint on the line following the shl_load call, and
165 # ??rehrauer: It appears that we can't just say
"finish" from here;
166 # GDB is getting confused by the dld
's presense on the stack.
168 send_gdb "break 27\n"
170 -re "Breakpoint \[0-9\]* at.*$gdb_prompt $"\
171 {pass "set break after shl_load"}
173 {fail "set break after shl_load"}
174 timeout {fail "(timeout) set break after shl_load"}
177 send_gdb "continue\n"
179 -re "Breakpoint \[0-9\]*, main .. at .*solib.c:27.*$gdb_prompt $"\
180 {pass "continue after generic catch load"}
182 {fail "continue after generic catch load"}
183 timeout {fail "(timeout) continue after generic catch load"}
186 # Step over the call to shl_findsym.
188 # ??rehrauer: In theory, since the call to shl_load asked for
189 # immediate binding of the shlib's symbols
, and since the
190 # shlib
's symbols should have been auto-loaded, we ought to
191 # be able to set a breakpoint on solib_main now. However,
192 # that seems not to be the case. Dunno why for sure; perhaps
193 # the breakpoint wants to be set on an import stub in the
194 # main program for solib_main? There wouldn't be one
, in
200 {pass
"step over shl_findsym"}
201 timeout
{fail
"(timeout) step over shl_findsym"}
204 # Verify that we can catch an unload of
any library.
206 send_gdb
"catch unload\n"
208 -re
"Catchpoint \[0-9\]* .unload <any library>.*$gdb_prompt $"\
209 {pass
"set generic catch unload"}
211 {fail
"set generic catch unload"}
212 timeout
{fail
"(timeout) set generic catch load"}
215 send_gdb
"continue\n"
217 -re
"Catchpoint \[0-9\] .unloaded gdb.base/solib1.sl.*$gdb_prompt $"\
218 {pass
"caught generic solib unload"}
220 {fail
"caught generic solib unload"}
221 timeout
{fail
"(timeout) caught generic solib unload"}
224 # Verify that we can catch a
load of a specific library.
(Delete
225 # all the other catchpoints first
, so that the generic catchpoints
226 # we
've previously set don't trigger.
)
230 -re
"Delete all breakpoints.*y or n.*"\
234 {pass
"delete all catchpoints"}
235 timeout
{fail
"(timeout) delete all catchpoints"}
239 {fail
"delete all catchpoints"}
240 timeout
{fail
"(timeout) delete all catchpoints"}
243 send_gdb
"catch load gdb.base/solib2.sl\n"
245 -re
"Catchpoint \[0-9\]* .load gdb.base/solib2.sl.*$gdb_prompt $"\
246 {pass
"set specific catch load"}
248 {fail
"set specific catch load"}
249 timeout
{fail
"(timeout) set specific catch load"}
252 send_gdb
"continue\n"
254 -re
"Catchpoint \[0-9\] .loaded gdb.base/solib2.sl.*$gdb_prompt $"\
255 {pass
"caught specific solib load"}
257 {fail
"caught specific solib load"}
258 timeout
{fail
"(timeout) caught specific solib load"}
261 # Verify that we can catch an unload of a specific library.
263 send_gdb
"catch unload gdb.base/solib2.sl\n"
265 -re
"Catchpoint \[0-9\]* .unload gdb.base/solib2.sl.*$gdb_prompt $"\
266 {pass
"set specific catch unload"}
268 {fail
"set specific catch unload"}
269 timeout
{fail
"(timeout) set specific catch unload"}
272 send_gdb
"continue\n"
274 -re
"Catchpoint \[0-9\] .unloaded gdb.base/solib2.sl.*$gdb_prompt $"\
275 {pass
"caught specific solib unload"}
277 {fail
"caught specific solib unload"}
278 timeout
{fail
"(timeout) caught specific solib unload"}
281 # Verify that we can
set a catchpoint
on a specific library that
282 # happens not to be loaded by the
program. And
, that this catchpoint
283 # won
't trigger inappropriately when other shlibs are loaded.
285 send_gdb "break 55\n"
287 -re "Breakpoint \[0-9\]* at.*$gdb_prompt $"\
288 {pass "set break on shl_unload"}
290 {fail "set break on shl_unload"}
291 timeout {fail "(timeout) set break on shl_unload"}
294 send_gdb "break 58\n"
296 -re "Breakpoint \[0-9\]* at.*$gdb_prompt $"\
297 {pass "set break after shl_unload"}
299 {fail "set break after shl_unload"}
300 timeout {fail "(timeout) set break after shl_unload"}
303 send_gdb "catch load foobar.sl\n"
305 -re "Catchpoint \[0-9\]* .load foobar.sl.*$gdb_prompt $"\
306 {pass "set specific catch load for nonloaded shlib"}
308 {fail "set specific catch load for nonloaded shlib"}
309 timeout {fail "(timeout) set specific catch load for nonloaded shlib"}
312 send_gdb "catch unload foobar.sl\n"
314 -re "Catchpoint \[0-9\]* .unload foobar.sl.*$gdb_prompt $"\
315 {pass "set specific catch unload for nonloaded shlib"}
317 {fail "set specific catch unload for nonloaded shlib"}
318 timeout {fail "(timeout) set specific catch unload for nonloaded shlib"}
321 send_gdb "continue\n"
323 -re "Breakpoint \[0-9\]*.*$gdb_prompt $"\
324 {pass "specific catch load doesn't trigger inappropriately
"}
326 {fail
"specific catch load doesn't trigger inappropriately"}
327 timeout
{fail
"(timeout) specific catch load doesn't trigger inappropriately"}
330 send_gdb
"continue\n"
332 -re
"Breakpoint \[0-9\]*.*$gdb_prompt $"\
333 {pass
"specific catch unload doesn't trigger inappropriately"}
335 {fail
"specific catch unload doesn't trigger inappropriately"}
336 timeout
{fail
"(timeout) specific catch unload doesn't trigger inappropriately"}
339 # ??rehrauer
: There ought to be testpoints here that verify that
340 #
load/unload catchpoints can use conditionals
, can be temporary
,
341 # self
-disabling
, etc etc.
347 # Test stepping into an indirect
call in a shared library.
351 gdb_load $
{binfile
}_sl
352 gdb_test
"break main" ".*deferred. at .main..*" "break on main"
353 gdb_test
"run" ".*Breakpoint.*main.*solib.c.*" "hit breakpoint at main"
354 gdb_test
"break 45" "Breakpoint.*solib.c, line 45.*" "break on indirect call"
355 gdb_test
"continue" "Continuing.*solib.c:45.*" \
356 "continue to break on indirect call"
357 gdb_test
"step" "solib_main.*solib1.c:17.*return arg.arg.*" \
358 "step into indirect call from a shared library"