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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-old/] [gdb-6.8/] [gdb/] [testsuite/] [gdb.base/] [signals.exp] - Blame information for rev 816

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

Line No. Rev Author Line
1 24 jeremybenn
# Copyright 1997, 1998, 1999, 2003, 2004, 2007, 2008
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 [target_info exists gdb,nosignals] {
18
    verbose "Skipping signals.exp because of nosignals."
19
    continue
20
}
21
 
22
if $tracelevel then {
23
        strace $tracelevel
24
}
25
 
26
set prms_id 0
27
set bug_id 0
28
 
29
set testfile signals
30
set srcfile ${testfile}.c
31
set binfile ${objdir}/${subdir}/${testfile}
32
if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
33
    untested signals.exp
34
    return -1
35
}
36
 
37
# Create and source the file that provides information about the compiler
38
# used to compile the test case.
39
if [get_compiler_info ${binfile}] {
40
    return -1;
41
}
42
 
43
if {$hp_cc_compiler} {
44
    set void 0
45
} else {
46
    set void void
47
}
48
 
49
gdb_exit
50
gdb_start
51
 
52
# This will need to be updated as the exact list of signals changes,
53
# but I want to test that TARGET_SIGNAL_0, TARGET_SIGNAL_DEFAULT, and
54
# TARGET_SIGNAL_UNKNOWN are skipped.
55
 
56
proc test_handle_all_print {} {
57
    global timeout
58
    # Increase timeout and expect input buffer for large output from gdb.
59
    # Allow blank or TAB as whitespace characters.
60
    set oldtimeout $timeout
61
    set timeout [expr "$timeout + 360"]
62
    verbose "Timeout is now $timeout seconds" 2
63
    if { ![istarget "*-*-linux*"]
64
         && ( [istarget "*-*-gnu*"]
65
              || [istarget "*-*-mach*"] ) } {
66
        gdb_test "handle all print" "Signal\[   \]+Stop\[       \]+Print\[      \]+Pass to program\[    \]+Description\r\nSIGHUP\[      \]+Yes\[        \]+Yes\[        \]+Yes\[        \]+Hangup.*SIG63\[      \]+Yes\[        \]+Yes\[        \]+Yes\[        \]+Real-time event 63.*EXC_BREAKPOINT\[         \]+Yes\[        \]+Yes\[        \]+Yes\[        \]+Breakpoint"
67
    } else {
68
        gdb_test "handle all print" "Signal\[   \]+Stop\[       \]+Print\[      \]+Pass to program\[    \]+Description\r\nSIGHUP\[      \]+Yes\[        \]+Yes\[        \]+Yes\[        \]+Hangup.*SIG63\[      \]+Yes\[        \]+Yes\[        \]+Yes\[        \]+Real-time event 63.*"
69
    }
70
    set timeout $oldtimeout
71
    verbose "Timeout restored to $timeout seconds" 2
72
}
73
test_handle_all_print
74
 
75
gdb_exit
76
gdb_start
77
gdb_reinitialize_dir $srcdir/$subdir
78
gdb_load $binfile
79
 
