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