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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-old/] [gdb-7.1/] [gdb/] [testsuite/] [gdb.base/] [solib.exp] - Blame information for rev 862

Go to most recent revision | Details | Compare with Previous | View Log

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

powered by: WebSVN 2.1.0

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