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

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [gnu-src/] [gdb-6.8/] [gdb/] [testsuite/] [gdb.base/] [sigstep.exp] - Blame information for rev 157

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 24 jeremybenn
# Copyright 2004, 2005, 2006, 2007, 2008 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 .
15
 
16
 
17
# The program sigstep.c creates a very simple backtrace containing one
18
# signal handler and signal trampoline.  A flag is set and then the
19
# handler returns.  This is repeated at infinitum.
20
 
21
# This test runs the program up to the signal handler, and then
22
# attempts to step/next out of the handler and back into main.
23
 
24
if [target_info exists gdb,nosignals] {
25
    verbose "Skipping sigstep.exp because of nosignals."
26
    continue
27
}
28
 
29
if $tracelevel then {
30
    strace $tracelevel
31
}
32
 
33
set prms_id 0
34
set bug_id 0
35
 
36
set testfile sigstep
37
set srcfile ${testfile}.c
38
set binfile ${objdir}/${subdir}/${testfile}
39
if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
40
    untested "Couldn't compile ${srcfile}.c"
41
    return -1
42
}
43
 
44
# get things started
45
gdb_exit
46
gdb_start
47
gdb_reinitialize_dir $srcdir/$subdir
48
gdb_load ${binfile}
49
 
50
gdb_test "display/i \$pc"
51
 
52
# Advance to main
53
if { ![runto_main] } then {
54
    gdb_suppress_tests;
55
}
56
 
57
# Pass all the alarms straight through (but verbosely)
58
# gdb_test "handle SIGALRM print pass nostop"
59
# gdb_test "handle SIGVTALRM print pass nostop"
60
# gdb_test "handle SIGPROF print pass nostop"
61
 
62
# Run to the signal handler, validate the backtrace.
63
gdb_test "break handler"
64
gdb_test "continue" ".* handler .*" "continue to stepi handler"
65
send_gdb "bt\n"
66
gdb_expect_list "backtrace for nexti" ".*$gdb_prompt $" {
67
    "\[\r\n\]+.0 \[^\r\n\]* handler "
68
    "\[\r\n\]+.1  .signal handler called."
69
    "\[\r\n\]+.2 \[^\r\n\]* main .*"
70
}
71
 
72
proc advance { i } {
73
    global gdb_prompt
74
    set prefix "$i from handler"
75
 
76
    # Get us back into the handler
77
    gdb_test "continue" ".* handler .*" "$prefix; continue to handler"
78
 
79
    set test "$prefix; leave handler"
80
    gdb_test_multiple "$i" "${test}" {
81
        -re "Could not insert single-step breakpoint.*$gdb_prompt $" {
82
            setup_kfail "sparc*-*-openbsd*" gdb/1736
83
            fail "$test (could not insert single-step breakpoint)"
84
        }
85
        -re "done = 1;.*${gdb_prompt} $" {
86
            send_gdb "$i\n"
87
            exp_continue -continue_timer
88
        }
89
        -re "\} .. handler .*${gdb_prompt} $" {
90
            send_gdb "$i\n"
91
            exp_continue -continue_timer
92
        }
93
        -re "Program exited normally.*${gdb_prompt} $" {
94
            setup_kfail powerpc-*-*bsd* gdb/1639
95
            fail "$test (program exited)"
96
        }
97
        -re "(while ..done|done = 0).*${gdb_prompt} $" {
98
            # After stepping out of a function /r signal-handler, GDB will
99
            # advance the inferior until it is at the first instruction of
100
            # a code-line.  While typically things return to the middle of
101
            # the "while..." (and hence GDB advances the inferior to the
102
            # "return..." line) it is also possible for the return to land
103
            # on the first instruction of "while...".  Accept both cases.
104
            pass "$test"
105
        }
106
    }
107
}
108
 
