2001-05-10 Elena Zannoni <ezannoni@redhat.com>
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.base / completion.exp
1 # Copyright 1998, 1999 Free Software Foundation, Inc.
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
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 Elena Zannoni (ezannoni@cygnus.com)
21
22 # This file is part of the gdb testsuite.
23
24 #
25 # tests for command completion
26 #
27 # Here are some useful test cases for completion.
28 # They should be tested with both M-? and TAB.
29 #
30 # "show output-" "radix"
31 # "show output" "-radix"
32 # "p" ambiguous (commands starting with p--path, print, printf, etc.)
33 # "p " ambiguous (all symbols)
34 # "info t foo" no completions
35 # "info t " no completions
36 # "info t" ambiguous ("info target", "info terminal", etc.)
37 # "info ajksdlfk" no completions
38 # "info ajksdlfk " no completions
39 # "info" " "
40 # "info " ambiguous (all info commands)
41 # "p \"a" no completions (string constant)
42 # "p 'a" ambiguous (all symbols starting with a)
43 # "p b-a" ambiguous (all symbols starting with a)
44 # "p b-" ambiguous (all symbols)
45 # "file Make" "file" (word break hard to screw up here)
46 # "file ../gdb.stabs/we" "ird" (needs to not break word at slash)
47 #
48
49
50 if $tracelevel then {
51 strace $tracelevel
52 }
53
54
55 global usestubs
56
57 #
58 # test running programs
59 #
60 set prms_id 0
61 set bug_id 0
62
63 set testfile "break"
64 set srcfile ${testfile}.c
65 set binfile ${objdir}/${subdir}/${testfile}
66 if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug additional_flags=-w}] != "" } {
67 gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail."
68 }
69
70 if [get_compiler_info ${binfile}] {
71 return -1;
72 }
73
74 gdb_exit
75 gdb_start
76 gdb_reinitialize_dir $srcdir/$subdir
77 gdb_load ${binfile}
78
79 if ![runto_main] then {
80 perror "tests suppressed"
81 }
82
83 set oldtimeout1 $timeout
84 set timeout 30
85
86
87 send_gdb "hfgfh\t"
88 sleep 1
89 gdb_expect {
90 -re "^hfgfh\\\x07$"\
91 { send_gdb "\n"
92 gdb_expect {
93 -re "Undefined command: \"hfgfh\"\\. Try \"help\"\\..*$gdb_prompt $"\
94 { pass "complete 'hfgfh'"}
95 -re ".*$gdb_prompt $" { fail "complete 'hfgfh'"}
96 timeout {fail "(timeout) complete 'hfgfh'"}
97 }
98 }
99 -re ".*$gdb_prompt $" { fail "complete 'hfgfh'" }
100 timeout { fail "(timeout) complete 'hfgfh'" }
101 }
102
103 #exp_internal 0
104
105 send_gdb "show output\t"
106 sleep 1
107 gdb_expect {
108 -re "^show output-radix $"\
109 { send_gdb "\n"
110 gdb_expect {
111 -re "Default output radix for printing of values is 10\\..*$gdb_prompt $"\
112 { pass "complete 'show output'"}
113 -re ".*$gdb_prompt $" { fail "complete 'show output'"}
114 timeout {fail "(timeout) complete 'show output'"}
115 }
116 }
117 -re "^show output$"\
118 { send_gdb "\n"
119 gdb_expect {
120 -re "Default output radix for printing of values is 10\\..*$gdb_prompt $"\
121 { fail "complete 'show output'"}
122 -re ".*$gdb_prompt $" { fail "complete 'show output'"}
123 timeout { fail "(timeout) complete 'show output'"}
124 }
125
126 }
127
128 -re ".*$gdb_prompt $" { fail "complete 'show output'" }
129 timeout { fail "(timeout) complete 'show output'" }
130 }
131
132
133 send_gdb "show output-\t"
134 sleep 1
135 gdb_expect {
136 -re "^show output-radix $"\
137 { send_gdb "\n"
138 gdb_expect {
139 -re "Default output radix for printing of values is 10\\..*$gdb_prompt $"\
140 { pass "complete 'show output-'"}
141 -re ".*$gdb_prompt $" { fail "complete 'show output-'"}
142 timeout {fail "(timeout) complete 'show output-'"}
143 }
144 }
145 -re "^show output-$"\
146 { send_gdb "\n"
147 gdb_expect {
148 -re "Default output radix for printing of values is 10\\..*$gdb_prompt $"\
149 { fail "complete 'show output-'"}
150 -re ".*$gdb_prompt $" { fail "complete 'show output-'"}
151 timeout { fail "(timeout) complete 'show output-'"}
152 }
153
154 }
155
156 -re ".*$gdb_prompt $" { fail "complete 'show output-'" }
157 timeout { fail "(timeout) complete 'show output-'" }
158 }
159
160 send_gdb "p\t"
161 sleep 1
162 gdb_expect {
163 -re "^p\\\x07$"\
164 { send_gdb "\n"
165 sleep 1
166 gdb_expect {
167 -re "The history is empty\\..*$gdb_prompt $"\
168 { pass "complete 'p'"}
169 -re ".*$gdb_prompt $" { fail "complete 'p'"}
170 timeout {fail "(timeout) complete 'p' 2"}
171 }
172 }
173 -re ".*$gdb_prompt $" { fail "complete 'p'" }
174 timeout { fail "(timeout) complete 'p' 1" }
175 }
176
177 send_gdb "p \t"
178 sleep 3
179 gdb_expect {
180 -re "^p \\\x07$"\
181 { send_gdb "\n"
182 sleep 1
183 gdb_expect {
184 -re "The history is empty\\..*$gdb_prompt $"\
185 { pass "complete 'p '"}
186 -re ".*$gdb_prompt $" { fail "complete 'p '"}
187 timeout {fail "(timeout) complete 'p ' 1"}
188 }
189 }
190 -re ".*$gdb_prompt $" { fail "complete 'p '" }
191 timeout { fail "(timeout) complete 'p ' 2" }
192 }
193
194
195 send_gdb "info t foo\t"
196 sleep 1
197 gdb_expect {
198 -re "^info t foo\\\x07$"\
199 { send_gdb "\n"
200 gdb_expect {
201 -re "Ambiguous info command \"t foo\": target, terminal, threads, tp, tracepoints, types\\..*$gdb_prompt $"\
202 { pass "complete 'info t foo'"}
203 -re ".*$gdb_prompt $" { fail "complete 'info t foo'"}
204 timeout {fail "(timeout) complete 'info t foo'"}
205 }
206 }
207 -re ".*$gdb_prompt $" { fail "complete 'info t foo'" }
208 timeout { fail "(timeout) complete 'info t foo'" }
209 }
210
211 send_gdb "info t\t"
212 sleep 1
213 gdb_expect {
214 -re "^info t\\\x07$"\
215 { send_gdb "\n"
216 gdb_expect {
217 -re "Ambiguous info command \"t\": target, terminal, threads, tp, tracepoints, types\\..
218 *$gdb_prompt $"\
219 { pass "complete 'info t'"}
220 -re ".*$gdb_prompt $" { fail "complete 'info t'"}
221 timeout {fail "(timeout) complete 'info t'"}
222 }
223 }
224 -re ".*$gdb_prompt $" { fail "complete 'info t'" }
225 timeout { fail "(timeout) complete 'info t'" }
226 }
227
228
229 send_gdb "info t \t"
230 sleep 1
231 gdb_expect {
232 -re "^info t \\\x07$"\
233 { send_gdb "\n"
234 gdb_expect {
235 -re "Ambiguous info command \"t \": target, terminal, threads, tp, tracepoints, types\\..
236 *$gdb_prompt $"\
237 { pass "complete 'info t '"}
238 -re ".*$gdb_prompt $" { fail "complete 'info t '"}
239 timeout {fail "(timeout) complete 'info t '"}
240 }
241 }
242 -re ".*$gdb_prompt $" { fail "complete 'info t '" }
243 timeout { fail "(timeout) complete 'info t '" }
244 }
245
246
247 send_gdb "info asdfgh\t"
248 sleep 1
249 gdb_expect {
250 -re "^info asdfgh\\\x07$"\
251 { send_gdb "\n"
252 gdb_expect {
253 -re "Undefined info command: \"asdfgh\". Try \"help info\"\\..
254 *$gdb_prompt $"\
255 { pass "complete 'info asdfgh'"}
256 -re ".*$gdb_prompt $" { fail "complete 'info asdfgh'"}
257 timeout {fail "(timeout) complete 'info asdfgh'"}
258 }
259 }
260 -re ".*$gdb_prompt $" { fail "complete 'info asdfgh'" }
261 timeout { fail "(timeout) complete 'info asdfgh'" }
262 }
263
264
265 send_gdb "info asdfgh \t"
266 sleep 1
267 gdb_expect {
268 -re "^info asdfgh \\\x07$"\
269 { send_gdb "\n"
270 gdb_expect {
271 -re "Undefined info command: \"asdfgh \". Try \"help info\"\\..
272 *$gdb_prompt $"\
273 { pass "complete 'info asdfgh '"}
274 -re ".*$gdb_prompt $" { fail "complete 'info asdfgh '"}
275 timeout {fail "(timeout) complete 'info asdfgh '"}
276 }
277 }
278 -re ".*$gdb_prompt $" { fail "complete 'info asdfgh '" }
279 timeout { fail "(timeout) complete 'info asdfgh '" }
280 }
281
282 send_gdb "info\t"
283 sleep 1
284 gdb_expect {
285 -re "^info $"\
286 { send_gdb "\n"
287 gdb_expect {
288 -re "\"info\" must be followed by the name of an info command\\.\r\nList of info subcommands:\r\n\r\n.*info address.*info watchpoints.*\r\n\r\nType \"help info\" followed by info subcommand name for full documentation.\r\nCommand name abbreviations are allowed if unambiguous\\..*$gdb_prompt $"\
289 { pass "complete 'info'"}
290 -re ".*$gdb_prompt $" { fail "complete 'info'"}
291 timeout {fail "(timeout) complete 'info'"}
292 }
293 }
294 -re ".*$gdb_prompt $" { fail "complete 'info'" }
295 timeout { fail "(timeout) complete 'info'" }
296 }
297
298 send_gdb "info \t"
299 sleep 1
300 gdb_expect {
301 -re "^info \\\x07$"\
302 { send_gdb "\n"
303 gdb_expect {
304 -re "\"info\" must be followed by the name of an info command\\.\r\nList of info subcommands:\r\n\r\n.*info address.*Type \"help info\" followed by info subcommand name for full documentation.\r\nCommand name abbreviations are allowed if unambiguous\\..*$gdb_prompt $"\
305 { pass "complete 'info '"}
306 -re ".*$gdb_prompt $" { fail "complete 'info '"}
307 timeout {fail "(timeout) complete 'info '"}
308 }
309 }
310 -re ".*$gdb_prompt $" { fail "complete 'info '" }
311 timeout { fail "(timeout) complete 'info '" }
312 }
313
314
315 send_gdb "info \t"
316 sleep 1
317 gdb_expect {
318 -re "^info \\\x07$"\
319 { send_gdb "\t"
320 gdb_expect {
321 -re "address.*types.*$gdb_prompt info $"\
322 { send_gdb "\n"
323 gdb_expect {
324 -re "\"info\".*unambiguous\\..*$gdb_prompt $"\
325 { pass "complete (2) 'info '"}
326 -re ".*$gdb_prompt $" { fail "complete (2) 'info '"}
327 timeout {fail "(timeout) complete (2) 'info '"}
328 }
329 }
330 -re ".*$gdb_prompt $" { fail "complete (2) 'info '"}
331 timeout {fail "(timeout) complete (2) 'info '"}
332 }
333 }
334 -re ".*$gdb_prompt $" { fail "complete (2) 'info '" }
335 timeout { fail "(timeout) complete (2) 'info '" }
336 }
337
338
339 send_gdb "p \"a\t"
340 sleep 1
341 gdb_expect {
342 -re "^p \"a\\\x07$"\
343 { send_gdb "\n"
344 gdb_expect {
345 -re "Unterminated string in expression\\..*$gdb_prompt $"\
346 { pass "complete 'p a'"}
347 -re ".*$gdb_prompt $" { fail "complete 'p a'"}
348 timeout {fail "(timeout) complete 'p a'"}
349 }
350 }
351 -re ".*$gdb_prompt $" { fail "complete 'p \"a'" }
352 timeout { fail "(timeout) complete 'p \"a'" }
353 }
354
355 send_gdb "p 'a\t"
356 sleep 1
357 gdb_expect {
358 -re "^p 'a\\\x07$"\
359 { send_gdb "\n"
360 gdb_expect {
361 -re "Invalid character constant\\..*$gdb_prompt $"\
362 { pass "complete 'p \'a'"}
363 -re ".*$gdb_prompt $" { fail "complete 'p \'a'"}
364 timeout {fail "(timeout) complete 'p \'a'"}
365 }
366 }
367 -re ".*$gdb_prompt $" { fail "complete 'p \'a'" }
368 timeout { fail "(timeout) complete 'p \'a'" }
369 }
370
371 send_gdb "p 'a\t"
372 sleep 1
373 gdb_expect {
374 -re "^p 'a\\\x07$" {
375 send_gdb "\t"
376 gdb_expect {
377 -re "a64l.*argv.*$gdb_prompt p .a$" {
378 send_gdb "\n"
379 gdb_expect {
380 -re "Invalid character constant\\..*$gdb_prompt $" {
381 pass "complete (2) 'p \'a'"
382 }
383 -re ".*$gdb_prompt $" { fail "complete (2) 'p \'a'" }
384 timeout { fail "(timeout) complete (2) 'p \'a'" }
385 }
386 }
387 -re "(There are $decimal possibilities\\. Do you really\r\nwish to see them all.|Display all $decimal possibilities.) \\(y or n\\)$" {
388 send_gdb "n"
389 gdb_expect {
390 -re "\\(gdb\\) p 'a$" {
391 send_gdb "\n"
392 gdb_expect {
393 -re "Invalid character constant\\..*$gdb_prompt $" {
394 pass "complete (2) 'p \'a'"
395 }
396 -re ".*$gdb_prompt $" {
397 fail "complete (2) 'p \'a'"
398 }
399 timeout { fail "(timeout) complete (2) 'p \'a'" }
400 }
401 }
402 -re ".*$gdb_prompt $" { fail "complete (2) 'p \'a'" }
403 timeout { fail "(timeout) complete (2) 'p \'a'" }
404 }
405 }
406 -re ".*$gdb_prompt $" { fail "complete (2) 'p \'a'" }
407 timeout { fail "(timeout) complete (2) 'p \'a'" }
408 }
409 }
410 -re ".*$gdb_prompt $" { fail "complete (2) 'p \'a'" }
411 timeout { fail "(timeout) complete (2) 'p \'a'" }
412 }
413
414
415 send_gdb "p b-a\t"
416 sleep 1
417 gdb_expect {
418 -re "^p b-a\\\x07$"\
419 { send_gdb "\n"
420 gdb_expect {
421 -re "No symbol \"b\" in current context\\..*$gdb_prompt $"\
422 { pass "complete 'p b-a'"}
423 -re ".*$gdb_prompt $" { fail "complete 'p b-a'"}
424 timeout {fail "(timeout) complete 'p b-a'"}
425 }
426 }
427 -re ".*$gdb_prompt $" { fail "complete 'p b-a'" }
428 timeout { fail "(timeout) complete 'p b-a'" }
429 }
430
431 send_gdb "p b-a\t"
432 sleep 1
433 gdb_expect {
434 -re "^p b-a\\\x07$" {
435 send_gdb "\t"
436 gdb_expect {
437 -re "a64l.*argv.*$gdb_prompt p b-a$" {
438 send_gdb "\n"
439 gdb_expect {
440 -re "No symbol \"b\" in current context\\..*$gdb_prompt $" {
441 pass "complete (2) 'p b-a'"
442 }
443 -re ".*$gdb_prompt $" { fail "complete (2) 'p b-a'" }
444 timeout { fail "(timeout) complete (2) 'p b-a'" }
445 }
446 }
447 -re "(There are $decimal possibilities\\. Do you really\r\nwish to see them all.|Display all $decimal possibilities.) \\(y or n\\)$" {
448 send_gdb "n"
449 gdb_expect {
450 -re "\\(gdb\\) p b-a$" {
451 send_gdb "\n"
452 gdb_expect {
453 -re "No symbol \"b\" in current context\\..*$gdb_prompt $" {
454 pass "complete (2) 'p b-a'"
455 }
456 -re ".*$gdb_prompt $" {
457 fail "complete (2) 'p b-a'"
458 }
459 timeout { fail "(timeout) complete (2) 'p b-a'" }
460 }
461 }
462 -re ".*$gdb_prompt $" { fail "complete (2) 'p b-a'" }
463 timeout { fail "(timeout) complete (2) 'p b-a'" }
464 }
465 }
466 -re ".*$gdb_prompt $" { fail "complete (2) 'p b-a'" }
467 timeout { fail "(timeout) complete (2) 'p b-a'" }
468 }
469 }
470 -re ".*$gdb_prompt $" { fail "complete (2) 'p b-a'" }
471 timeout { fail "(timeout) complete (2) 'p b-a'" }
472 }
473
474 send_gdb "p b-\t"
475 sleep 1
476 gdb_expect {
477 -re "^p b-\\\x07$" {
478 send_gdb "\t"
479 gdb_expect {
480 -re "(There are $decimal possibilities\\. Do you really\r\nwish to see them all.|Display all $decimal possibilities.) \\(y or n\\)$" {
481 send_gdb "n"
482 gdb_expect {
483 -re "\\(gdb\\) p b-$" {
484 send_gdb "\n"
485 gdb_expect {
486 -re "No symbol \"b\" in current context\\..*$gdb_prompt $" {
487 pass "complete (2) 'p b-'"
488 }
489 -re ".*$gdb_prompt $" {
490 fail "complete (2) 'p b-'"
491 }
492 timeout { fail "(timeout) complete (2) 'p b-'" }
493 }
494 }
495 -re ".*$gdb_prompt $" { fail "complete (2) 'p b-'" }
496 timeout { fail "(timeout) complete (2) 'p b-'" }
497 }
498 }
499 -re ".*$gdb_prompt $" { fail "complete (2) 'p b-'" }
500 timeout { fail "(timeout) complete (2) 'p b-'" }
501 }
502 }
503 -re ".*$gdb_prompt $" { fail "complete (2) 'p b-'" }
504 timeout { fail "(timeout) complete (2) 'p b-'" }
505 }
506
507 send_gdb "file ${objdir}/Make\t"
508 sleep 1
509 gdb_expect {
510 -re "file ${objdir}/Makefile.*$"\
511 { send_gdb "\n"
512 gdb_expect {
513 -re "\r\nA program is being debugged already\\. Kill it\\? \\(y or n\\) $"\
514 { send_gdb "n\n"
515 gdb_expect {
516 -re "\r\nProgram not killed\\.\r\n$gdb_prompt $"\
517 { pass "complete 'file Make'"}
518 -re ".*$gdb_prompt $" { fail "complete 'file Make'"}
519 timeout {fail "(timeout) complete 'file Make'"}
520 }
521 }
522 -re ".*$gdb_prompt $" { fail "complete 'file Make'"}
523 timeout {fail "(timeout) complete 'file Make'"}
524 }
525 }
526 -re ".*$gdb_prompt $" { fail "complete 'file Make'" }
527 timeout { fail "(timeout) complete 'file Make'" }
528 }
529
530
531 send_gdb "file ${srcdir}/gdb.base/compl\t"
532 sleep 1
533 gdb_expect {
534 -re "^file ${srcdir}/gdb.base/completion\\.exp $"\
535 { send_gdb "\n"
536 gdb_expect {
537 -re "\r\nA program is being debugged already\\. Kill it\\? \\(y or n\\) $"
538 \
539 { send_gdb "n\n"
540 gdb_expect {
541 -re "\r\nProgram not killed\\.\r\n$gdb_prompt $"\
542 { pass "complete 'file gdb.base/compl'"}
543 -re ".*$gdb_prompt $" { fail "complete 'file gdb.base/compl'"}
544 timeout {fail "(timeout) complete 'file gdb.base/compl'"}
545 }
546 }
547 -re ".*$gdb_prompt $" { fail "complete 'file gdb.base/compl'"}
548 timeout {fail "(timeout) complete 'file gdb.base/compl'"}
549 }
550 }
551 -re ".*$gdb_prompt $" { fail "complete 'file gdb.base/compl'" }
552 timeout { fail "(timeout) complete 'file gdb.base/compl'" }
553 }
554
555 send_gdb "info func mark\t"
556 sleep 1
557 gdb_expect {
558 -re "^info func mark.*er$"\
559 {
560 send_gdb "\t\t"
561 sleep 3
562 gdb_expect {
563 -re "marker1.*$gdb_prompt info func marker$"\
564 { send_gdb "\n"
565 gdb_expect {
566 -re "All functions matching regular expression \"marker\":\r\n\r\nFile.*break.c:\r\nint marker1\\(\\);\r\nint marker2\\(int\\).*marker3\\(char.*char.*\\).*marker4\\(long int\\);\r\n$gdb_prompt $"\
567 { pass "complete 'info func mar'"}
568 -re ".*$gdb_prompt $" { fail "complete 'info func mar'"}
569 timeout {fail "(timeout) complete 'info func mar'"}
570 }
571 }
572 -re ".*$gdb_prompt $" { fail "complete 'info func mar'"}
573 timeout {fail "(timeout) complete 'info func mar'"}
574 }
575 }
576 -re ".*$gdb_prompt $" { fail "complete 'info func mar'" }
577 timeout { fail "(timeout) complete 'info func mar'" }
578 }
579
580
581 send_gdb "set follow-fork-mode \t\t"
582 sleep 1
583 gdb_expect {
584 -re "ask.*child.*parent.*$gdb_prompt set follow-fork-mode $"\
585 { send_gdb "\n"
586 gdb_expect {
587 -re "Requires an argument.*ask.*child.*parent.*$gdb_prompt $"\
588 { pass "complete 'set follow-fork-mode'"}
589 -re "Ambiguous item \"\"\\..*$gdb_prompt $"\
590 { pass "complete 'set follow-fork-mode'"}
591 -re ".*$gdb_prompt $" { fail "complete 'set follow-fork-mode'"}
592 timeout {fail "(timeout) complete 'set follow-fork-mode'"}
593 }
594 }
595 -re ".*$gdb_prompt $" { fail "complete 'set follow-fork-mode'" }
596 timeout { fail "(timeout) complete 'set follow-fork-mode'" }
597 }
598
599 set timeout $oldtimeout1
600 return 0
601
602
603
604
605
606
607
608
609
610
611
612
613
614
This page took 0.042089 seconds and 5 git commands to generate.