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