OpenCores
URL https://opencores.org/ocsvn/openrisc_me/openrisc_me/trunk

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [gnu-src/] [gdb-7.2/] [gdb/] [testsuite/] [gdb.base/] [solib.exp] - Blame information for rev 330

Details | Compare with Previous | View Log

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

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.