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