1 # Copyright (C) 1998 Free Software Foundation, Inc.
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.
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.
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.
17 # Please email any bugs, comments, and/or additions to this file to:
22 # This file is part of the gdb testsuite.
25 # tests for command completion
27 # Here are some useful test cases for completion.
28 # They should be tested with both M-? and TAB.
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
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)
55 if { ![istarget "hppa*-hp-hpux*"] } {
56 #skip all these tests for now (FIXME)
63 # test running programs
69 set srcfile ${testfile}.c
70 set binfile ${objdir}/${subdir}/${testfile}
71 if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug additional_flags=-w}] != "" } {
72 gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail."
75 if [get_compiler_info ${binfile}] {
81 gdb_reinitialize_dir $srcdir/$subdir
84 if ![runto_main] then {
85 perror "tests suppressed"
88 set oldtimeout1 $timeout
98 -re "Undefined command: \"hfgfh\"\\. Try \"help\"\\..*$gdb_prompt $"\
99 { pass "complete 'hfgfh'"}
100 -re ".*$gdb_prompt $" { fail "complete 'hfgfh'"}
101 timeout {fail "(timeout) complete 'hfgfh'"}
104 -re ".*$gdb_prompt $" { fail "complete 'hfgfh'" }
105 timeout { fail "(timeout) complete 'hfgfh'" }
110 send_gdb "show output\t"
113 -re "^show output-radix $"\
116 -re "Default output radix for printing of values is 10\\..*$gdb_prompt $"\
117 { pass "complete 'show output'"}
118 -re ".*$gdb_prompt $" { fail "complete 'show output'"}
119 timeout {fail "(timeout) complete 'show output'"}
125 -re "Default output radix for printing of values is 10\\..*$gdb_prompt $"\
126 { fail "complete 'show output'"}
127 -re ".*$gdb_prompt $" { fail "complete 'show output'"}
128 timeout { fail "(timeout) complete 'show output'"}
133 -re ".*$gdb_prompt $" { fail "complete 'show output'" }
134 timeout { fail "(timeout) complete 'show output'" }
138 send_gdb "show output-\t"
141 -re "^show output-radix $"\
144 -re "Default output radix for printing of values is 10\\..*$gdb_prompt $"\
145 { pass "complete 'show output-'"}
146 -re ".*$gdb_prompt $" { fail "complete 'show output-'"}
147 timeout {fail "(timeout) complete 'show output-'"}
150 -re "^show output-$"\
153 -re "Default output radix for printing of values is 10\\..*$gdb_prompt $"\
154 { fail "complete 'show output-'"}
155 -re ".*$gdb_prompt $" { fail "complete 'show output-'"}
156 timeout { fail "(timeout) complete 'show output-'"}
161 -re ".*$gdb_prompt $" { fail "complete 'show output-'" }
162 timeout { fail "(timeout) complete 'show output-'" }
172 -re "The history is empty\\..*$gdb_prompt $"\
173 { pass "complete 'p'"}
174 -re ".*$gdb_prompt $" { fail "complete 'p'"}
175 timeout {fail "(timeout) complete 'p' 2"}
178 -re ".*$gdb_prompt $" { fail "complete 'p'" }
179 timeout { fail "(timeout) complete 'p' 1" }
189 -re "The history is empty\\..*$gdb_prompt $"\
190 { pass "complete 'p '"}
191 -re ".*$gdb_prompt $" { fail "complete 'p '"}
192 timeout {fail "(timeout) complete 'p ' 1"}
195 -re ".*$gdb_prompt $" { fail "complete 'p '" }
196 timeout { fail "(timeout) complete 'p ' 2" }
200 send_gdb "info t foo\t"
203 -re "^info t foo\\\x07$"\
206 -re "Ambiguous info command \"t foo\": target, terminal, threads, tp, tracepoints, types\\..*$gdb_prompt $"\
207 { pass "complete 'info t foo'"}
208 -re ".*$gdb_prompt $" { fail "complete 'info t foo'"}
209 timeout {fail "(timeout) complete 'info t foo'"}
212 -re ".*$gdb_prompt $" { fail "complete 'info t foo'" }
213 timeout { fail "(timeout) complete 'info t foo'" }
219 -re "^info t\\\x07$"\
222 -re "Ambiguous info command \"t\": target, terminal, threads, tp, tracepoints, types\\..
224 { pass "complete 'info t'"}
225 -re ".*$gdb_prompt $" { fail "complete 'info t'"}
226 timeout {fail "(timeout) complete 'info t'"}
229 -re ".*$gdb_prompt $" { fail "complete 'info t'" }
230 timeout { fail "(timeout) complete 'info t'" }
237 -re "^info t \\\x07$"\
240 -re "Ambiguous info command \"t \": target, terminal, threads, tp, tracepoints, types\\..
242 { pass "complete 'info t '"}
243 -re ".*$gdb_prompt $" { fail "complete 'info t '"}
244 timeout {fail "(timeout) complete 'info t '"}
247 -re ".*$gdb_prompt $" { fail "complete 'info t '" }
248 timeout { fail "(timeout) complete 'info t '" }
252 send_gdb "info asdfgh\t"
255 -re "^info asdfgh\\\x07$"\
258 -re "Undefined info command: \"asdfgh\". Try \"help info\"\\..
260 { pass "complete 'info asdfgh'"}
261 -re ".*$gdb_prompt $" { fail "complete 'info asdfgh'"}
262 timeout {fail "(timeout) complete 'info asdfgh'"}
265 -re ".*$gdb_prompt $" { fail "complete 'info asdfgh'" }
266 timeout { fail "(timeout) complete 'info asdfgh'" }
270 send_gdb "info asdfgh \t"
273 -re "^info asdfgh \\\x07$"\
276 -re "Undefined info command: \"asdfgh \". Try \"help info\"\\..
278 { pass "complete 'info asdfgh '"}
279 -re ".*$gdb_prompt $" { fail "complete 'info asdfgh '"}
280 timeout {fail "(timeout) complete 'info asdfgh '"}
283 -re ".*$gdb_prompt $" { fail "complete 'info asdfgh '" }
284 timeout { fail "(timeout) complete 'info asdfgh '" }
293 -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 $"\
294 { pass "complete 'info'"}
295 -re ".*$gdb_prompt $" { fail "complete 'info'"}
296 timeout {fail "(timeout) complete 'info'"}
299 -re ".*$gdb_prompt $" { fail "complete 'info'" }
300 timeout { fail "(timeout) complete 'info'" }
309 -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 $"\
310 { pass "complete 'info '"}
311 -re ".*$gdb_prompt $" { fail "complete 'info '"}
312 timeout {fail "(timeout) complete 'info '"}
315 -re ".*$gdb_prompt $" { fail "complete 'info '" }
316 timeout { fail "(timeout) complete 'info '" }
326 -re "address.*types.*$gdb_prompt info $"\
329 -re "\"info\".*unambiguous\\..*$gdb_prompt $"\
330 { pass "complete (2) 'info '"}
331 -re ".*$gdb_prompt $" { fail "complete (2) 'info '"}
332 timeout {fail "(timeout) complete (2) 'info '"}
335 -re ".*$gdb_prompt $" { fail "complete (2) 'info '"}
336 timeout {fail "(timeout) complete (2) 'info '"}
339 -re ".*$gdb_prompt $" { fail "complete (2) 'info '" }
340 timeout { fail "(timeout) complete (2) 'info '" }
350 -re "Unterminated string in expression\\..*$gdb_prompt $"\
351 { pass "complete 'p a'"}
352 -re ".*$gdb_prompt $" { fail "complete 'p a'"}
353 timeout {fail "(timeout) complete 'p a'"}
356 -re ".*$gdb_prompt $" { fail "complete 'p \"a'" }
357 timeout { fail "(timeout) complete 'p \"a'" }
366 -re "Invalid character constant\\..*$gdb_prompt $"\
367 { pass "complete 'p \'a'"}
368 -re ".*$gdb_prompt $" { fail "complete 'p \'a'"}
369 timeout {fail "(timeout) complete 'p \'a'"}
372 -re ".*$gdb_prompt $" { fail "complete 'p \'a'" }
373 timeout { fail "(timeout) complete 'p \'a'" }
382 -re "a64l.*atol.*$gdb_prompt p .a$" {
385 -re "Invalid character constant\\..*$gdb_prompt $" {
386 pass "complete (2) 'p \'a'"
388 -re ".*$gdb_prompt $" { fail "complete (2) 'p \'a'" }
389 timeout { fail "(timeout) complete (2) 'p \'a'" }
392 -re "(There are $decimal possibilities\\. Do you really\r\nwish to see them all.|Display all $decimal possibilities.) \\(y or n\\)$" {
395 -re "\\(gdb\\) p 'a$" {
398 -re "Invalid character constant\\..*$gdb_prompt $" {
399 pass "complete (2) 'p \'a'"
401 -re ".*$gdb_prompt $" {
402 fail "complete (2) 'p \'a'"
404 timeout { fail "(timeout) complete (2) 'p \'a'" }
407 -re ".*$gdb_prompt $" { fail "complete (2) 'p \'a'" }
408 timeout { fail "(timeout) complete (2) 'p \'a'" }
411 -re ".*$gdb_prompt $" { fail "complete (2) 'p \'a'" }
412 timeout { fail "(timeout) complete (2) 'p \'a'" }
415 -re ".*$gdb_prompt $" { fail "complete (2) 'p \'a'" }
416 timeout { fail "(timeout) complete (2) 'p \'a'" }
426 -re "No symbol \"b\" in current context\\..*$gdb_prompt $"\
427 { pass "complete 'p b-a'"}
428 -re ".*$gdb_prompt $" { fail "complete 'p b-a'"}
429 timeout {fail "(timeout) complete 'p b-a'"}
432 -re ".*$gdb_prompt $" { fail "complete 'p b-a'" }
433 timeout { fail "(timeout) complete 'p b-a'" }
439 -re "^p b-a\\\x07$" {
442 -re "a64l.*atol.*$gdb_prompt p b-a$" {
445 -re "No symbol \"b\" in current context\\..*$gdb_prompt $" {
446 pass "complete (2) 'p b-a'"
448 -re ".*$gdb_prompt $" { fail "complete (2) 'p b-a'" }
449 timeout { fail "(timeout) complete (2) 'p b-a'" }
452 -re "(There are $decimal possibilities\\. Do you really\r\nwish to see them all.|Display all $decimal possibilities.) \\(y or n\\)$" {
455 -re "\\(gdb\\) p b-a$" {
458 -re "No symbol \"b\" in current context\\..*$gdb_prompt $" {
459 pass "complete (2) 'p b-a'"
461 -re ".*$gdb_prompt $" {
462 fail "complete (2) 'p b-a'"
464 timeout { fail "(timeout) complete (2) 'p b-a'" }
467 -re ".*$gdb_prompt $" { fail "complete (2) 'p b-a'" }
468 timeout { fail "(timeout) complete (2) 'p b-a'" }
471 -re ".*$gdb_prompt $" { fail "complete (2) 'p b-a'" }
472 timeout { fail "(timeout) complete (2) 'p b-a'" }
475 -re ".*$gdb_prompt $" { fail "complete (2) 'p b-a'" }
476 timeout { fail "(timeout) complete (2) 'p b-a'" }
485 -re "(There are $decimal possibilities\\. Do you really\r\nwish to see them all.|Display all $decimal possibilities.) \\(y or n\\)$" {
488 -re "\\(gdb\\) p b-$" {
491 -re "No symbol \"b\" in current context\\..*$gdb_prompt $" {
492 pass "complete (2) 'p b-'"
494 -re ".*$gdb_prompt $" {
495 fail "complete (2) 'p b-'"
497 timeout { fail "(timeout) complete (2) 'p b-'" }
500 -re ".*$gdb_prompt $" { fail "complete (2) 'p b-'" }
501 timeout { fail "(timeout) complete (2) 'p b-'" }
504 -re ".*$gdb_prompt $" { fail "complete (2) 'p b-'" }
505 timeout { fail "(timeout) complete (2) 'p b-'" }
508 -re ".*$gdb_prompt $" { fail "complete (2) 'p b-'" }
509 timeout { fail "(timeout) complete (2) 'p b-'" }
512 send_gdb "file ${objdir}/Make\t"
515 -re "file ${objdir}/Makefile.*$"\
518 -re "\r\nA program is being debugged already\\. Kill it\\? \\(y or n\\) $"\
521 -re "\r\nProgram not killed\\.\r\n$gdb_prompt $"\
522 { pass "complete 'file Make'"}
523 -re ".*$gdb_prompt $" { fail "complete 'file Make'"}
524 timeout {fail "(timeout) complete 'file Make'"}
527 -re ".*$gdb_prompt $" { fail "complete 'file Make'"}
528 timeout {fail "(timeout) complete 'file Make'"}
531 -re ".*$gdb_prompt $" { fail "complete 'file Make'" }
532 timeout { fail "(timeout) complete 'file Make'" }
536 send_gdb "file ${srcdir}/gdb.base/a1\t"
539 -re "^file ${srcdir}/gdb.base/.*'a1.*-self\\.exp' $"\
542 -re "\r\nA program is being debugged already\\. Kill it\\? \\(y or n\\) $"
546 -re "\r\nProgram not killed\\.\r\n$gdb_prompt $"\
547 { pass "complete 'file gdb.base/a1'"}
548 -re ".*$gdb_prompt $" { fail "complete 'file gdb.base/a1'"}
549 timeout {fail "(timeout) complete 'file gdb.base/a1'"}
552 -re ".*$gdb_prompt $" { fail "complete 'file gdb.base/a1'"}
553 timeout {fail "(timeout) complete 'file gdb.base/a1'"}
556 -re ".*$gdb_prompt $" { fail "complete 'file gdb.base/a1'" }
557 timeout { fail "(timeout) complete 'file gdb.base/a1'" }
561 send_gdb "info func mark\t"
564 -re "^info func mark.*er$"\
569 -re "marker1.*$gdb_prompt info func marker$"\
572 -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\\);\r\n$gdb_prompt $"\
573 { pass "complete 'info func mar'"}
574 -re ".*$gdb_prompt $" { fail "complete 'info func mar'"}
575 timeout {fail "(timeout) complete 'info func mar'"}
578 -re ".*$gdb_prompt $" { fail "complete 'info func mar'"}
579 timeout {fail "(timeout) complete 'info func mar'"}
582 -re ".*$gdb_prompt $" { fail "complete 'info func mar'" }
583 timeout { fail "(timeout) complete 'info func mar'" }
587 send_gdb "set follow-fork-mode \t\t"
590 -re "ask.*child.*parent.*$gdb_prompt set follow-fork-mode $"\
593 -re "Requires an argument.*parent.*child.*ask.*$gdb_prompt $"\
594 { pass "complete 'set follow-fork-mode'"}
595 -re "Ambiguous item \"\"\\..*$gdb_prompt $"\
596 { pass "complete 'set follow-fork-mode'"}
597 -re ".*$gdb_prompt $" { fail "complete 'set follow-fork-mode'"}
598 timeout {fail "(timeout) complete 'set follow-fork-mode'"}
601 -re ".*$gdb_prompt $" { fail "complete 'set follow-fork-mode'" }
602 timeout { fail "(timeout) complete 'set follow-fork-mode'" }
605 set timeout $oldtimeout1