1 # Copyright 1998-2024 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 3 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, see <http://www.gnu.org/licenses/>.
16 # This file was written by Elena Zannoni (ezannoni@cygnus.com)
18 # This file is part of the gdb testsuite.
21 # tests for command completion
23 # Here are some useful test cases for completion.
24 # They should be tested with both M-? and TAB.
26 # "show output-" "radix"
27 # "show output" "-radix"
28 # "p" ambiguous (commands starting with p--path, print, printf, etc.)
29 # "p " ambiguous (all symbols)
30 # "info t foo" no completions
31 # "info t " no completions
32 # "info t" ambiguous ("info target", "info terminal", etc.)
33 # "info ajksdlfk" no completions
34 # "info ajksdlfk " no completions
36 # "info " ambiguous (all info commands)
37 # "p \"break1" unambiguous (completes to filename "break1.c")
38 # "p \"break1." unambiguous (should complete to "break1.c" but does not,
39 # due to readline limitations)
40 # "p 'arg" ambiguous (all symbols starting with arg)
41 # "p b-arg" ambiguous (all symbols starting with arg)
42 # "p b-" ambiguous (all symbols)
43 # "file Make" "file" (word break hard to screw up here)
44 # "file ../gdb.stabs/we" "ird" (needs to not break word at slash)
50 # test running programs
53 standard_testfile break.c break1.c
55 if {[prepare_for_testing "failed to prepare" $testfile \
56 [list $srcfile $srcfile2] {debug nowarnings}]} {
65 gdb_test_no_output "set max-completions unlimited"
67 gdb_test_no_output "complete print values\[0\].x." \
68 "field completion with invalid field"
70 # If there is a non-deprecated completion, it should be returned.
71 gdb_test "complete sav" "save" "test non-deprecated completion"
72 # If there is only a deprecated completion, then it should be returned.
73 gdb_test "complete save-t" "save-tracepoints" "test deprecated completion"
77 # Tag name completion.
80 gdb_test "complete ptype struct some_" "ptype struct some_struct"
81 gdb_test "complete ptype enum some_" "ptype enum some_enum"
82 gdb_test "complete ptype union some_" "ptype union some_union"
85 gdb_test "complete set gnutarget aut" "set gnutarget auto"
88 gdb_test "complete set cp-abi aut" "set cp-abi auto"
90 # Test that completion of commands 'target FOO' works well.
91 set targets [list "core" "tfile" "exec"]
93 # Test that completion of command 'target ctf' if GDB supports ctf
95 gdb_test_multiple "target ctf" "" {
96 -re "Undefined target command: \"ctf\"\. Try \"help target\"\.\r\n$gdb_prompt $" {
98 -re "No CTF directory specified.*\r\n$gdb_prompt $" {
103 # Test artifacts are put in different locations depending on test
104 # is a parallel run or not. Firstly check file exists, and then
105 # do the test on file completion.
107 foreach dir1 [ list "./gdb.base" "./outputs/gdb.base/completion" ] {
108 if { [remote_file host exists ${dir1}/completion]
109 && [remote_file host exists ${dir1}/completion0.o]
110 && [remote_file host exists ${dir1}/completion1.o] } {
111 foreach target_name ${targets} {
112 gdb_test "complete target ${target_name} ${dir1}/completion" \
113 "target ${target_name} ${dir1}/completion.*${dir1}/completion0\\.o.*${dir1}/completion1\\.o.*" \
114 "complete target ${target_name}"
121 # "set foo unlimited" completion.
124 # A var_uinteger command.
125 gdb_test "complete set height " "set height unlimited"
126 gdb_test "complete set height u" "set height unlimited"
128 # A var_integer command.
129 gdb_test "complete set listsize " "set listsize unlimited"
130 gdb_test "complete set listsize unl" "set listsize unlimited"
132 # A var_zuinteger_unlimited command.
133 gdb_test "complete set trace-buffer-size " "set trace-buffer-size unlimited"
134 gdb_test "complete set trace-buffer-size unl" "set trace-buffer-size unlimited"
136 # Test "info registers" completion: First determine this
137 # architecture's registers and reggroups...
139 set regs_output [capture_command_output "mt print registers" \
140 ".*Name.*Nr.*Rel.*Offset.*Size.*Type.\[^\n\]*\n"]
141 append regs_output "\n"
142 append regs_output [capture_command_output "mt print reggroups" \
143 ".*Group.*Type\[^\n]*\n"]
144 append regs_output "\n"
145 append regs_output [capture_command_output "mt print user-registers" \
146 ".*Name.*Nr\[^\n]*\n"]
148 foreach {- reg} [regexp -all -inline -line {^(\w+)} $regs_output] {
149 lappend all_regs $reg
152 set all_regs [join [lsort -unique $all_regs]]
154 # ... and then compare them to the completion of "info registers".
156 set regs_output [capture_command_output "complete info registers " ""]
157 set completed_regs {}
158 foreach {-> reg} [regexp -all -inline -line {^info registers (\w+\S*)} $regs_output] {
159 lappend completed_regs $reg
161 set completed_regs [join [lsort $completed_regs]]
162 gdb_assert {$all_regs eq $completed_regs} "complete 'info registers '"
164 # Tests below are about tab-completion, which doesn't work if readline
165 # library isn't used. Check it first.
167 if { ![readline_is_used] } {
171 # The bulk of this test script pre-dates the completion-support
172 # library, and should probably (where possible) be converted.
173 # However, for now, new tests are being added using this library.
174 load_lib completion-support.exp
176 set test "complete 'hfgfh'"
178 gdb_test_multiple "" "$test" {
179 -re "^hfgfh\\\x07$" {
181 gdb_test_multiple "" $test {
182 -re "Undefined command: \"hfgfh\"\\. Try \"help\"\\..*$gdb_prompt $" {
191 set test "complete 'show output'"
192 send_gdb "show output\t"
193 gdb_test_multiple "" "$test" {
194 -re "^show output-radix $" {
196 gdb_test_multiple "" "$test" {
197 -re "Default output radix for printing of values is 10\\..*$gdb_prompt $" {
204 set test "complete 'show output-'"
205 send_gdb "show output-\t"
206 gdb_test_multiple "" "$test" {
207 -re "^show output-radix $" {
209 gdb_test_multiple "" "$test" {
210 -re "Default output radix for printing of values is 10\\..*$gdb_prompt $" {
217 set test "complete 'p'"
219 gdb_test_multiple "" "$test" {
222 gdb_test_multiple "" "$test" {
223 -re "The history is empty\\..*$gdb_prompt $" {
230 set test "complete 'p '"
232 gdb_test_multiple "" "$test" {
235 gdb_test_multiple "" "$test" {
236 -re "The history is empty\\..*$gdb_prompt $" {
243 set test "complete 'info t foo'"
244 send_gdb "info t foo\t"
245 gdb_test_multiple "" "$test" {
246 -re "^info t foo\\\x07$" {
248 gdb_test_multiple "" "$test" {
249 -re "Ambiguous info command \"t foo\": target, tasks, terminal, threads, tp, tracepoints, tvariables, (type-printers, )?types\\..*$gdb_prompt $" {
256 set test "complete 'info t'"
258 gdb_test_multiple "" "$test" {
259 -re "^info t\\\x07$" {
261 gdb_test_multiple "" "$test" {
262 -re "Ambiguous info command \"t\": target, tasks, terminal, threads, tp, tracepoints, tvariables, (type-printers, )?types\\..*$gdb_prompt $" {
269 set test "complete 'info t '"
271 gdb_test_multiple "" "$test" {
272 -re "^info t \\\x07$" {
274 gdb_test_multiple "" "$test" {
275 -re "Ambiguous info command \"t \": target, tasks, terminal, threads, tp, tracepoints, tvariables, (type-printers, )?types\\..*$gdb_prompt $" {
282 set test "complete 'info asdfgh'"
283 send_gdb "info asdfgh\t"
284 gdb_test_multiple "" "$test" {
285 -re "^info asdfgh\\\x07$" {
287 gdb_test_multiple "" "$test" {
288 -re "Undefined info command: \"asdfgh\". Try \"help info\"\\..*$gdb_prompt $" {
295 set test "complete 'info asdfgh '"
296 send_gdb "info asdfgh \t"
297 gdb_test_multiple "" "$test" {
298 -re "^info asdfgh \\\x07$" {
300 gdb_test_multiple "" "$test" {
301 -re "Undefined info command: \"asdfgh \". Try \"help info\"\\..*$gdb_prompt $" {
308 set test "complete 'info'"
310 gdb_test_multiple "" "$test" {
313 gdb_test_multiple "" "$test" {
314 -re "List of info subcommands.*$gdb_prompt $" {
321 set test "complete 'info '"
323 gdb_test_multiple "" "$test" {
324 -re "^info \\\x07$" {
326 gdb_test_multiple "" "$test" {
327 -re "List of info subcommands:\r\n\r\n.*$gdb_prompt $" {
334 set test "complete (2) 'info '"
336 gdb_test_multiple "" "$test" {
337 -re "^info \\\x07$" {
339 gdb_test_multiple "" "$test" {
340 -re "address.*types.*$gdb_prompt " {
342 gdb_test_multiple "" "$test" {
343 -re "allowed if unambiguous\\..*$gdb_prompt $" {
352 set test "complete 'help info wat'"
353 send_gdb "help info wat\t"
354 gdb_test_multiple "" "$test" {
355 -re "^help info watchpoints $" {
357 gdb_test_multiple "" "$test" {
358 -re "Status of specified watchpoints.*\r\n.*$gdb_prompt $" {
363 -re "^help info wat\\\x07$" {
368 set test "complete 'p \"break1'"
369 send_gdb "p \"break1\t"
370 gdb_test_multiple "" "$test" {
371 -re "^p \"break1\\\x07$" {
373 gdb_test_multiple "" "$test" {}
375 -re "^p \"break1\\.c\"$" {
377 gdb_test_multiple "" "$test" {
378 -re "$gdb_prompt $" {
386 set test "complete 'p \"break1.'"
387 send_gdb "p \"break1.\t"
388 gdb_test_multiple "" "$test" {
389 -re "^p \"break1\\.\\\x07$" {
391 gdb_test_multiple "" "$test" {}
393 -re "^p \"break1\\.c\"$" {
395 gdb_test_multiple "" "$test" {
396 -re "$gdb_prompt $" {
401 -re "^p \"break1\\..*$" {
403 gdb_test_multiple "" "$test" {}
407 set test "complete 'p 'arg'"
409 gdb_test_multiple "" "$test" {
410 -re "^p 'arg\\\x07$" {
412 gdb_test_multiple "" "$test" {
413 -re "(Invalid character constant\\.|Unmatched single quote\\.).*$gdb_prompt $" {
420 set test "complete (2) 'p 'arg'"
422 gdb_test_multiple "" "$test" {
423 -re "^p 'arg\\\x07$" {
425 gdb_test_multiple "" "$test" {
426 -re "argv.*$gdb_prompt " {
428 gdb_test_multiple "" "$test" {
429 -re "(Invalid character constant\\.|Unmatched single quote\\.).*$gdb_prompt $" {
434 -re "(There are $decimal possibilities\\. Do you really\r\nwish to see them all.|Display all $decimal possibilities.) \\(y or n\\)$" {
436 gdb_test_multiple "" "$test" {
437 -re "\\(gdb\\) p 'arg$" {
439 gdb_test_multiple "" "$test" {
440 -re "(Invalid character constant\\.|Unmatched single quote\\.).*$gdb_prompt $" {
451 set test "complete 'handle signal'"
452 send_gdb "handle sigq\t"
453 gdb_test_multiple "" "$test" {
454 -re "^handle sigq
\b\b\b\bSIGQUIT $" {
456 gdb_test_multiple "" "$test" {
457 -re "SIGQUIT.*Quit.*$gdb_prompt $" {
464 set test "complete 'handle keyword'"
465 send_gdb "handle nos\t"
466 gdb_test_multiple "" "$test" {
467 -re "^handle nostop $" {
469 gdb_test_multiple "" "$test" {
470 -re "$gdb_prompt $" {
477 set test "complete help aliases"
478 send_gdb "help user-define\t"
479 gdb_test_multiple "" "$test" {
480 -re "^help user-defined $" {
482 gdb_test_multiple "" "$test" {
483 -re "$gdb_prompt $" {
491 # These tests used to try completing the shorter "p b-a".
492 # Unfortunately, on some systems, there are .o files in system
493 # libraries which declare static variables named `b'. Of course,
494 # those variables aren't really in scope, as far as the compiler is
495 # concerned. But GDB deliberately tries to be more liberal: if you
496 # enter an identifier that doesn't have any binding in scope, GDB will
497 # search all the program's compilation units for a static variable of
500 # This behavior can help avoid a lot of pedantry, so it's usually a
501 # good thing. But in this test case, it causes GDB to print the value
502 # of some random variable, instead of giving us the "No symbol..."
503 # error we were expecting.
505 # For example, on S/390 linux, the file s_atan.c in libm.a declares a
506 # `b', which is a structure containing an int and a float, so GDB says
507 # ``Argument to arithmetic operation not a number or boolean'' instead
508 # of ``No symbol ...''.
510 # So, I'm hoping that there is no system with a static library variable named
511 # `no_var_by_this_name'.
513 set test "complete 'p no_var_named_this-arg'"
514 send_gdb "p no_var_named_this-arg\t"
515 gdb_test_multiple "" "$test" {
516 -re "^p no_var_named_this-arg\\\x07$" {
518 gdb_test_multiple "" "$test" {
519 -re "No symbol \"no_var_named_this\" in current context\\..*$gdb_prompt $" {
526 set test "complete (2) 'p no_var_named_this-arg'"
527 send_gdb "p no_var_named_this-arg\t"
528 gdb_test_multiple "" "$test" {
529 -re "^p no_var_named_this-arg\\\x07$" {
531 gdb_test_multiple "" "$test" {
532 -re "argv.*$gdb_prompt " {
534 gdb_test_multiple "" "$test" {
535 -re "No symbol \"no_var_named_this\" in current context\\..*$gdb_prompt $" {
540 -re "(There are $decimal possibilities\\. Do you really\r\nwish to see them all.|Display all $decimal possibilities.) \\(y or n\\)$" {
546 pass "$test, eat prompt"
549 fail "$test, eat prompt (timeout)"
553 gdb_test_multiple "" "$test" {
554 -re "No symbol \"no_var_named_this\" in current context\\..*$gdb_prompt $" {
563 set test "complete (2) 'p no_var_named_this-'"
564 send_gdb "p no_var_named_this-\t"
565 gdb_test_multiple "" "$test" {
566 -re "^p no_var_named_this-\\\x07$" {
568 gdb_test_multiple "" "$test" {
569 -re "(There are $decimal possibilities\\. Do you really\r\nwish to see them all.|Display all $decimal possibilities.) \\(y or n\\)$" {
575 pass "$test, eat prompt"
578 fail "$test, eat prompt (timeout)"
582 gdb_test_multiple "" "$test" {
583 -re "No symbol \"no_var_named_this\" in current context\\..*$gdb_prompt $" {
588 -re "argv.*$gdb_prompt $" {
590 gdb_test_multiple "" "$test" {
591 -re "No symbol \"no_var_named_this\" in current context\\..*$gdb_prompt $" {
600 set test "complete 'p values\[0\].a'"
601 send_gdb "p values\[0\].a\t"
602 gdb_test_multiple "" "$test" {
603 -re "^p values.0..a_field $" {
605 gdb_test_multiple "" "$test" {
606 -re " = 0.*$gdb_prompt $" {
613 set test "complete 'p values\[0\] . a'"
614 send_gdb "p values\[0\] . a\t"
615 gdb_test_multiple "" "$test" {
616 -re "^p values.0. . a_field $" {
618 gdb_test_multiple "" "$test" {
619 -re " = 0.*$gdb_prompt $" {
626 set test "complete 'p &values\[0\] -> a'"
627 send_gdb "p &values\[0\] -> a\t"
628 gdb_test_multiple "" "$test" {
629 -re "^p &values.0. -> a_field $" {
631 gdb_test_multiple "" "$test" {
632 -re " = .*0x\[0-9a-fA-F\]*.*$gdb_prompt $" {
639 gdb_test "complete p &values\[0\]->z" \
640 "p &values.0.->z_field" \
641 "completion of field in anonymous union"
643 gdb_test "complete ptype &values\[0\]->z" \
644 "ptype &values.0.->z_field" \
645 "ptype completion of field in anonymous union"
647 gdb_test "complete whatis &values\[0\]->z" \
648 "whatis &values.0.->z_field" \
649 "whatis completion of field in anonymous union"
651 # The following tests used to simply try to complete `${objdir}/file',
652 # and so on. The problem is that ${objdir} can be very long; the
653 # completed filename may be more than eighty characters wide. When
654 # this happens, readline tries to manage things, producing output that
655 # may make sense on the screen, but is rather hard for our script to
658 # In the case that motivated this change, the (gdb) prompt occupied
659 # the leftmost six columns, and `${objdir}/' was seventy-four
660 # characters long --- eighty in all. After printing the slash,
661 # readline emitted a space, a carriage return, and then `Makefile'
662 # (the tab character being received as input after `Make'.
664 # Basically, you have to let readline do whatever it's going to do to
665 # make the screen look right. If it happens to use a different
666 # strategy on Tuesdays to get the cursor in the right place, that's
667 # not something the testsuite should care about.
669 # So, we avoid long lines. We `cd' to ${srcdir} first, and then do
670 # the completion relative to the current directory.
672 # ${srcdir} may be a relative path. We want to make sure we end up
673 # in the right directory - so make sure we know where it is.
678 # If the directory name contains a '+' we must escape it, adding a backslash.
679 # If not, the test below will fail because it will interpret the '+' as a
680 # regexp operator. We use string_to_regexp for this purpose.
682 gdb_test "cd ${fullsrcdir}" \
683 "Working directory [string_to_regexp ${fullsrcdir}].*" \
687 # GDB used to fail adding / on directories, on the first try only.
688 set uniquedir ../testsuite/gdb.base/comp-dir
689 set escapeduniquedir [string_to_regexp ${uniquedir}]
691 set uniquesub ${uniquesu}r
692 set escapeuniquesub [string_to_regexp ${uniquesub}]
693 send_gdb "dir ${uniquedir}\t"
695 -re "${escapeduniquedir}/" {
696 pass "directory completion"
697 send_gdb "${uniquesu}\t"
699 -re "${escapeduniquedir} $" {
700 fail "directory completion (old gdb bug)"
701 send_gdb "\b/${uniquesu}\t"
704 fail "directory completion (timeout)"
705 send_gdb "\ndir ${uniquedir}/${uniquesu}\t"
710 -re "${escapeuniquesub}/$" {
711 pass "directory completion 2"
714 fail "directory completion 2"
718 # Empty COMMAND sends no newline while " " sends the newline we need.
719 gdb_test " " "Source directories searched: .*" "glob remaining of directory test"
721 gdb_test "complete file ./gdb.base/compl" \
722 "file ./gdb.base/completion\\.exp.*" \
723 "complete-command 'file ./gdb.base/compl'"
725 set test "complete 'file ./gdb.base/completi'"
726 send_gdb "file ./gdb.base/completi\t"
727 gdb_test_multiple "" "$test" {
728 -re "^file ./gdb.base/completion\\.exp $" {
730 # Ignore the exact error message.
731 gdb_test_multiple "" "complete 'file ./gdb.base/completi'" {
732 -re "\r\nA program is being debugged already\\.\[\r\n\]+Are you sure you want to change the file\\? \\(y or n\\) $" {
736 -re "$gdb_prompt $" {
743 set test "complete 'info func marke'"
744 send_gdb "info func marke\t"
745 gdb_test_multiple "" "$test" {
746 -re "^info func marke.*r$" {
748 gdb_test_multiple "" "$test" {
749 -re "marker1.*$gdb_prompt " {
751 gdb_test_multiple "" "$test" {
752 -re "All functions matching regular expression \"marker\":.*File.*break1.c:.*\tint marker1\\((void|)\\);\r\n.*:\tint marker2\\(int\\).*marker3\\(char.*char.*\\).*marker4\\(long( int)?\\);.*$gdb_prompt $" {
762 set test "complete 'set follow-fork-mode'"
763 send_gdb "set follow-fork-mode \t\t"
764 gdb_test_multiple "" "$test" {
765 -re "child.*parent.*$gdb_prompt " {
767 gdb_test_multiple "" "$test" {
768 -re "Requires an argument.*child.*parent.*$gdb_prompt $" {
771 -re "Ambiguous item \"\"\\..*$gdb_prompt $" {
779 # Tests for the location completer
782 # Turn off pending breakpoint support so that we don't get queried
784 gdb_test_no_output "set breakpoint pending off"
786 set subsrc [string range $srcfile 0 [expr {[string length $srcfile] - 3}]]
787 set test "tab complete break $subsrc"
788 send_gdb "break $subsrc\t\t"
789 gdb_test_multiple "" $test {
790 -re "break\.c.*break1\.c.*$gdb_prompt " {
792 gdb_test_multiple "" $test {
793 -re "malformed linespec error: unexpected end of input\r\n$gdb_prompt " {
796 -re "$gdb_prompt p$" {
802 -re "$gdb_prompt p$" {
807 gdb_test "complete break $subsrc" "break\.c.*break1\.c"
809 set test "tab complete break need"
810 send_gdb "break need\t"
811 gdb_test_multiple "" $test {
812 -re "break need_malloc " {
814 gdb_test_multiple "" $test {
815 -re ".*Breakpoint.*at .*/$srcfile, line .*$gdb_prompt " {
817 gdb_test_no_output "delete breakpoint \$bpnum" \
818 "delete breakpoint for $test"
820 -re "$gdb_prompt p$" {
825 -re "$gdb_prompt p$" {
830 gdb_test "complete break need" "need_malloc"
833 # Enabling max-completions is necessary to trigger the bug.
834 gdb_test_no_output "set max-completions 10"
835 set test "tab complete break $srcfile:ma"
836 send_gdb "break $srcfile:ma\t"
837 gdb_test_multiple "" $test {
838 -re "break $srcfile:main " {
840 gdb_test_multiple "" $test {
841 -re ".*Breakpoint.*at .*/$srcfile, line .*$gdb_prompt " {
843 gdb_test_no_output "delete breakpoint \$bpnum" \
844 "delete breakpoint for $test"
846 -re "$gdb_prompt p$" {
851 -re "$gdb_prompt p$" {
856 gdb_test "complete break $srcfile:ma" "break\.c:main"
858 # End of gdb/17960 testing.
861 # Completion limiting.
864 gdb_test_no_output "set max-completions 5"
866 proc ignore_and_resync {cmd result test} {
869 gdb_test_multiple "" "$test" {
871 # Complete the command and ignore the output
872 # to resync gdb for the next test.
874 gdb_test_multiple "" "$test" {
875 -re "$gdb_prompt $" {
883 proc test_tab_complete {cmd test} {
887 gdb_test_multiple "" "$test" {
888 -re "^${cmd}\\\x07$" {
890 gdb_test_multiple "" "$test" {
891 -re "List may be truncated, max-completions reached.*\r\n$gdb_prompt " {
892 ignore_and_resync $cmd pass $test
895 ignore_and_resync $cmd fail $test
902 test_tab_complete "p" \
903 "command-name completion limiting using tab character"
905 set test "command-name completion limiting using complete command"
906 send_gdb "complete p\n"
907 gdb_test_multiple "" "$test" {
908 -re "List may be truncated, max-completions reached.*\r\n$gdb_prompt $" {
913 gdb_test_no_output "set max-completions 3"
915 test_tab_complete "p marker" \
916 "symbol-name completion limiting using tab character"
918 set test "symbol-name completion limiting using complete command"
919 send_gdb "complete p mark\n"
920 gdb_test_multiple "" "$test" {
921 -re "List may be truncated, max-completions reached.*\r\n$gdb_prompt $" {
926 # Test completion of 'p', 'x', and 'display' all using a /FMT.
927 foreach_with_prefix spc { " " "" } {
928 test_gdb_complete_multiple "p${spc}/d some_union_global." "" "f" {
933 test_gdb_complete_none "p${spc}/"
934 test_gdb_complete_unique "p${spc}/d" "p${spc}/d"
936 # Try completion on an invalid /FMT string. GDB doesn't attempt
937 # to validate the /FMT string during completion, the string is
938 # just assumed to be complete when the user hits TAB.
939 test_gdb_complete_unique "p${spc}/@" "p${spc}/@"
941 test_gdb_complete_unique "x${spc}/1w values\[0\].b"\
942 "x${spc}/1w values\[0\].b_field"
944 test_gdb_complete_unique "display${spc}/x values\[0\].z"\
945 "display${spc}/x values\[0\].z_field"
948 # Test 'p' using both options and /FMT.
949 test_gdb_complete_multiple "p -array on -- /d some_union_global." \
955 # Check the watch commands can all complete, with and without flags.
956 foreach_with_prefix cmd { "watch" "awatch" "rwatch" } {
957 foreach_with_prefix opt { "" "-l" "-location" } {
958 test_gdb_complete_multiple "${cmd} ${opt} some_union_global." \
966 # Check that tab completion of a deprecated alias does not display the
967 # warning about the alias being deprecated during tab completion.
968 gdb_test_no_output "alias xxx_yyy_zzz=break"
969 gdb_test_no_output "maint deprecate xxx_yyy_zzz"
970 test_gdb_complete_unique "xxx_yyy_" "xxx_yyy_zzz"
972 # Check that tab completion of a deprecated alias with a prefix does
973 # not display the warning about the alias being deprecated during tab
975 gdb_test_no_output "alias set aaa_bbb_ccc=set debug"
976 gdb_test_no_output "maint deprecate set aaa_bbb_ccc"
977 test_gdb_complete_unique "set aaa_bbb_" "set aaa_bbb_ccc"
979 # Test command completion for the disassemble command.
980 test_gdb_complete_unique \
981 "disassemble multi_line_if" \
982 "disassemble multi_line_if_conditional"
984 test_gdb_complete_multiple "disassemble " \
986 "multi_line_if_conditional"
987 "multi_line_while_conditional"
990 foreach_with_prefix spc { " " "" } {
991 test_gdb_complete_none "disassemble${spc}/"
993 foreach_with_prefix flg { "r" "b" "rb" "s" "m" "ms" } {
994 test_gdb_complete_unique "disassemble${spc}/${flg}" \
995 "disassemble${spc}/${flg}"
997 test_gdb_complete_unique \
998 "disassemble${spc}/${flg} multi_line_if" \
999 "disassemble${spc}/${flg} multi_line_if_conditional"
1001 test_gdb_complete_multiple "disassemble${spc}/${flg} " \
1003 "multi_line_if_conditional"
1004 "multi_line_while_conditional"