109
proc advancei { i } {
110
    global gdb_prompt
111
    set prefix "$i from handleri"
112
    set program_exited 0
113
 
114
    # Get us back into the handler
115
    gdb_test "continue" ".* handler .*" "$prefix; continue to handler"
116
 
117
    set test "$prefix; leave handler"
118
    gdb_test_multiple "$i" "${test}" {
119
        -re "Cannot insert breakpoint 0.*${gdb_prompt} $" {
120
            # Some platforms use a special read-only page for signal
121
            # trampolines.  We can't set a breakpoint there, and we
122
            # don't gracefully fall back to single-stepping.
123
            setup_kfail "i?86-*-linux*" gdb/1736
124
            setup_kfail "*-*-openbsd*" gdb/1736
125
            fail "$test (could not set breakpoint)"
126
            return
127
        }
128
        -re "Could not insert single-step breakpoint.*$gdb_prompt $" {
129
            setup_kfail "sparc*-*-openbsd*" gdb/1736
130
            fail "$test (could not insert single-step breakpoint)"
131
        }
132
        -re "Breakpoint \[0-9\]*, handler .*${gdb_prompt} $" {
133
            fail "$test (hit breakpoint again)"
134
        }
135
        -re "done = 1;.*${gdb_prompt} $" {
136
            send_gdb "$i\n"
137
            exp_continue -continue_timer
138
        }
139
        -re "\} .. handler .*${gdb_prompt} $" {
140
            send_gdb "$i\n"
141
            exp_continue -continue_timer
142
        }
143
        -re "signal handler called.*${gdb_prompt} $" {
144
            pass "$test"
145
        }
146
        -re "main .*${gdb_prompt} $" {
147
            fail "$test (in main)"
148
        }
149
        -re "Program exited normally.*${gdb_prompt} $" {
150
            fail "$test (program exited)"
151
            set program_exited 1
152
        }
153
        -re "Make handler return now.*y or n. $" {
154
            send_gdb "y\n"
155
            exp_continue -continue_timer
156
        }
157
    }
158
 
159
    set test "$prefix; leave signal trampoline"
160
    gdb_test_multiple "$i" "${test}" {
161
        -re "while .*${gdb_prompt} $" {
162
            pass "$test (in main)"
163
        }
164
        -re "signal handler called.*${gdb_prompt} $" {
165
            send_gdb "$i\n"
166
            exp_continue -continue_timer
167
        }
168
        -re "return .*${gdb_prompt} $" {
169
            fail "$test (stepped)"
170
        }
171
        -re "Make .*frame return now.*y or n. $" {
172
            send_gdb "y\n"
173
            exp_continue -continue_timer
174
        }
175
        -re "Program exited normally.*${gdb_prompt} $" {
176
            kfail gdb/1639 "$test (program exited)"
177
            set program_exited 1
178
        }
179
        -re "The program is not being run.*${gdb_prompt} $" {
180
            if { $program_exited } {
181
                # Previously kfailed with an exit
182
                pass "$test (the program is not being run)"
183
            } else {
184
                fail "$test (the program is not being run)"
185
            }
186
        }
187
    }
188
}
189
 
190
# Check that we can step/next our way out of a signal handler.
191
 
192
advance step
193
advancei stepi
194
 
195
advance next
196
advancei nexti
197
 
198
advancei finish
199
advancei return
200
gdb_test "set done = 1" "" "Set done as return will have skipped it"
201
 
202
 
203
# Check that we can step/next our way into / over a signal handler.
204
 
205
# There are at least the following cases: breakpoint @pc VS breakpoint
206
# in handler VS step / next / continue.
207
 
208
# Use the real-time itimer, as otherwize the process never gets enough
209
# time to expire the timer.
210
 
211
delete_breakpoints
212
set infinite_loop [gdb_get_line_number {while (!done)}]
213
gdb_test "set itimer = itimer_real"
214
gdb_test "break [gdb_get_line_number {done = 0}]"
215
 
216
# Try stepping when there's a signal pending, and a breakpoint at the
217
# handler.  Should step into the signal handler.
218
 
