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