80
if [runto_main] then {
81
 
82
    # Since count is a static variable outside main, runto_main is no
83
    # guarantee that count will be 0 at this point.
84
 
85
    gdb_test "set variable count = 0" ""
86
 
87
    # Test an inferior function call that takes a signal that hits a
88
    # breakpoint (with a false condition).  When GDB tries to run the
89
    # stack dummy, it will hit the breakpoint at handler.  Provided it
90
    # doesn't lose its cool, this is not a problem, it just has to
91
    # note that the breakpoint condition is false and keep going.
92
 
93
    # ...setup an always false conditional breakpoint
94
 
95
    gdb_test "break handler if 0" "Breakpoint \[0-9\]+ .*"
96
    gdb_test "set \$handler_breakpoint_number = \$bpnum" ""
97
 
98
    # ...setup the signal
99
 
100
    gdb_test "next" "signal \\(SIGUSR1.*" "next to signal"
101
    gdb_test "next" "alarm \\(.*" "next to alarm #1"
102
    gdb_test "next" "\\+\\+count; /\\* first \\*/" \
103
        "next to ++count #1"
104
    sleep 2
105
 
106
    # ...call the function
107
 
108
    gdb_test "p func1 ()" "^p func1 \\(\\)\r\n.\[0-9\]* = $void" \
109
        "p func1 () #1"
110
 
111
    # ...veryfiy that the cout was updated
112
 
113
    gdb_test "p count" "= 2" "p count #1"
114
 
115
    # Now run the same test but with a breakpoint that does stop.
116
 
117
    # ...set up the breakpoint and signal
118
 
119
    gdb_test "condition \$handler_breakpoint_number" "now unconditional\\."
120
    gdb_test "next" "alarm \\(.*" "next to alarm #2"
121
    gdb_test "next" "\\+\\+count; /\\* second \\*/" \
122
        "next to ++count #2"
123
    sleep 2
124
 
125
    # ...call the function, which is immediatly interrupted
126
 
127
    gdb_test "p func1 ()" \
128
"Breakpoint \[0-9\]*, handler.*
129
The program being debugged stopped while in a function called from GDB.*" \
130
        "p func1 () #2"
131
 
132
    # ...verify the backtrace
133
 
134
    gdb_test "backtrace" \
135
        "#0  handler.*#1  .signal handler called.*#2  func1.*#3  .function called from gdb.*#4.*main.*" \
136
        "backtrace from handler when calling func1"
137
 
138
    # ...and continue (silently returning)
139
 
140
    gdb_test "continue" "Continuing\\."
141
 
142
    # ...and then count should have been incremented
143
 
144
    gdb_test "p count" "= 5" "p count #2"
145
 
146
 
147
    # Verify that "info signals" produces reasonable output.
148
 
149
    gdb_test "info signals" "SIGHUP.*SIGINT.*SIGQUIT.*SIGILL.*SIGTRAP.*SIGABRT.*SIGEMT.*SIGFPE.*SIGKILL.*SIGBUS.*SIGSEGV.*SIGSYS.*SIGPIPE.*SIGALRM.*SIGTERM.*SIGURG.*SIGSTOP.*SIGTSTP.*SIGCONT.*SIGCHLD.*SIGTTIN.*SIGTTOU.*SIGIO.*SIGXCPU.*SIGXFSZ.*SIGVTALRM.*SIGPROF.*SIGWINCH.*SIGLOST.*SIGUSR1.*SIGUSR2.*SIGPWR.*SIGPOLL.*SIGWIND.*SIGPHONE.*SIGWAITING.*SIGLWP.*SIGDANGER.*SIGGRANT.*SIGRETRACT.*SIGMSG.*SIGSOUND.*SIGSAK.*SIGPRIO.*SIG33.*SIG34.*SIG35.*SIG36.*SIG37.*SIG38.*SIG39.*SIG40.*SIG41.*SIG42.*SIG43.*SIG44.*SIG45.*SIG46.*SIG47.*SIG48.*SIG49.*SIG50.*SIG51.*SIG52.*SIG53.*SIG54.*SIG55.*SIG56.*SIG57.*SIG58.*SIG59.*SIG60.*SIG61.*SIG62.*SIG63.*Use the \"handle\" command to change these tables.*" \
150
        "info signals"
151
 
152
    # Verify that "info signal" correctly handles an argument, be it a
153
    # symbolic signal name, or an integer ID.
154
 
155
    gdb_test "info signal SIGTRAP" \
156
        "SIGTRAP\[ \t\]*Yes\[ \t\]*Yes\[ \t\]*No\[ \t\]*Trace/breakpoint trap.*" \
157
        "info signal SIGTRAP"
158
 
159
    gdb_test "info signal 5" \
160
        "SIGTRAP\[ \t\]*Yes\[ \t\]*Yes\[ \t\]*No\[ \t\]*Trace/breakpoint trap.*" \
161
        "info signal 5"
162
 
163
    # Verify that "handle" with illegal arguments is gracefully, um,
164
    # handled.
165
 
166
    gdb_test "handle" \
167
        "Argument required .signal to handle.*" \
168
        "handle without arguments"
169
 
170
    gdb_test "handle SIGFOO" \
171
        "Unrecognized or ambiguous flag word: \"SIGFOO\".*" \
172
        "handle with bogus SIG"
173
 
174
    gdb_test "handle SIGHUP frump" \
175
        "Unrecognized or ambiguous flag word: \"frump\".*" \
176
        "handle SIG with bogus action"
177
 
178
    # Verify that "handle" can take multiple actions per SIG, and that
179
    # in the case of conflicting actions, that the rightmost action
180
    # "wins".
181
 
182
    gdb_test "handle SIGHUP print noprint" \
183
        "SIGHUP\[ \t\]*No\[ \t\]*No\[ \t\]*Yes\[ \t\]*Hangup.*" \
184
        "handle SIG with multiple conflicting actions"
185
 
186
    # Exercise all the various actions.  (We don't care what the
187
    # outcome is, this is just to ensure that they all can be parsed.)
188
 
189
    gdb_test "handle SIGHUP print noprint stop nostop ignore noignore pass nopass" \
190
        "Signal.*" \
191
        "handle SIG parses all legal actions"
192
 
193
    # Verify that we can "handle" multiple signals at once,
194
    # interspersed with actions.
195
 
196
    gdb_test "handle SIG63 print SIGILL" \
197
        "SIGILL\[ \t\]*Yes\[ \t\]*Yes\[ \t\]*Yes\[ \t\]*Illegal instruction.*SIG63\[ \t\]*Yes\[ \t\]*Yes\[ \t\]*Yes\[ \t\]*Real-time event 63.*" \
198
        "handle multiple SIGs"
199
 
200
    # Verify that "handle" can take a numeric argument for the signal
201
    # ID, rather than a symbolic name.  (This may not be portable;
202
    # works for HP-UX.)
203
 
204
    # Also note that this testpoint overrides SIGTRAP, which on HP-UX
205
    # at least, is used to implement single-steps and breakpoints.
206
    # Don't expect to run the inferior after this!
207
 
208
    set test "override SIGTRAP"
209
    gdb_test_multiple "handle 5 nopass" "$test" {
210
        -re "SIGTRAP is used by the debugger.*Are you sure you want to change it.*y or n.*" {
211
            gdb_test "y" \
212
                "SIGTRAP\[ \t\]*Yes\[ \t\]*Yes\[ \t\]*No\[ \t\]*Trace/breakpoint trap.*" \
213
                "$test"
214
        }
215
    }
216
 
217
    # GDB doesn't seem to allow numeric signal IDs larger than 15.  Verify
218
    # that restriction.  ??rehrauer: Not sure if this is a feature or a
219
    # bug, actually.  Why is the range 1-15?
220
 
221
    gdb_test "handle 58" \
222
        "Only signals 1-15 are valid as numeric signals.*Use \"info signals\" for a list of symbolic signals.*" \
223
        "invalid signal number rejected"
224
 
225
    # Verify that we can accept a signal ID range (number-number).
226
    # ??rehrauer: This feature isn't documented on the quick-reference
227
    # card.
228
 
229
    gdb_test "handle 13-15" \
230
        "SIGPIPE.*SIGALRM.*SIGTERM.*" \
231
        "handle multiple SIGs via integer range"
232
 
233
    # Bizarrely enough, GDB also allows you to reverse the range stat,
234
    # stop IDs.  E.g., "3-1" and "1-3" mean the same thing.  Probably
235
    # this isn't documented, but the code anticipates it, so we'd best
236
    # test it...
237
 
238
    gdb_test "handle 15-13" \
239
        "SIGPIPE.*SIGALRM.*SIGTERM.*" \
240
        "handle multiple SIGs via reverse integer range"
241
 
242
    # SIGINT is used by the debugger as well.  Verify that we can
243
    # change our minds about changing it.
244
 
245
    set test "override SIGINT"
246
    gdb_test_multiple "handle SIGINT nopass" "$test" {
247
        -re "SIGINT is used by the debugger.*Are you sure you want to change it.*y or n.*" {
248
            gdb_test_multiple "n" "$test" {
249
                -re "Not confirmed, unchanged.*Signal.*$gdb_prompt $"  {
250
                    # "Signal ..." should not be in the output.
251
                    kfail gdb/1707 "$test"
252
                }
253
                -re "Not confirmed, unchanged.*$gdb_prompt $" {
254
                    pass "$test"
255
                }
256
            }
257
        }
258
    }
259
 
260
    # Verify that GDB responds gracefully to the "signal" command with
261
    # a missing argument.
262
 
263
    gdb_test "signal" \
264
        "Argument required .signal number..*" \
265
        "signal without arguments disallowed"
266
 
267
    # Verify that we can successfully send a signal other than 0 to
268
    # the inferior.  (This probably causes the inferior to run away.
269
    # Be prepared to rerun to main for further testing.)
270
 
271
    gdb_test "signal SIGUSR1" "Breakpoint.*handler.*"
272
    gdb_test "bt" \
273
        "#0  handler .*#1  .signal handler called.*\#2 .*main.*" \
274
        "backtrace for SIGUSR1"
275
}
276
 
277
return 0

powered by: WebSVN 2.1.0

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