219
proc skip_to_handler { i } {
220
    global gdb_prompt
221
    global infinite_loop
222
    set prefix "$i to handler"
223
 
224
    # Run around to the done
225
    # You can add more patterns to this if you need them.
226
    set test "$prefix; resync"
227
    gdb_test_multiple "continue" "$test" {
228
        -re "done = 0.*$gdb_prompt " {
229
            pass "$test"
230
        }
231
    }
232
 
233
    # Advance to the infinite loop
234
    gdb_test "advance $infinite_loop" "" "$prefix; advance to infinite loop"
235
 
236
    # Make the signal pending
237
    sleep 1
238
 
239
    # Insert / remove the handler breakpoint.
240
    gdb_test "break handler" "" "$prefix; break handler"
241
    gdb_test "$i" " handler .*" "$prefix; performing $i"
242
    gdb_test "clear handler" "" "$prefix; clear handler"
243
}
244
 
245
skip_to_handler step
246
skip_to_handler next
247
skip_to_handler continue
248
 
249
# Try stepping when there's a signal pending, and a breakpoint at the
250
# handler's entry-point.  Should step into the signal handler stopping
251
# at the entry-point.
252
 
253
# Some systems (e.x., GNU/Linux as of 2004-08-30), when delivering a
254
# signal, resume the process at the first instruction of the signal
255
# handler and not the first instruction of the signal trampoline.  The
256
# stack is constructed such that the signal handler still appears to
257
# have been called by the trampoline code.  This test checks that it
258
# is possible to stop the inferior, even at that first instruction.
259
 
260
proc skip_to_handler_entry { i } {
261
    global gdb_prompt
262
    global infinite_loop
263
    set prefix "$i to handler entry"
264
 
265
    # Run around to the done
266
    # You can add more patterns to this if you need them.
267
    set test "$prefix; resync"
268
    gdb_test_multiple "continue" "$test" {
269
        -re "done = 0.*$gdb_prompt " {
270
            pass "$test"
271
        }
272
    }
273
 
274
    # Advance to the infinite loop
275
    gdb_test "advance $infinite_loop" "" "$prefix; advance to infinite loop"
276
 
277
    # Make the signal pending
278
    sleep 1
279
 
280
    # Insert / remove the handler breakpoint.
281
    gdb_test "break *handler" "" "$prefix; break handler"
282
    gdb_test "$i" " handler .*" "$prefix; performing $i"
283
    gdb_test "clear *handler" "" "$prefix; clear handler"
284
}
285
 
286
skip_to_handler_entry step
287
skip_to_handler_entry next
288
skip_to_handler_entry continue
289
 
290
# Try stepping when there's a signal pending but no breakpoints.
291
# Should skip the handler advancing to the next line.
292
 
293
proc skip_over_handler { i } {
294
    global gdb_prompt
295
    global infinite_loop
296
    set prefix "$i over handler"
297
 
298
    # Run around to the done
299
    # You can add more patterns to this if you need them.
300
    set test "$prefix; resync"
301
    gdb_test_multiple "continue" "$test" {
302
        -re "done = 0.*$gdb_prompt " {
303
            pass "$test"
304
        }
305
    }
306
 
307
    # Advance to the infinite loop
308
    gdb_test "advance $infinite_loop" "" "$prefix; advance to infinite loop"
309
 
310
    # Make the signal pending
311
    sleep 1
312
 
313
    gdb_test "$i" "done = 0.*" "$prefix; performing $i"
314
}
315
 
316
skip_over_handler step
317
skip_over_handler next
318
skip_over_handler continue
319
 
320
# Try stepping when there's a signal pending, a pre-existing
321
# breakpoint at the current instruction, and a breakpoint in the
322
# handler.  Should advance to the signal handler.
323
 
