Commit | Line | Data |
---|---|---|
766de354 | 1 | # Copyright (C) 1992, 1994, 1995 Free Software Foundation, Inc. |
633e6238 PS |
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 | |
5c6f833b | 15 | # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ |
633e6238 PS |
16 | |
17 | # Please email any bugs, comments, and/or additions to this file to: | |
18 | # bug-gdb@prep.ai.mit.edu | |
19 | ||
20 | # This file was written by Fred Fish. (fnf@cygnus.com) | |
21 | ||
22 | if $tracelevel then { | |
23 | strace $tracelevel | |
24 | } | |
25 | ||
26 | set prms_id 0 | |
27 | set bug_id 0 | |
28 | ||
1b5b9581 FF |
29 | set testfile "list" |
30 | set binfile ${objdir}/${subdir}/${testfile} | |
31 | if { [compile "${srcdir}/${subdir}/list0.c -g -c -o ${binfile}0.o"] != "" } { | |
32 | perror "Couldn't compile ${testfile}0.c to object" | |
33 | return -1 | |
34 | } | |
35 | if { [compile "${srcdir}/${subdir}/list1.c -g -c -o ${binfile}1.o"] != "" } { | |
36 | perror "Couldn't compile ${testfile}1.c to object" | |
37 | return -1 | |
38 | } | |
39 | if { [compile "${binfile}0.o ${binfile}1.o -o ${binfile}"] != "" } { | |
40 | perror "Couldn't link ${testfile}." | |
41 | return -1 | |
42 | } | |
633e6238 | 43 | |
1b5b9581 FF |
44 | execute_anywhere "rm -f ${binfile}.ci" |
45 | if { [compile "-E ${srcdir}/${subdir}/compiler.c > ${binfile}.ci"] != "" } { | |
46 | perror "Couldn't make ${testfile}.ci file" | |
47 | return -1 | |
633e6238 PS |
48 | } |
49 | ||
50 | # | |
51 | # Local utility proc just to set and verify listsize | |
52 | # Return 1 if success, 0 if fail. | |
53 | # | |
54 | ||
55 | proc set_listsize { arg } { | |
56 | global prompt | |
57 | ||
58 | send "set listsize $arg\n" | |
59 | expect { | |
5c6f833b | 60 | -re "set listsize $arg\[\r\n\]+$prompt $" {} |
633e6238 PS |
61 | -re ".*$prompt $" { fail "setting listsize to $arg" ; return 0 } |
62 | timeout { fail "set listsize to $arg (timeout)" ; return 0 } | |
63 | } | |
64 | ||
65 | send "show listsize\n" | |
66 | expect { | |
67 | -re "Number of source lines .* is $arg.\r\n.*$prompt $" {} | |
68 | -re ".*$prompt $" { fail "listsize not set to $arg" ; return 0 } | |
69 | timeout { fail "show listsize (timeout)" ; return 0 } | |
70 | } | |
71 | return 1 | |
72 | } | |
73 | ||
74 | # | |
75 | # Test display of listsize lines around a given line number. | |
76 | # | |
77 | ||
78 | proc test_listsize {} { | |
79 | global prompt | |
80 | ||
81 | # Show default size | |
82 | ||
83 | send "show listsize\n" | |
84 | expect { | |
85 | -re "Number of source lines gdb will list by default is 10.*$prompt $" { | |
86 | pass "show default list size" | |
87 | } | |
88 | -re ".*$prompt $" { | |
89 | fail "show default listsize (10)" | |
90 | } | |
91 | timeout { | |
92 | fail "show listsize (timeout)" | |
93 | } | |
94 | } | |
95 | ||
96 | # Show the default lines | |
5c6f833b | 97 | # The second case is for optimized code, it is still correct. |
633e6238 PS |
98 | |
99 | # This doesn't work for COFF targets. | |
100 | setup_xfail "a29k-*-udi" | |
101 | send "list\n" | |
102 | expect { | |
a04abecc | 103 | -re "1\[ \t\]+#include \"list0.h\".*10\[ \t\]+x = 0;\r\n$prompt $" { |
5c6f833b JL |
104 | pass "list default lines around main" |
105 | } | |
106 | -re "2.*11\[ \t\]+foo .x\[+)\]+;\r\n$prompt $" { | |
107 | pass "list default lines around main" | |
633e6238 PS |
108 | } |
109 | -re ".*$prompt $" { | |
110 | fail "list default lines around main" | |
111 | } | |
112 | timeout { | |
113 | fail "list default lines around main (timeout)" | |
114 | } | |
115 | } | |
116 | ||
117 | # Ensure we can limit printouts to one line | |
118 | ||
119 | if [ set_listsize 1 ] then { | |
120 | setup_xfail "*-*-*" | |
121 | send "list 1\n" | |
122 | expect { | |
123 | -re "1\[ \t\]+#include \"list0.h\"\r\n$prompt $" { | |
124 | pass "list line 1 with listsize 1" | |
125 | } | |
126 | -re "list 1\r\n$prompt $" { | |
127 | fail "list line 1 with listsize 1" | |
128 | } | |
129 | -re ".*$prompt $" { | |
130 | fail "list line 1 with listsize 1" | |
131 | } | |
132 | timeout { | |
133 | fail "list line 1 with listsize 1 (timeout)" | |
134 | } | |
135 | } | |
136 | ||
137 | setup_xfail "*-*-*" | |
138 | send "list 2\n" | |
139 | expect { | |
140 | -re "2\[ \t\]+\r\n$prompt $" { | |
141 | pass "list line 2 with listsize 1" | |
142 | } | |
143 | -re "list 2\r\n$prompt $" { | |
144 | fail "list line 2 with listsize 1" | |
145 | } | |
146 | -re ".*$prompt $" { | |
147 | fail "list line 2 with listsize 1" | |
148 | } | |
149 | timeout { | |
150 | fail "list line 2 with listsize 1 (timeout)" | |
151 | } | |
152 | } | |
153 | } | |
154 | ||
155 | # Try just two lines | |
156 | ||
157 | if [ set_listsize 2 ] then { | |
158 | send "list 1\n" | |
159 | expect { | |
160 | -re "1\[ \t\]+#include \"list0.h\"\r\n$prompt $" { | |
161 | pass "list line 1 with listsize 2" | |
162 | } | |
163 | -re ".*$prompt $" { | |
164 | fail "list line 1 with listsize 2" | |
165 | } | |
166 | timeout { | |
167 | fail "list line 1 with listsize 2 (timeout)" | |
168 | } | |
169 | } | |
170 | ||
171 | send "list 2\n" | |
172 | expect { | |
173 | -re "1\[ \t\]+#include \"list0.h\"\r\n2\[ \t\]+\r\n$prompt $" { | |
174 | pass "list line 2 with listsize 2" | |
175 | } | |
176 | -re ".*$prompt $" { | |
177 | fail "list line 2 with listsize 2" | |
178 | } | |
179 | timeout { | |
180 | fail "list line 2 with listsize 2 (timeout)" | |
181 | } | |
182 | } | |
183 | ||
184 | send "list 3\n" | |
185 | expect { | |
186 | -re "2\[ \t\]+\r\n3\[ \t\]+main \[)(\]+\r\n$prompt $" { | |
187 | pass "list line 3 with listsize 2" | |
188 | } | |
189 | -re ".*$prompt $" { | |
190 | fail "list line 3 with listsize 2" | |
191 | } | |
192 | timeout { | |
193 | fail "list line 3 with listsize 2 (timeout)" | |
194 | } | |
195 | } | |
196 | } | |
197 | ||
198 | # Try small listsize > 1 that is an odd number | |
199 | ||
200 | if [ set_listsize 3 ] then { | |
201 | setup_xfail "*-*-*" | |
202 | send "list 1\n" | |
203 | expect { | |
204 | -re "1\[ \t\]+#include \"list0.h\"2\[ \t\]+\r\n$prompt $" { | |
205 | pass "list line 1 with listsize 3" | |
206 | } | |
207 | -re "1\[ \t\]+#include \"list0.h\"\r\n$prompt $" { | |
208 | fail "list line 1 with listsize 3" | |
209 | } | |
210 | -re ".*$prompt $" { | |
211 | fail "list line 1 with listsize 3" | |
212 | } | |
213 | timeout { | |
214 | fail "list line 1 with listsize 3 (timeout)" | |
215 | } | |
216 | } | |
217 | ||
218 | setup_xfail "*-*-*" | |
219 | send "list 2\n" | |
220 | expect { | |
221 | -re "1\[ \t\]+#include \"list0.h\".*3\[ \t\]+main \[)(\]+\r\n$prompt $" { | |
222 | pass "list line 2 with listsize 3" | |
223 | } | |
224 | -re "1\[ \t\]+#include \"list0.h\"\r\n2\[ \t\]+\r\n$prompt $" { | |
225 | fail "list line 2 with listsize 3" | |
226 | } | |
227 | -re ".*$prompt $" { | |
228 | fail "list line 2 with listsize 3" | |
229 | } | |
230 | timeout { | |
231 | fail "list line 2 with listsize 3 (timeout)" | |
232 | } | |
233 | } | |
234 | ||
235 | setup_xfail "*-*-*" | |
236 | send "list 3\n" | |
237 | expect { | |
238 | -re "2\[ \t\]+\r\n3\[ \t\]+main \[(\]+\[)\]+\r\n4\[ \t\]+\{\r\n$prompt $" { | |
239 | pass "list line 3 with listsize 3" | |
240 | } | |
241 | -re "2\[ \t\]+\r\n3\[ \t\]+main \[)(\]+\r\n$prompt $" { | |
242 | fail "list line 3 with listsize 3" | |
243 | } | |
244 | -re ".*$prompt $" { | |
245 | fail "list line 3 with listsize 3" | |
246 | } | |
247 | timeout { | |
248 | fail "list line 3 with listsize 3 (timeout)" | |
249 | } | |
250 | } | |
251 | } | |
252 | ||
253 | # Try small listsize > 2 that is an even number. | |
254 | ||
255 | if [ set_listsize 4 ] then { | |
256 | send "list 1\n" | |
257 | expect { | |
258 | -re "1\[ \t\]+#include \"list0.h\"\r\n2\[ \t\]+\r\n$prompt $" { | |
259 | pass "list line 1 with listsize 4" | |
260 | } | |
261 | -re ".*$prompt $" { | |
262 | fail "list line 1 with listsize 4" | |
263 | } | |
264 | timeout { | |
265 | fail "list line 1 with listsize 4 (timeout)" | |
266 | } | |
267 | } | |
268 | ||
269 | send "list 2\n" | |
270 | expect { | |
271 | -re "1\[ \t\]+#include \"list0.h\".*3\[ \t\]+main \[)(\]+\r\n$prompt $" { | |
272 | pass "list line 2 with listsize 4" | |
273 | } | |
274 | -re ".*$prompt $" { | |
275 | fail "list line 2 with listsize 4" | |
276 | } | |
277 | timeout { | |
278 | fail "list line 2 with listsize 4 (timeout)" | |
279 | } | |
280 | } | |
281 | ||
282 | send "list 3\n" | |
283 | expect { | |
284 | -re "1\[ \t\]+#include \"list0.h\".*4\[ \t\]+\{\r\n$prompt $" { | |
285 | pass "list line 3 with listsize 4" | |
286 | } | |
287 | -re ".*$prompt $" { | |
288 | fail "list line 3 with listsize 4" | |
289 | } | |
290 | timeout { | |
291 | fail "list line 3 with listsize 4 (timeout)" | |
292 | } | |
293 | } | |
294 | ||
295 | send "list 4\n" | |
296 | expect { | |
297 | -re "2\[ \t\]+\r\n.*5\[ \t\]+int x;\r\n$prompt $" { | |
298 | pass "list line 4 with listsize 4" | |
299 | } | |
300 | -re ".*$prompt $" { | |
301 | fail "list line 4 with listsize 4" | |
302 | } | |
303 | timeout { | |
304 | fail "list line 4 with listsize 4 (timeout)" | |
305 | } | |
306 | } | |
307 | } | |
308 | ||
309 | # Try a size larger than the entire file. | |
310 | ||
311 | if [ set_listsize 100 ] then { | |
312 | send "list 1\n" | |
313 | expect { | |
a04abecc | 314 | -re "1\[ \t\]+#include \"list0.h\".*\r\n42\[ \t\]+\}\r\n$prompt $" { |
633e6238 PS |
315 | pass "list line 1 with listsize 100" |
316 | } | |
317 | timeout { | |
318 | fail "list line 1 with listsize 100" | |
319 | } | |
320 | } | |
321 | ||
322 | send "list 10\n" | |
323 | expect { | |
a04abecc KH |
324 | -re "1\[ \t\]+#include \"list0.h\".*\r\n42\[ \t\]+\}\r\n$prompt $" { |
325 | pass "list line 10 with listsize 100" | |
633e6238 PS |
326 | } |
327 | timeout { | |
a04abecc | 328 | fail "list line 10 with listsize 100" |
633e6238 PS |
329 | } |
330 | } | |
331 | } | |
332 | ||
333 | # Try listsize of 0 which suppresses printing. | |
334 | ||
335 | send "set listsize 0\n" | |
336 | expect { | |
5c6f833b | 337 | -re "set listsize 0\[\r\n\]+$prompt $" { |
633e6238 PS |
338 | setup_xfail "*-*-*" |
339 | send "show listsize\n" | |
340 | expect { | |
341 | -re "Number of source lines .* is 0.\r\n.*$prompt $" { | |
342 | pass "listsize of 0 displays as 0" | |
343 | } | |
344 | -re "Number of source lines .* is unlimited.\r\n.*$prompt $" { | |
345 | fail "listsize of 0 displays as unlimited" | |
346 | } | |
347 | -re ".*$prompt $" { | |
348 | fail "listsize not set to unlimited (0)" | |
349 | } | |
350 | timeout { | |
351 | fail "show listsize (timeout)" | |
352 | } | |
353 | } | |
354 | send "list 1\n" | |
355 | expect { | |
5c6f833b | 356 | -re "list 1\[\r\n\]+$prompt $" { |
633e6238 PS |
357 | pass "listsize of 0 suppresses output" |
358 | } | |
359 | -re ".*$prompt $" { | |
360 | fail "listsize of 0 should suppress output" | |
361 | } | |
362 | timeout { | |
363 | fail "listsize of 0 suppresses output (timeout)" | |
364 | } | |
365 | } | |
366 | } | |
367 | -re ".*$prompt $" { | |
368 | fail "setting listsize to 0" | |
369 | } | |
370 | timeout { | |
371 | fail "set listsize to 0 (timeout)" | |
372 | } | |
373 | } | |
374 | ||
375 | # Try listsize of -1 which is special, and means unlimited. | |
376 | ||
377 | send "set listsize -1\n" | |
378 | expect { | |
5c6f833b | 379 | -re "set listsize -1\[\r\n\]+$prompt $" { |
633e6238 PS |
380 | send "show listsize\n" |
381 | expect { | |
382 | -re "Number of source lines .* is unlimited.\r\n.*$prompt $" { | |
383 | pass "listsize of -1 displays as unlimited" | |
384 | } | |
385 | -re ".*$prompt $" { | |
386 | fail "listsize not set to unlimited (-1)" | |
387 | } | |
388 | timeout { | |
389 | fail "show listsize (timeout)" | |
390 | } | |
391 | } | |
392 | setup_xfail "*-*-*" | |
393 | send "list 1\n" | |
394 | expect { | |
395 | -re "1\[ \t\]+#include .*\r\n39\[ \t\]+\}\r\n$prompt $" { | |
396 | pass "list line 1 with unlimited listsize" | |
397 | } | |
5c6f833b | 398 | -re "list 1\[\r\n\]+$prompt $" { |
633e6238 PS |
399 | fail "listsize of -1 (unlimited) suppresses output" |
400 | } | |
401 | timeout { | |
402 | fail "list line 1 with unlimited listsize" | |
403 | } | |
404 | } | |
405 | } | |
406 | -re ".*$prompt $" { | |
407 | fail "setting listsize to -1" | |
408 | } | |
409 | timeout { | |
410 | fail "set listsize to -1 (timeout)" | |
411 | } | |
412 | } | |
413 | } | |
414 | ||
415 | # | |
416 | # Test "list filename:number" for C include file | |
417 | # | |
418 | ||
419 | proc test_list_include_file {} { | |
420 | global prompt | |
421 | ||
633e6238 PS |
422 | # FIXME Fails for COFF as well, I think. |
423 | setup_xfail "a29k-*-udi" | |
424 | send "list list0.h:1\n" | |
425 | expect { | |
426 | -re "1\[ \t\]+/\[*\]+ An include file .*5\[ \t\]+foo \[(\]+x\[)\]+\r\n$prompt $" { | |
427 | pass "list line 1 in include file" | |
428 | } | |
429 | -re "No source file named list0.h.\r\n$prompt $" { | |
430 | fail "list line 1 in include file" | |
431 | } | |
432 | -re ".*$prompt $" { | |
433 | fail "list line 1 in include file" | |
434 | } | |
435 | timeout { | |
436 | fail "list line 1 in include file (timeout)" | |
437 | } | |
438 | } | |
439 | ||
633e6238 PS |
440 | # FIXME Fails for COFF as well, I think. |
441 | setup_xfail "a29k-*-udi" | |
442 | send "list list0.h:100\n" | |
443 | expect { | |
444 | -re "Line number 95 out of range; .*list0.h has 36 lines.\r\n$prompt $" { | |
445 | pass "list message for lines past EOF" | |
446 | } | |
447 | -re "No source file named list0.h.\r\n$prompt $" { | |
448 | fail "list message for lines past EOF" | |
449 | } | |
450 | -re ".*$prompt $" { | |
451 | fail "list message for lines past EOF" | |
452 | } | |
453 | timeout { | |
454 | fail "list message for lines past EOF (timeout)" | |
455 | } | |
456 | } | |
457 | } | |
458 | ||
459 | # | |
460 | # Test "list filename:number" for C source file | |
461 | # | |
462 | ||
463 | proc test_list_filename_and_number {} { | |
464 | global prompt | |
465 | ||
466 | set testcnt 0 | |
467 | ||
468 | send "list list0.c:1\n" | |
469 | expect { | |
470 | -re "1\[ \t\]+#include \"list0.h\".*5\[ \t\]+int x;\r\n$prompt $" { | |
471 | incr testcnt | |
472 | } | |
473 | -re ".*$prompt $" { fail "list list0.c:1" ; return } | |
474 | timeout { fail "list list0.c:1" ; return } | |
475 | } | |
476 | send "list list0.c:10\n" | |
477 | expect { | |
478 | -re "5\[ \t\]+int x;.*14\[ \t\]+foo .x\[+)\]+;\r\n$prompt $" { | |
479 | incr testcnt | |
480 | } | |
481 | -re ".*$prompt $" { fail "list list.c:10" ; return } | |
482 | timeout { fail "list list.c:10" ; return } | |
483 | } | |
484 | send "list list1.c:1\n" | |
485 | expect { | |
486 | -re "1\[ \t\]+void.*5\[ \t\]+printf \[(\]+.*\[)\]+;\r\n$prompt $" { | |
487 | incr testcnt | |
488 | } | |
489 | -re ".*$prompt $" { fail "list list1.c:1" ; return } | |
490 | timeout { fail "list list1.c:1" ; return } | |
491 | } | |
492 | send "list list1.c:12\n" | |
493 | expect { | |
494 | -re "7\[ \t\]+long_line \[(\]+.*\[)\]+;.*14\[ \t\]+\}\r\n.*$prompt $" { | |
495 | incr testcnt | |
496 | } | |
497 | -re ".*$prompt $" { fail "list list1.c:12" ; return } | |
498 | timeout { fail "list list1.c:12" ; return } | |
499 | } | |
500 | pass "list filename:number ($testcnt tests)" | |
501 | } | |
502 | ||
503 | # | |
504 | # Test "list function" for C source file | |
505 | # | |
506 | ||
507 | proc test_list_function {} { | |
508 | global prompt | |
1b5b9581 | 509 | global gcc_compiled |
633e6238 PS |
510 | |
511 | # gcc appears to generate incorrect debugging information for code | |
512 | # in include files, which breaks this test. | |
766de354 | 513 | # SunPRO cc is the second case below, it's also correct. |
633e6238 PS |
514 | setup_xfail "a29k-*-udi" |
515 | send "list main\n" | |
516 | expect { | |
a04abecc | 517 | -re "1\[ \t\]+#include .*8\[ \t\]+breakpoint\[(\]\[)\]+;\r\n$prompt $" { |
633e6238 PS |
518 | pass "list function in source file 1" |
519 | } | |
5c6f833b | 520 | -re "5\[ \t\]+int x;.*14\[ \t\]+foo \[(\]+.*\[)\]+;\r\n$prompt $" { |
766de354 PS |
521 | pass "list function in source file 1" |
522 | } | |
633e6238 PS |
523 | -re ".*$prompt $" { fail "list main" ; return } |
524 | timeout { fail "list main" ; return } | |
525 | } | |
526 | ||
527 | # Ultrix gdb takes the second case below; it's also correct. | |
766de354 | 528 | # SunPRO cc is the third case. |
633e6238 PS |
529 | send "list bar\n" |
530 | expect { | |
531 | -re "1\[ \t\]+void.*8\[ \t\]+\}\r\n$prompt $" { | |
532 | pass "list function in source file 2" | |
533 | } | |
534 | -re "1\[ \t\]+void.*7\[ \t\]*long_line ..;\r\n$prompt $" { | |
535 | pass "list function in source file 2" | |
536 | } | |
766de354 PS |
537 | -re "1\[ \t\]+void.*7\[ \t\]*long_line ..;.*9\[ \t\]*\r\n$prompt $" { |
538 | pass "list function in source file 2" | |
539 | } | |
633e6238 PS |
540 | -re ".*$prompt $" { fail "list bar" ; return } |
541 | timeout { fail "list bar" ; return } | |
542 | } | |
543 | ||
544 | # Test "list function" for C include file | |
545 | # Ultrix gdb is the second case, still correct. | |
766de354 | 546 | # SunPRO cc is the third case. |
5c6f833b | 547 | setup_xfail "powerpc-*-*" |
1b5b9581 | 548 | if {$gcc_compiled} then { setup_xfail "rs6000-*-*" } |
633e6238 PS |
549 | send "list foo\n" |
550 | expect { | |
551 | -re "2\[ \t\]+including file.*11\[ \t\]+bar \[(\]+.*\[)\]+;\r\n$prompt $" { | |
552 | pass "list function in include file" | |
553 | } | |
554 | -re "1\[ \t\]+/. An include file.*10\[ \t\]+bar \[(\]+.*\[)\]+;\r\n$prompt $" { | |
555 | pass "list function in include file" | |
556 | } | |
766de354 PS |
557 | -re "3\[ \t\]+.*12\[ \t\]+bar \[(\]+.*\[)\]+;\r\n$prompt $" { |
558 | pass "list function in include file" | |
559 | } | |
633e6238 PS |
560 | -re ".*main \[)(\]+.*$prompt $" { |
561 | fail "list function in include file" | |
562 | } | |
563 | -re ".*$prompt $" { fail "list foo (in include file)" ; return } | |
564 | timeout { fail "list foo (timeout)" ; return } | |
565 | } | |
566 | } | |
567 | ||
568 | proc test_list_forward {} { | |
569 | global prompt | |
570 | ||
571 | set testcnt 0 | |
572 | ||
573 | send "list list0.c:10\n" | |
574 | expect { | |
575 | -re "5\[ \t\]+int x;.*14\[ \t\]+foo \[(\]+.*\[)\]+;\r\n$prompt $" { incr testcnt } | |
576 | -re ".*$prompt $" { fail "list list0.c:10" ; return } | |
577 | timeout { fail "list list0.c:10" ; return } | |
578 | } | |
579 | ||
580 | send "list\n" | |
581 | expect { | |
582 | -re "15\[ \t\]+foo \[(\]+.*\[)\]+;.*24\[ \t\]+foo \[(\]+.*\[)\]+;\r\n$prompt $" { incr testcnt } | |
583 | -re ".*$prompt $" { fail "list 15-24" ; return } | |
584 | timeout { fail "list 15-24 (timeout)" ; return } | |
585 | } | |
586 | ||
587 | send "list\n" | |
588 | expect { | |
a04abecc | 589 | -re "25\[ \t\]+foo \[(\]+.*\[)\]+;.*34\[ \t\]+foo \[(\]+.*\[)\]+;\r\n$prompt $" { incr testcnt } |
633e6238 PS |
590 | -re ".*$prompt $" { fail "list 25-34" ; return } |
591 | timeout { fail "list 25-34 (timeout)" ; return } | |
592 | } | |
593 | ||
594 | send "list\n" | |
595 | expect { | |
a04abecc KH |
596 | -re "35\[ \t\]+foo \[(\]+.*\[)\]+;.*42\[ \t\]+\}\r\n$prompt $" { incr testcnt } |
597 | -re ".*$prompt $" { fail "list 35-42" ; return } | |
598 | timeout { fail "list 35-42 (timeout)" ; return } | |
633e6238 PS |
599 | } |
600 | ||
601 | pass "successive list commands to page forward ($testcnt tests)" | |
602 | } | |
603 | ||
604 | proc test_list_backwards {} { | |
605 | global prompt | |
606 | ||
607 | set testcnt 0 | |
608 | ||
a04abecc | 609 | send "list list0.c:33\n" |
633e6238 | 610 | expect { |
a04abecc KH |
611 | -re "28\[ \t\]+foo \[(\]+.*\[)\]+;.*37\[ \t\]+\r\n$prompt $" { incr testcnt } |
612 | -re ".*$prompt $" { fail "list list0.c:33" ; return } | |
613 | timeout { fail "list list0.c:33" ; return } | |
633e6238 PS |
614 | } |
615 | ||
616 | send "list -\n" | |
617 | expect { | |
a04abecc KH |
618 | -re "18\[ \t\]+foo \[(\]+.*\[)\]+;.*27\[ \t\]+foo \[(\]+.*\[)\]+;\r\n$prompt $" { incr testcnt } |
619 | -re ".*$prompt $" { fail "list 18-27" ; return } | |
620 | timeout { fail "list 18-27 (timeout)" ; return } | |
633e6238 PS |
621 | } |
622 | ||
623 | send "list -\n" | |
624 | expect { | |
a04abecc KH |
625 | -re "8\[ \t\]+breakpoint\[(\]\[)\];.*17\[ \t\]+foo \[(\]+.*\[)\]+;\r\n$prompt $" { incr testcnt } |
626 | -re ".*$prompt $" { fail "list 8-17" ; return } | |
627 | timeout { fail "list 8-17 (timeout)" ; return } | |
633e6238 PS |
628 | } |
629 | ||
630 | send "list -\n" | |
631 | expect { | |
a04abecc KH |
632 | -re "1\[ \t\]+#include .*7\[ \t\]+set_debug_traps\[(\]\[)\]+;\r\n$prompt $" { incr testcnt } |
633 | -re ".*$prompt $" { fail "list 1-7" ; return } | |
634 | timeout { fail "list 1-7 (timeout)" ; return } | |
633e6238 PS |
635 | } |
636 | ||
637 | pass "$testcnt successive \"list -\" commands to page backwards" | |
638 | } | |
639 | ||
640 | # | |
641 | # Test "list first,last" | |
642 | # | |
643 | ||
644 | proc test_list_range {} { | |
645 | global prompt | |
646 | ||
647 | send "list list0.c:2,list0.c:5\n" | |
648 | expect { | |
649 | -re "2\[ \t\]+\r\n3\[ \t\]+main \[)(\]+.*5\[ \t\]+int x;\r\n$prompt $" { | |
650 | pass "list range; filename:line1,filename:line2" | |
651 | } | |
652 | -re ".*$prompt $" { fail "list list0.c:2,list0.c:5" } | |
653 | timeout { fail "list list0.c:2,list0.c:5" } | |
654 | } | |
655 | ||
656 | send "list 2,5\n" | |
657 | expect { | |
658 | -re "2\[ \t\]+\r\n3\[ \t\]+main \[)(\]+.*5\[ \t\]+int x;\r\n$prompt $" { | |
659 | pass "list range; line1,line2" | |
660 | } | |
661 | -re ".*$prompt $" { fail "list 2,5" } | |
662 | timeout { fail "list 2,5" } | |
663 | } | |
664 | ||
665 | #send "list -1,6\n" | |
666 | #expect { | |
667 | #-re "Line number 0 out of range; .*list0.c has 39 lines.\r\n$prompt $" { | |
668 | #pass "list range; lower bound negative" | |
669 | #} | |
670 | #-re ".*$prompt $" { fail "list -1,6" } | |
671 | #timeout { fail "list -1,6" } | |
672 | #} | |
673 | ||
674 | #send "list -100,-40\n" | |
675 | #expect { | |
676 | #-re "Line number -60 out of range; .*list0.c has 39 lines.\r\n$prompt $" { | |
677 | #pass "list range; both bounds negative" | |
678 | #} | |
679 | #-re ".*$prompt $" { fail "-100,-40" } | |
680 | #timeout { fail "-100,-40" } | |
681 | #} | |
682 | ||
a04abecc | 683 | send "list 30,43\n" |
633e6238 | 684 | expect { |
a04abecc | 685 | -re "30\[ \t\]+foo \[(\]+.*\[)\]+;.*42\[ \t\]+\}\r\n$prompt $" { |
633e6238 PS |
686 | pass "list range; upper bound past EOF" |
687 | } | |
a04abecc KH |
688 | -re ".*$prompt $" { fail "list 30,43" } |
689 | timeout { fail "list 30,43" } | |
633e6238 PS |
690 | } |
691 | ||
a04abecc | 692 | send "list 43,100\n" |
633e6238 | 693 | expect { |
a04abecc | 694 | -re "Line number 43 out of range; .*list0.c has 42 lines.\r\n$prompt $" { |
633e6238 PS |
695 | pass "list range; both bounds past EOF" |
696 | } | |
a04abecc KH |
697 | -re ".*$prompt $" { fail "43,100" } |
698 | timeout { fail "43,100" } | |
633e6238 PS |
699 | } |
700 | ||
701 | send "list list0.c:2,list1.c:17\n" | |
702 | expect { | |
703 | -re "Specified start and end are in different files.\r\n$prompt $" { | |
704 | pass "list range, must be same files" | |
705 | } | |
706 | -re ".*$prompt $" { fail "list0.c:2,list1.c:17" } | |
707 | timeout { fail "list0.c:2,list1.c:17" } | |
708 | } | |
709 | } | |
710 | ||
711 | # | |
712 | # Test "list filename:function" | |
713 | # | |
714 | ||
715 | proc test_list_filename_and_function {} { | |
716 | global prompt | |
717 | ||
718 | set testcnt 0 | |
719 | ||
720 | # gcc appears to generate incorrect debugging information for code | |
721 | # in include files, which breaks this test. | |
766de354 | 722 | # SunPRO cc is the second case below, it's also correct. |
633e6238 PS |
723 | setup_xfail "a29k-*-udi" |
724 | send "list list0.c:main\n" | |
725 | expect { | |
a04abecc | 726 | -re "1\[ \t\]+#include .*8\[ \t\]+breakpoint\[(\]\[)\]+;\r\n$prompt $" { |
633e6238 PS |
727 | incr testcnt |
728 | } | |
5c6f833b | 729 | -re "5\[ \t\]+int x;.*14\[ \t\]+foo \[(\]+.*\[)\]+;\r\n$prompt $" { |
766de354 PS |
730 | pass "list function in source file 1" |
731 | } | |
633e6238 PS |
732 | -re ".*$prompt $" { fail "list list0.c:main" } |
733 | timeout { fail "list list0.c:main (timeout)" } | |
734 | } | |
735 | ||
736 | # The i960 and a29k-amd-udi are the second case | |
737 | ||
738 | # Not sure what the point of having this function be unused is. | |
739 | # AIX is legitimately removing it. | |
740 | setup_xfail "rs6000-*-aix*" | |
741 | send "list list0.c:unused\n" | |
742 | expect { | |
a04abecc | 743 | -re "36\[ \t\]+\}.*42\[ \t\]+\}\r\n$prompt $" { |
633e6238 PS |
744 | incr testcnt |
745 | } | |
5c6f833b | 746 | -re "37.*42\[ \t\]+\}\r\n$prompt $" { |
633e6238 PS |
747 | incr testcnt |
748 | } | |
749 | -re ".*$prompt $" { fail "list list0.c:unused" } | |
750 | timeout { fail "list list0.c:unused (timeout)" } | |
751 | } | |
752 | clear_xfail "rs6000-*-aix*" | |
753 | ||
754 | # gcc appears to generate incorrect debugging information for code | |
755 | # in include files, which breaks this test. | |
756 | # Ultrix gdb is the second case, one line different but still correct. | |
766de354 | 757 | # SunPRO cc is the third case. |
633e6238 | 758 | setup_xfail "rs6000-*-*" 1804 |
5c6f833b | 759 | setup_xfail "powerpc-*-*" 1804 |
633e6238 PS |
760 | # FIXME Fails for COFF as well, I think. |
761 | setup_xfail "a29k-*-udi" | |
762 | send "list list0.h:foo\n" | |
763 | expect { | |
764 | -re "2\[ \t\]+including file. This.*11\[ \t\]+bar \[(\]+.*\[)\]+;\r\n$prompt $" { | |
765 | incr testcnt | |
766 | } | |
767 | -re "1\[ \t\]+/. An include file.*10\[ \t\]+bar \[(\]+.*\[)\]+;\r\n$prompt $" { | |
768 | incr testcnt | |
769 | } | |
766de354 PS |
770 | -re "3\[ \t\]+.*12\[ \t\]+bar \[(\]+.*\[)\]+;\r\n$prompt $" { |
771 | incr testcnt | |
772 | } | |
633e6238 PS |
773 | -re "No source file named list0.h.\r\n$prompt $" { |
774 | fail "list list0.h:foo" | |
775 | } | |
776 | -re ".*$prompt $" { fail "list list0.h:foo" } | |
777 | timeout { fail "list list0.h:foo (timeout)" } | |
778 | } | |
779 | ||
780 | # Ultrix gdb is the second case. | |
781 | # a29k-amd-udi is the third case. | |
782 | send "list list1.c:bar\n" | |
783 | expect { | |
784 | -re "1\[ \t\]+void.*8\[ \t\]+\}\r\n$prompt $" { | |
785 | incr testcnt | |
786 | } | |
787 | -re "1\[ \t\]+void.*7\[ \t\]*long_line ..;\r\n$prompt $" { | |
788 | incr testcnt | |
789 | } | |
790 | -re "1\[ \t\]+void.*9\[ \t\]*\r\n$prompt $" { | |
791 | incr testcnt | |
792 | } | |
793 | -re ".*$prompt $" { fail "list list1.c:bar" } | |
794 | timeout { fail "list list1.c:bar (timeout)" } | |
795 | } | |
796 | ||
797 | # The i960 and a29k-amd-udi are the second case | |
798 | ||
799 | # Not sure what the point of having this function be unused is. | |
800 | # AIX is legitimately removing it. | |
801 | setup_xfail "rs6000-*-aix*" | |
802 | send "list list1.c:unused\n" | |
803 | expect { | |
804 | -re "7\[ \t\]+long_line \[(\]\[)\];.*14\[ \t\]+\}\r\n.*$prompt $" { | |
805 | incr testcnt | |
806 | } | |
807 | -re "9.*14\[ \t\]+\}\r\n.*$prompt $" { | |
808 | incr testcnt | |
809 | } | |
810 | -re ".*$prompt $" { fail "list list1.c:unused" } | |
811 | timeout { fail "list list1.c:unused (timeout)" } | |
812 | } | |
813 | clear_xfail "rs6000-*-aix*" | |
814 | ||
815 | pass "list filename:function ($testcnt tests)" | |
816 | ||
817 | # Test some invalid specs | |
818 | # The following test takes the FIXME result on most systems using | |
819 | # DWARF. It fails to notice that main() is not in the file requested. | |
820 | ||
821 | setup_xfail "*-*-*" | |
822 | ||
823 | # Does this actually work ANYWHERE? I believe not, as this is an `aspect' of | |
824 | # lookup_symbol(), where, when it is given a specific symtab which does not | |
825 | # contain the requested symbol, it will subsequently search all of the symtabs | |
826 | # for the requested symbol. | |
827 | ||
828 | send "list list0.c:foo\n" | |
829 | expect { | |
830 | -re "Function \"foo\" not defined in .*list0.c\r\n$prompt $" { | |
831 | pass "list filename:function; wrong filename rejected" | |
832 | } | |
833 | -re "2\[ \t\]+including file.*11\[ \t\]+bar \[(\]+.*\[)\]+;\r\n$prompt $" { | |
834 | fail "list filename:function; wrong filename not rejected" | |
835 | } | |
836 | -re ".*main \[)(\]+.*$prompt $" { | |
837 | fail "list filename:function; wrong filename not rejected" | |
838 | } | |
839 | -re ".*$prompt $" { | |
840 | fail "list filename:function; wrong filename not rejected" | |
841 | } | |
842 | timeout { | |
843 | fail "list filename:function; wrong filename (timeout)" | |
844 | } | |
845 | } | |
846 | ||
847 | send "list foobar.c:main\n" | |
848 | expect { | |
849 | -re "No source file named foobar.c.\r\n$prompt $" { | |
850 | pass "list filename:function; nonexistant file" | |
851 | } | |
852 | -re ".*$prompt $" { | |
853 | fail "list filename:function; nonexistant file" | |
854 | } | |
855 | timeout { | |
856 | fail "list filename:function; nonexistant file (timeout)" | |
857 | } | |
858 | } | |
859 | ||
633e6238 PS |
860 | send "list list0.h:foobar\n" |
861 | expect { | |
862 | -re "Function \"foobar\" not defined.\r\n$prompt $" { | |
863 | pass "list filename:function; nonexistant function" | |
864 | } | |
865 | -re "No source file named list0.h.\r\n$prompt $" { | |
866 | fail "list filename:function; nonexistant function" | |
867 | } | |
868 | -re ".*$prompt $" { | |
869 | fail "list filename:function; nonexistant function" | |
870 | } | |
871 | timeout { | |
872 | fail "list filename:function; nonexistant function (timeout)" | |
873 | } | |
874 | } | |
875 | ||
876 | } | |
877 | ||
878 | proc test_forward_search {} { | |
766de354 PS |
879 | |
880 | gdb_test "set listsize 4" "" | |
881 | # On SunOS4, this gives us lines 19-22. On AIX, it gives us | |
882 | # lines 20-23. This depends on whether the line number of a function | |
883 | # is considered to be the openbrace or the first statement--either one | |
884 | # is acceptable. | |
885 | gdb_test "list long_line" "20\[ \t\]+long_line .*" | |
633e6238 PS |
886 | |
887 | gdb_test "search 4321" " not found" | |
888 | ||
766de354 | 889 | gdb_test "search 6789" "24\[ \t\]+oof .6789.;" |
633e6238 PS |
890 | |
891 | # We could look at the result of this, but dejagnu seems to | |
892 | # fail, perhaps because expect's buffers are too small. | |
893 | # In any case, we just want GDB to not crash if the line | |
894 | # being searched is extremely long. | |
895 | ||
766de354 | 896 | set timeout 30 |
633e6238 PS |
897 | gdb_test "search 1234" "" |
898 | } | |
899 | ||
900 | # Start with a fresh gdb. | |
901 | ||
902 | gdb_exit | |
903 | gdb_start | |
904 | gdb_reinitialize_dir $srcdir/$subdir | |
1b5b9581 FF |
905 | gdb_load ${binfile} |
906 | ||
907 | source ${binfile}.ci | |
633e6238 | 908 | |
6413ee42 KH |
909 | if $usestubs { |
910 | send "step\n" | |
911 | # if use stubs step out of the breakpoint() function. | |
912 | expect { | |
913 | -re "main.* at .*$prompt $" {} | |
914 | timeout { fail "single step at breakpoint() (timeout)" ; return 0 } | |
915 | } | |
a04abecc | 916 | } |
6413ee42 | 917 | |
633e6238 PS |
918 | send "set width 0\n" |
919 | expect -re "$prompt $" | |
920 | ||
921 | test_listsize | |
922 | if [ set_listsize 10 ] then { | |
923 | test_list_include_file | |
924 | test_list_filename_and_number | |
925 | test_list_function | |
926 | test_list_forward | |
927 | test_list_backwards | |
928 | test_list_range | |
929 | test_list_filename_and_function | |
930 | test_forward_search | |
931 | } |