]>
Commit | Line | Data |
---|---|---|
f0fd9238 AC |
1 | # Copyright 2004 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 2 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, write to the Free Software | |
15 | # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | |
16 | ||
17 | ||
18 | # The program sigstep.c creates a very simple backtrace containing one | |
19 | # signal handler and signal trampoline. | |
20 | ||
21 | # This test runs the program up to the signal handler, and then | |
22 | # attempts to step/next the inferior back to 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 ${module}.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 | ||
75 | # Get us back into the handler | |
76 | rerun_to_main | |
77 | gdb_test "continue" ".* handler .*" "continue to handler for $i" | |
78 | ||
79 | set test "$i out of handler" | |
80 | gdb_test_multiple "$i" "${test}" { | |
81 | -re "done = 1;.*${gdb_prompt} $" { | |
82 | send_gdb "$i\n" | |
83 | exp_continue | |
84 | } | |
85 | -re "\} .. handler .*${gdb_prompt} $" { | |
86 | send_gdb "$i\n" | |
87 | exp_continue | |
88 | } | |
89 | -re "Program exited normally.*${gdb_prompt} $" { | |
42edda50 AC |
90 | setup_kfail powerpc-*-*bsd* gdb/1639 |
91 | fail "$test (program exited)" | |
61bcae62 AC |
92 | } |
93 | -re "(while ..done|return 0).*${gdb_prompt} $" { | |
94 | # After stepping out of a function /r signal-handler, GDB will | |
95 | # advance the inferior until it is at the first instruction of | |
96 | # a code-line. While typically things return to the middle of | |
97 | # the "while..." (and hence GDB advances the inferior to the | |
98 | # "return..." line) it is also possible for the return to land | |
99 | # on the first instruction of "while...". Accept both cases. | |
f0fd9238 AC |
100 | pass "$test" |
101 | } | |
102 | } | |
103 | } | |
104 | ||
105 | proc advancei { i } { | |
106 | global gdb_prompt | |
107 | set program_exited 0 | |
108 | ||
109 | # Get us back into the handler | |
110 | rerun_to_main | |
111 | gdb_test "continue" ".* handler .*" "continue to handler for $i" | |
112 | ||
113 | set test "$i into signal trampoline" | |
114 | gdb_test_multiple "$i" "${test}" { | |
115 | -re "done = 1;.*${gdb_prompt} $" { | |
116 | send_gdb "$i\n" | |
117 | exp_continue | |
118 | } | |
119 | -re "\} .. handler .*${gdb_prompt} $" { | |
120 | send_gdb "$i\n" | |
121 | exp_continue | |
122 | } | |
123 | -re "signal handler called.*${gdb_prompt} $" { | |
124 | pass "$test" | |
125 | } | |
f0fd9238 AC |
126 | -re "main .*${gdb_prompt} $" { |
127 | fail "$test (in main)" | |
128 | } | |
42edda50 AC |
129 | -re "Program exited normally.*${gdb_prompt} $" { |
130 | fail "$test (program exited)" | |
131 | set program_exited 1 | |
132 | } | |
f0fd9238 AC |
133 | -re "Make handler return now.*y or n. $" { |
134 | send_gdb "y\n" | |
135 | exp_continue | |
136 | } | |
137 | } | |
138 | ||
139 | set test "$i out of signal trampoline" | |
140 | gdb_test_multiple "$i" "${test}" { | |
141 | -re "while .*${gdb_prompt} $" { | |
142 | pass "$test (in main)" | |
143 | } | |
144 | -re "signal handler called.*${gdb_prompt} $" { | |
145 | send_gdb "$i\n" | |
146 | exp_continue | |
147 | } | |
148 | -re "return .*${gdb_prompt} $" { | |
149 | fail "$test (stepped)" | |
150 | } | |
151 | -re "Make .*frame return now.*y or n. $" { | |
152 | send_gdb "y\n" | |
153 | exp_continue | |
154 | } | |
42edda50 AC |
155 | -re "Program exited normally.*${gdb_prompt} $" { |
156 | kfail gdb/1639 "$test (program exited)" | |
157 | set program_exited 1 | |
158 | } | |
f0fd9238 AC |
159 | -re "The program is not being run.*${gdb_prompt} $" { |
160 | if { $program_exited } { | |
161 | # Previously kfailed with an exit | |
42edda50 | 162 | pass "$test (the program is not being run)" |
f0fd9238 | 163 | } else { |
42edda50 | 164 | fail "$test (the program is not being run)" |
f0fd9238 AC |
165 | } |
166 | } | |
167 | } | |
168 | } | |
169 | ||
170 | advance step | |
171 | advancei stepi | |
172 | ||
173 | advance next | |
174 | advancei nexti | |
175 | ||
176 | advancei finish | |
177 | advancei return |