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

Subversion Repositories openrisc_me

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

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

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

powered by: WebSVN 2.1.0

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