Commit | Line | Data |
---|---|---|
3e3ffd2b MC |
1 | # Copyright 2002, 2004 |
2 | # Free Software Foundation, Inc. | |
54951bd7 AC |
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 | ||
54951bd7 AC |
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 | |
3e3ffd2b MC |
51 | |
52 | set result [gdb_load $executable] | |
54951bd7 AC |
53 | set timeout $oldtimeout |
54 | verbose "Timeout is now $timeout seconds" 2 | |
55 | ||
3e3ffd2b MC |
56 | if { [lindex $result 0] != "" } then { |
57 | return -1 | |
3bdcad15 MI |
58 | } else { |
59 | if { [lsearch -exact [lrange $result 1 end] "nodebug"] >= 0 } then { | |
60 | untested "No debug information, skipping testcase." | |
61 | return -1 | |
62 | } | |
3e3ffd2b MC |
63 | } |
64 | ||
54951bd7 AC |
65 | # Set a breakpoint at main |
66 | gdb_test "break captured_command_loop" \ | |
67 | "Breakpoint.*at.* file.*, line.*" \ | |
68 | "breakpoint in captured_command_loop" | |
69 | ||
70 | # run yourself | |
71 | # It may take a very long time for the inferior gdb to start (lynx), | |
72 | # so we bump it back up for the duration of this command. | |
73 | set timeout 600 | |
74 | ||
75 | set description "run until breakpoint at captured_command_loop" | |
76 | send_gdb "run -nw\n" | |
77 | gdb_expect { | |
78 | -re "Starting program.*Breakpoint \[0-9\]+,.*captured_command_loop .data.* at .*main.c:.*$gdb_prompt $" { | |
79 | pass "$description" | |
80 | } | |
81 | -re "Starting program.*Breakpoint \[0-9\]+,.*captured_command_loop .data.*$gdb_prompt $" { | |
82 | xfail "$description (line numbers scrambled?)" | |
83 | } | |
84 | -re "vfork: No more processes.*$gdb_prompt $" { | |
85 | fail "$description (out of virtual memory)" | |
86 | set timeout $oldtimeout | |
87 | verbose "Timeout is now $timeout seconds" 2 | |
88 | return -1 | |
89 | } | |
90 | -re ".*$gdb_prompt $" { | |
91 | fail "$description" | |
92 | set timeout $oldtimeout | |
93 | verbose "Timeout is now $timeout seconds" 2 | |
94 | return -1 | |
95 | } | |
96 | timeout { | |
97 | fail "$description (timeout)" | |
98 | } | |
99 | } | |
100 | ||
101 | set timeout $oldtimeout | |
102 | verbose "Timeout is now $timeout seconds" 2 | |
103 | ||
104 | return 0 | |
105 | } | |
106 | ||
9dd34b2b | 107 | proc test_initial_complaints { } { |
54951bd7 AC |
108 | |
109 | global gdb_prompt | |
110 | ||
111 | # Unsupress complaints | |
112 | gdb_test "set stop_whining = 2" | |
113 | ||
114 | # Prime the system | |
115 | gdb_test "call complaint (&symfile_complaints, \"Register a complaint\")" \ | |
116 | "During symbol reading, Register a complaint." | |
117 | ||
118 | # Check that the complaint was inserted and where | |
119 | gdb_test "print symfile_complaints->root->fmt" \ | |
120 | ".\[0-9\]+ =.*\"Register a complaint\"" | |
121 | ||
122 | # Re-issue the first message #1 | |
123 | gdb_test "call complaint (&symfile_complaints, symfile_complaints->root->fmt)" \ | |
124 | "During symbol reading, Register a complaint." | |
125 | ||
126 | # Check that there is only one thing in the list | |
127 | gdb_test "print symfile_complaints->root->next == &complaint_sentinel" \ | |
128 | ".\[0-9\]+ = 1" "list has one entry" | |
129 | ||
130 | # Add a second complaint, expect it | |
131 | gdb_test "call complaint (&symfile_complaints, \"Testing! Testing! Testing!\")" \ | |
132 | "During symbol reading, Testing. Testing. Testing.." | |
133 | ||
134 | return 0 | |
135 | } | |
136 | ||
137 | proc test_serial_complaints { } { | |
138 | ||
139 | global gdb_prompt | |
140 | ||
141 | gdb_test_exact "call clear_complaints (&symfile_complaints, 1, 0)" "" "serial start" | |
142 | ||
143 | # Prime the system | |
144 | send_gdb "call complaint (&symfile_complaints, \"serial line 1\")\n" | |
145 | gdb_expect { | |
146 | -re "During symbol reading...serial line 1...$gdb_prompt " { | |
147 | pass "serial line 1" | |
148 | } | |
149 | "$gdb_prompt" { | |
150 | fail "serial line 1" | |
151 | } | |
152 | timeout { | |
153 | fail "serial line 1 (timeout)" | |
154 | } | |
155 | } | |
156 | ||
157 | # Add a second complaint, expect it | |
158 | send_gdb "call complaint (&symfile_complaints, \"serial line 2\")\n" | |
159 | gdb_expect { | |
160 | -re "serial line 2...$gdb_prompt " { | |
161 | pass "serial line 2" | |
162 | } | |
163 | "$gdb_prompt" { | |
164 | fail "serial line 2" | |
165 | } | |
166 | timeout { | |
167 | fail "serial line 2 (timeout)" | |
168 | } | |
169 | } | |
170 | ||
171 | send_gdb "call clear_complaints (&symfile_complaints, 1, 0)\n" | |
172 | gdb_expect { | |
173 | -re "\r\n\r\n$gdb_prompt " { | |
174 | pass "serial end" | |
175 | } | |
176 | "$gdb_prompt" { | |
177 | fail "serial end" | |
178 | } | |
179 | timeout { | |
180 | fail "serial end (timeout)" | |
181 | } | |
182 | } | |
183 | ||
184 | return 0 | |
185 | } | |
186 | ||
187 | # For short complaints, all are the same | |
188 | ||
189 | proc test_short_complaints { } { | |
190 | ||
191 | global gdb_prompt | |
192 | ||
193 | gdb_test_exact "call clear_complaints (&symfile_complaints, 1, 1)" "" "short start" | |
194 | ||
195 | # Prime the system | |
196 | send_gdb "call complaint (&symfile_complaints, \"short line 1\")\n" | |
197 | gdb_expect { | |
198 | -re "short line 1...$gdb_prompt " { | |
199 | pass "short line 1" | |
200 | } | |
201 | "$gdb_prompt" { | |
202 | fail "short line 1" | |
203 | } | |
204 | timeout { | |
205 | fail "short line 1 (timeout)" | |
206 | } | |
207 | } | |
208 | ||
209 | # Add a second complaint, expect it | |
210 | send_gdb "call complaint (&symfile_complaints, \"short line 2\")\n" | |
211 | gdb_expect { | |
212 | -re "short line 2...$gdb_prompt " { | |
213 | pass "short line 2" | |
214 | } | |
215 | "$gdb_prompt" { | |
216 | fail "short line 2" | |
217 | } | |
218 | timeout { | |
219 | fail "short line 2 (timeout)" | |
220 | } | |
221 | } | |
222 | ||
223 | send_gdb "call clear_complaints (&symfile_complaints, 1, 0)\n" | |
224 | gdb_expect { | |
225 | -re "\r\n\r\n$gdb_prompt " { | |
226 | pass "short end" | |
227 | } | |
228 | "$gdb_prompt" { | |
229 | fail "short end" | |
230 | } | |
231 | timeout { | |
232 | fail "short end (timeout)" | |
233 | } | |
234 | } | |
235 | ||
236 | return 0 | |
237 | } | |
238 | ||
9dd34b2b AC |
239 | # Check that nothing comes out when there haven't been any real |
240 | # complaints. Note that each test is really checking the previous | |
241 | # command. | |
242 | ||
243 | proc test_empty_complaint { cmd msg } { | |
244 | global gdb_prompt | |
245 | send_gdb $cmd | |
246 | gdb_expect { | |
247 | -re "\r\n\r\n$gdb_prompt " { | |
248 | fail $msg | |
249 | } | |
250 | "\r\n$gdb_prompt" { | |
251 | pass $msg | |
252 | } | |
253 | timeout { | |
254 | fail "$msg (timeout)" | |
255 | } | |
256 | } | |
257 | ||
258 | } | |
259 | ||
260 | proc test_empty_complaints { } { | |
261 | ||
262 | test_empty_complaint "call clear_complaints(&symfile_complaints,0,0)\n" \ | |
263 | "empty non-verbose non-noisy clear" | |
264 | test_empty_complaint "call clear_complaints(&symfile_complaints,1,0)\n" \ | |
265 | "empty verbose non-noisy clear" | |
266 | test_empty_complaint "call clear_complaints(&symfile_complaints,1,1)\n" \ | |
267 | "empty verbose noisy clear" | |
268 | test_empty_complaint "call clear_complaints(&symfile_complaints,0,1)\n" \ | |
269 | "empty non-verbose noisy clear" | |
270 | ||
271 | return 0 | |
272 | } | |
273 | ||
54951bd7 AC |
274 | # Find a pathname to a file that we would execute if the shell was asked |
275 | # to run $arg using the current PATH. | |
276 | ||
277 | proc find_gdb { arg } { | |
278 | ||
279 | # If the arg directly specifies an existing executable file, then | |
280 | # simply use it. | |
281 | ||
282 | if [file executable $arg] then { | |
283 | return $arg | |
284 | } | |
285 | ||
286 | set result [which $arg] | |
287 | if [string match "/" [ string range $result 0 0 ]] then { | |
288 | return $result | |
289 | } | |
290 | ||
291 | # If everything fails, just return the unqualified pathname as default | |
292 | # and hope for best. | |
293 | ||
294 | return $arg | |
295 | } | |
296 | ||
297 | # Run the test with self. | |
298 | # Copy the file executable file in case this OS doesn't like to edit its own | |
299 | # text space. | |
300 | ||
301 | set GDB_FULLPATH [find_gdb $GDB] | |
302 | ||
303 | # Remove any old copy lying around. | |
304 | remote_file host delete x$tool | |
305 | ||
306 | gdb_start | |
307 | ||
308 | set file [remote_download host $GDB_FULLPATH x$tool] | |
309 | ||
310 | set setup_result [setup_test $file ] | |
311 | if {$setup_result <0} then { | |
312 | return -1 | |
313 | } | |
314 | ||
9dd34b2b | 315 | test_initial_complaints |
54951bd7 AC |
316 | test_serial_complaints |
317 | test_short_complaints | |
9dd34b2b | 318 | test_empty_complaints |
54951bd7 AC |
319 | |
320 | gdb_exit; | |
321 | catch "remote_file host delete $file"; |