b4afcb54cfb54595e37ea7500f75f6903964f9f2
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.gdb / complaints.exp
1 # Copyright 2002, 2004, 2007, 2008, 2009, 2010 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 <http://www.gnu.org/licenses/>.
15
16 # This file was written by Andrew Cagney (cagney at redhat dot com),
17 # derived from xfullpath.exp (written by Joel Brobecker), derived from
18 # selftest.exp (written by Rob Savoye).
19
20 if $tracelevel then {
21 strace $tracelevel
22 }
23
24
25 # are we on a target board
26 if { [is_remote target] || ![isnative] } then {
27 return
28 }
29
30 proc setup_test { executable } {
31 global gdb_prompt
32 global timeout
33
34 # load yourself into the debugger
35 # This can take a relatively long time, particularly for testing where
36 # the executable is being accessed over a network, or where gdb does not
37 # support partial symbols for a particular target and has to load the
38 # entire symbol table. Set the timeout to 10 minutes, which should be
39 # adequate for most environments (it *has* timed out with 5 min on a
40 # SPARCstation SLC under moderate load, so this isn't unreasonable).
41 # After gdb is started, set the timeout to 30 seconds for the duration
42 # of this test, and then back to the original value.
43
44 set oldtimeout $timeout
45 set timeout 600
46 verbose "Timeout is now $timeout seconds" 2
47
48 global gdb_file_cmd_debug_info
49 set gdb_file_cmd_debug_info "unset"
50
51 set result [gdb_load $executable]
52 set timeout $oldtimeout
53 verbose "Timeout is now $timeout seconds" 2
54
55 if { $result != 0 } then {
56 return -1
57 }
58
59 if { $gdb_file_cmd_debug_info != "debug" } then {
60 untested "No debug information, skipping testcase."
61 return -1
62 }
63
64 # Set a breakpoint at main
65 gdb_test "break captured_command_loop" \
66 "Breakpoint.*at.* file.*, line.*" \
67 "breakpoint in captured_command_loop"
68
69 # run yourself
70 # It may take a very long time for the inferior gdb to start (lynx),
71 # so we bump it back up for the duration of this command.
72 set timeout 600
73
74 set description "run until breakpoint at captured_command_loop"
75 send_gdb "run -nw\n"
76 gdb_expect {
77 -re "Starting program.*Breakpoint \[0-9\]+,.*captured_command_loop .data.* at .*main.c:.*$gdb_prompt $" {
78 pass "$description"
79 }
80 -re "Starting program.*Breakpoint \[0-9\]+,.*captured_command_loop .data.*$gdb_prompt $" {
81 xfail "$description (line numbers scrambled?)"
82 }
83 -re "vfork: No more processes.*$gdb_prompt $" {
84 fail "$description (out of virtual memory)"
85 set timeout $oldtimeout
86 verbose "Timeout is now $timeout seconds" 2
87 return -1
88 }
89 -re ".*$gdb_prompt $" {
90 fail "$description"
91 set timeout $oldtimeout
92 verbose "Timeout is now $timeout seconds" 2
93 return -1
94 }
95 timeout {
96 fail "$description (timeout)"
97 }
98 }
99
100 set timeout $oldtimeout
101 verbose "Timeout is now $timeout seconds" 2
102
103 return 0
104 }
105
106 proc test_initial_complaints { } {
107
108 global gdb_prompt
109
110 # Unsupress complaints
111 gdb_test "set stop_whining = 2"
112
113 # Prime the system
114 gdb_test "call complaint (&symfile_complaints, \"Register a complaint\")" \
115 "During symbol reading, Register a complaint."
116
117 # Check that the complaint was inserted and where
118 gdb_test "print symfile_complaints->root->fmt" \
119 ".\[0-9\]+ =.*\"Register a complaint\""
120
121 # Re-issue the first message #1
122 gdb_test "call complaint (&symfile_complaints, symfile_complaints->root->fmt)" \
123 "During symbol reading, Register a complaint."
124
125 # Check that there is only one thing in the list
126 gdb_test "print symfile_complaints->root->next == &complaint_sentinel" \
127 ".\[0-9\]+ = 1" "list has one entry"
128
129 # Add a second complaint, expect it
130 gdb_test "call complaint (&symfile_complaints, \"Testing! Testing! Testing!\")" \
131 "During symbol reading, Testing. Testing. Testing.."
132
133 return 0
134 }
135
136 proc test_serial_complaints { } {
137
138 global gdb_prompt
139
140 gdb_test_exact "call clear_complaints (&symfile_complaints, 1, 0)" "" "serial start"
141
142 # Prime the system
143 send_gdb "call complaint (&symfile_complaints, \"serial line 1\")\n"
144 gdb_expect {
145 -re "During symbol reading...serial line 1...$gdb_prompt " {
146 pass "serial line 1"
147 }
148 "$gdb_prompt" {
149 fail "serial line 1"
150 }
151 timeout {
152 fail "serial line 1 (timeout)"
153 }
154 }
155
156 # Add a second complaint, expect it
157 send_gdb "call complaint (&symfile_complaints, \"serial line 2\")\n"
158 gdb_expect {
159 -re "serial line 2...$gdb_prompt " {
160 pass "serial line 2"
161 }
162 "$gdb_prompt" {
163 fail "serial line 2"
164 }
165 timeout {
166 fail "serial line 2 (timeout)"
167 }
168 }
169
170 send_gdb "call clear_complaints (&symfile_complaints, 1, 0)\n"
171 gdb_expect {
172 -re "\r\n\r\n$gdb_prompt " {
173 pass "serial end"
174 }
175 "$gdb_prompt" {
176 fail "serial end"
177 }
178 timeout {
179 fail "serial end (timeout)"
180 }
181 }
182
183 return 0
184 }
185
186 # For short complaints, all are the same
187
188 proc test_short_complaints { } {
189
190 global gdb_prompt
191
192 gdb_test_exact "call clear_complaints (&symfile_complaints, 1, 1)" "" "short start"
193
194 # Prime the system
195 send_gdb "call complaint (&symfile_complaints, \"short line 1\")\n"
196 gdb_expect {
197 -re "short line 1...$gdb_prompt " {
198 pass "short line 1"
199 }
200 "$gdb_prompt" {
201 fail "short line 1"
202 }
203 timeout {
204 fail "short line 1 (timeout)"
205 }
206 }
207
208 # Add a second complaint, expect it
209 send_gdb "call complaint (&symfile_complaints, \"short line 2\")\n"
210 gdb_expect {
211 -re "short line 2...$gdb_prompt " {
212 pass "short line 2"
213 }
214 "$gdb_prompt" {
215 fail "short line 2"
216 }
217 timeout {
218 fail "short line 2 (timeout)"
219 }
220 }
221
222 send_gdb "call clear_complaints (&symfile_complaints, 1, 0)\n"
223 gdb_expect {
224 -re "\r\n\r\n$gdb_prompt " {
225 pass "short end"
226 }
227 "$gdb_prompt" {
228 fail "short end"
229 }
230 timeout {
231 fail "short end (timeout)"
232 }
233 }
234
235 return 0
236 }
237
238 # Check that nothing comes out when there haven't been any real
239 # complaints. Note that each test is really checking the previous
240 # command.
241
242 proc test_empty_complaint { cmd msg } {
243 global gdb_prompt
244 send_gdb $cmd
245 gdb_expect {
246 -re "\r\n\r\n$gdb_prompt " {
247 fail $msg
248 }
249 "\r\n$gdb_prompt" {
250 pass $msg
251 }
252 timeout {
253 fail "$msg (timeout)"
254 }
255 }
256
257 }
258
259 proc test_empty_complaints { } {
260
261 test_empty_complaint "call clear_complaints(&symfile_complaints,0,0)\n" \
262 "empty non-verbose non-noisy clear"
263 test_empty_complaint "call clear_complaints(&symfile_complaints,1,0)\n" \
264 "empty verbose non-noisy clear"
265 test_empty_complaint "call clear_complaints(&symfile_complaints,1,1)\n" \
266 "empty verbose noisy clear"
267 test_empty_complaint "call clear_complaints(&symfile_complaints,0,1)\n" \
268 "empty non-verbose noisy clear"
269
270 return 0
271 }
272
273 # Find a pathname to a file that we would execute if the shell was asked
274 # to run $arg using the current PATH.
275
276 proc find_gdb { arg } {
277
278 # If the arg directly specifies an existing executable file, then
279 # simply use it.
280
281 if [file executable $arg] then {
282 return $arg
283 }
284
285 set result [which $arg]
286 if [string match "/" [ string range $result 0 0 ]] then {
287 return $result
288 }
289
290 # If everything fails, just return the unqualified pathname as default
291 # and hope for best.
292
293 return $arg
294 }
295
296 # Run the test with self.
297 # Copy the file executable file in case this OS doesn't like to edit its own
298 # text space.
299
300 set GDB_FULLPATH [find_gdb $GDB]
301
302 # Remove any old copy lying around.
303 remote_file host delete x$tool
304
305 gdb_start
306
307 set file [remote_download host $GDB_FULLPATH x$tool]
308
309 set setup_result [setup_test $file ]
310 if {$setup_result <0} then {
311 return -1
312 }
313
314 test_initial_complaints
315 test_serial_complaints
316 test_short_complaints
317 test_empty_complaints
318
319 gdb_exit;
320 catch "remote_file host delete $file";
This page took 0.036588 seconds and 3 git commands to generate.