324
proc breakpoint_to_handler { i } {
325
    global gdb_prompt
326
    global infinite_loop
327
    set prefix "$i on breakpoint, to handler"
328
 
329
    # Run around to the done
330
    # You can add more patterns to this if you need them.
331
    set test "$prefix; resync"
332
    gdb_test_multiple "continue" "$test" {
333
        -re "done = 0.*$gdb_prompt " {
334
            pass "$test"
335
        }
336
    }
337
 
338
    gdb_test "break $infinite_loop" "" "$prefix; break infinite loop"
339
    gdb_test "break handler" "" "$prefix; break handler"
340
 
341
    # Continue to the infinite loop
342
    gdb_test "continue" "while ..done.*" "$prefix; continue to infinite loop"
343
 
344
    # Make the signal pending
345
    sleep 1
346
 
347
    setup_kfail "i*86-*-*" gdb/1738
348
    gdb_test "$i" " handler .*" "$prefix; performing $i"
349
    gdb_test "clear $infinite_loop" "" "$prefix; clear infinite loop"
350
    gdb_test "clear handler" "" "$prefix; clear handler"
351
}
352
 
353
breakpoint_to_handler step
354
breakpoint_to_handler next
355
breakpoint_to_handler continue
356
 
357
# Try stepping when there's a signal pending, and a breakpoint at the
358
# handler's entry instruction and a breakpoint at the current
359
# instruction.  Should step into the signal handler and breakpoint at
360
# that entry instruction.
361
 
362
# Some systems (e.x., GNU/Linux as of 2004-08-30), when delivering a
363
# signal, resume the process at the first instruction of the signal
364
# handler and not the first instruction of the signal trampoline.  The
365
# stack is constructed such that the signal handler still appears to
366
# have been called by the trampoline code.  This test checks that it
367
# is possible to stop the inferior, even at that first instruction.
368
 
369
proc breakpoint_to_handler_entry { i } {
370
    global gdb_prompt
371
    global infinite_loop
372
    set prefix "$i on breakpoint, to handler entry"
373
 
374
    # Run around to the done
375
    # You can add more patterns to this if you need them.
376
    set test "$prefix; resync"
377
    gdb_test_multiple "continue" "$test" {
378
        -re "done = 0.*$gdb_prompt " {
379
            pass "$test"
380
        }
381
    }
382
 
383
    gdb_test "break $infinite_loop" "" "$prefix; break infinite loop"
384
    gdb_test "break *handler" "" "$prefix; break handler"
385
 
386
    # Continue to the infinite loop
387
    gdb_test "continue" "while ..done.*" "$prefix; continue to infinite loop"
388
 
389
    # Make the signal pending
390
    sleep 1
391
 
392
    setup_kfail "i*86-*-*" gdb/1738
393
    gdb_test "$i" " handler .*" "$prefix; performing $i"
394
    gdb_test "clear $infinite_loop" "" "$prefix; clear infinite loop"
395
    gdb_test "clear *handler" "" "$prefix; clear handler"
396
}
397
 
398
breakpoint_to_handler_entry step
399
breakpoint_to_handler_entry next
400
breakpoint_to_handler_entry continue
401
 
402
# Try stepping when there's a signal pending, and a pre-existing
403
# breakpoint at the current instruction, and no breakpoint in the
404
# handler.  Should advance to the next line.
405
 
406
proc breakpoint_over_handler { i } {
407
    global gdb_prompt
408
    global infinite_loop
409
    set prefix "$i on breakpoint, skip handler"
410
 
411
    # Run around to the done
412
    # You can add more patterns to this if you need them.
413
    set test "$prefix; resync"
414
    gdb_test_multiple "continue" "$test" {
415
        -re "done = 0.*$gdb_prompt " {
416
            pass "$test"
417
        }
418
    }
419
 
420
    gdb_test "break $infinite_loop" "" "$prefix; break infinite loop"
421
 
422
    # Continue to the infinite loop
423
    gdb_test "continue" "while ..done.*" "$prefix; continue to infinite loop"
424
 
425
    # Make the signal pending
426
    sleep 1
427
 
428
    gdb_test "$i" "done = 0.*" "$prefix; performing $i"
429
    gdb_test "clear $infinite_loop" "" "$prefix; clear infinite loop"
430
}
431
 
432
breakpoint_over_handler step
433
breakpoint_over_handler next
434
breakpoint_over_handler continue

powered by: WebSVN 2.1.0

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