]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - gdb/testsuite/gdb.base/completion.exp
* gdb.base/constvars.exp: Remove most xfails for GCC 3.x.
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.base / completion.exp
CommitLineData
1e698235 1# Copyright 1998, 1999, 2002, 2003 Free Software Foundation, Inc.
c906108c
SS
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)
9b284272
DJ
41# "p \"break" unambiguous (completes to filename "break.c")
42# "p \"break." unambiguous (should complete to "break.c" but does not,
43# due to readline limitations)
c906108c
SS
44# "p 'a" ambiguous (all symbols starting with a)
45# "p b-a" ambiguous (all symbols starting with a)
46# "p b-" ambiguous (all symbols)
47# "file Make" "file" (word break hard to screw up here)
48# "file ../gdb.stabs/we" "ird" (needs to not break word at slash)
49#
50
51
52if $tracelevel then {
53 strace $tracelevel
54 }
55
56
c906108c
SS
57global usestubs
58
59#
60# test running programs
61#
62set prms_id 0
63set bug_id 0
64
65set testfile "break"
66set srcfile ${testfile}.c
67set binfile ${objdir}/${subdir}/${testfile}
68if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug additional_flags=-w}] != "" } {
69 gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail."
70}
71
085dd6e6
JM
72if [get_compiler_info ${binfile}] {
73 return -1;
74}
75
c906108c 76gdb_exit
5ea2a32c
KB
77
78# Don't let a .inputrc file or an existing setting of INPUTRC mess up
79# the test results. Even if /dev/null doesn't exist on the particular
80# platform, the readline library will use the default setting just by
81# failing to open the file. OTOH, opening /dev/null successfully will
82# also result in the default settings being used since nothing will be
83# read from this file.
84global env
85if [info exists env(INPUTRC)] {
86 set old_inputrc $env(INPUTRC)
87}
88set env(INPUTRC) "/dev/null"
89
c906108c
SS
90gdb_start
91gdb_reinitialize_dir $srcdir/$subdir
92gdb_load ${binfile}
93
94if ![runto_main] then {
95 perror "tests suppressed"
96}
97
98set oldtimeout1 $timeout
085dd6e6 99set timeout 30
c906108c
SS
100
101
102send_gdb "hfgfh\t"
103sleep 1
104gdb_expect {
105 -re "^hfgfh\\\x07$"\
106 { send_gdb "\n"
107 gdb_expect {
108 -re "Undefined command: \"hfgfh\"\\. Try \"help\"\\..*$gdb_prompt $"\
109 { pass "complete 'hfgfh'"}
110 -re ".*$gdb_prompt $" { fail "complete 'hfgfh'"}
111 timeout {fail "(timeout) complete 'hfgfh'"}
112 }
113 }
114 -re ".*$gdb_prompt $" { fail "complete 'hfgfh'" }
115 timeout { fail "(timeout) complete 'hfgfh'" }
116 }
117
118#exp_internal 0
119
120send_gdb "show output\t"
121sleep 1
122gdb_expect {
123 -re "^show output-radix $"\
124 { send_gdb "\n"
125 gdb_expect {
126 -re "Default output radix for printing of values is 10\\..*$gdb_prompt $"\
127 { pass "complete 'show output'"}
128 -re ".*$gdb_prompt $" { fail "complete 'show output'"}
129 timeout {fail "(timeout) complete 'show output'"}
130 }
131 }
132 -re "^show output$"\
133 { send_gdb "\n"
134 gdb_expect {
135 -re "Default output radix for printing of values is 10\\..*$gdb_prompt $"\
136 { fail "complete 'show output'"}
137 -re ".*$gdb_prompt $" { fail "complete 'show output'"}
138 timeout { fail "(timeout) complete 'show output'"}
139 }
140
141 }
142
143 -re ".*$gdb_prompt $" { fail "complete 'show output'" }
144 timeout { fail "(timeout) complete 'show output'" }
145 }
146
147
148send_gdb "show output-\t"
149sleep 1
150gdb_expect {
151 -re "^show output-radix $"\
152 { send_gdb "\n"
153 gdb_expect {
154 -re "Default output radix for printing of values is 10\\..*$gdb_prompt $"\
155 { pass "complete 'show output-'"}
156 -re ".*$gdb_prompt $" { fail "complete 'show output-'"}
157 timeout {fail "(timeout) complete 'show output-'"}
158 }
159 }
160 -re "^show output-$"\
161 { send_gdb "\n"
162 gdb_expect {
163 -re "Default output radix for printing of values is 10\\..*$gdb_prompt $"\
164 { fail "complete 'show output-'"}
165 -re ".*$gdb_prompt $" { fail "complete 'show output-'"}
166 timeout { fail "(timeout) complete 'show output-'"}
167 }
168
169 }
170
171 -re ".*$gdb_prompt $" { fail "complete 'show output-'" }
172 timeout { fail "(timeout) complete 'show output-'" }
173 }
174
175send_gdb "p\t"
176sleep 1
177gdb_expect {
178 -re "^p\\\x07$"\
179 { send_gdb "\n"
085dd6e6 180 sleep 1
c906108c
SS
181 gdb_expect {
182 -re "The history is empty\\..*$gdb_prompt $"\
183 { pass "complete 'p'"}
184 -re ".*$gdb_prompt $" { fail "complete 'p'"}
085dd6e6 185 timeout {fail "(timeout) complete 'p' 2"}
c906108c
SS
186 }
187 }
188 -re ".*$gdb_prompt $" { fail "complete 'p'" }
085dd6e6 189 timeout { fail "(timeout) complete 'p' 1" }
c906108c
SS
190 }
191
192send_gdb "p \t"
085dd6e6 193sleep 3
c906108c
SS
194gdb_expect {
195 -re "^p \\\x07$"\
196 { send_gdb "\n"
085dd6e6 197 sleep 1
c906108c
SS
198 gdb_expect {
199 -re "The history is empty\\..*$gdb_prompt $"\
200 { pass "complete 'p '"}
201 -re ".*$gdb_prompt $" { fail "complete 'p '"}
085dd6e6 202 timeout {fail "(timeout) complete 'p ' 1"}
c906108c
SS
203 }
204 }
205 -re ".*$gdb_prompt $" { fail "complete 'p '" }
085dd6e6 206 timeout { fail "(timeout) complete 'p ' 2" }
c906108c
SS
207 }
208
209
210send_gdb "info t foo\t"
211sleep 1
212gdb_expect {
213 -re "^info t foo\\\x07$"\
214 { send_gdb "\n"
215 gdb_expect {
216 -re "Ambiguous info command \"t foo\": target, terminal, threads, tp, tracepoints, types\\..*$gdb_prompt $"\
217 { pass "complete 'info t foo'"}
218 -re ".*$gdb_prompt $" { fail "complete 'info t foo'"}
219 timeout {fail "(timeout) complete 'info t foo'"}
220 }
221 }
222 -re ".*$gdb_prompt $" { fail "complete 'info t foo'" }
223 timeout { fail "(timeout) complete 'info t foo'" }
224 }
225
226send_gdb "info t\t"
227sleep 1
228gdb_expect {
229 -re "^info t\\\x07$"\
230 { send_gdb "\n"
231 gdb_expect {
232 -re "Ambiguous info command \"t\": target, terminal, threads, tp, tracepoints, types\\..
233*$gdb_prompt $"\
234 { pass "complete 'info t'"}
235 -re ".*$gdb_prompt $" { fail "complete 'info t'"}
236 timeout {fail "(timeout) complete 'info t'"}
237 }
238 }
239 -re ".*$gdb_prompt $" { fail "complete 'info t'" }
240 timeout { fail "(timeout) complete 'info t'" }
241 }
242
243
244send_gdb "info t \t"
245sleep 1
246gdb_expect {
247 -re "^info t \\\x07$"\
248 { send_gdb "\n"
249 gdb_expect {
250 -re "Ambiguous info command \"t \": target, terminal, threads, tp, tracepoints, types\\..
251*$gdb_prompt $"\
252 { pass "complete 'info t '"}
253 -re ".*$gdb_prompt $" { fail "complete 'info t '"}
254 timeout {fail "(timeout) complete 'info t '"}
255 }
256 }
257 -re ".*$gdb_prompt $" { fail "complete 'info t '" }
258 timeout { fail "(timeout) complete 'info t '" }
259 }
260
261
262send_gdb "info asdfgh\t"
263sleep 1
264gdb_expect {
265 -re "^info asdfgh\\\x07$"\
266 { send_gdb "\n"
267 gdb_expect {
268 -re "Undefined info command: \"asdfgh\". Try \"help info\"\\..
269*$gdb_prompt $"\
270 { pass "complete 'info asdfgh'"}
271 -re ".*$gdb_prompt $" { fail "complete 'info asdfgh'"}
272 timeout {fail "(timeout) complete 'info asdfgh'"}
273 }
274 }
275 -re ".*$gdb_prompt $" { fail "complete 'info asdfgh'" }
276 timeout { fail "(timeout) complete 'info asdfgh'" }
277 }
278
279
280send_gdb "info asdfgh \t"
281sleep 1
282gdb_expect {
283 -re "^info asdfgh \\\x07$"\
284 { send_gdb "\n"
285 gdb_expect {
286 -re "Undefined info command: \"asdfgh \". Try \"help info\"\\..
287*$gdb_prompt $"\
288 { pass "complete 'info asdfgh '"}
289 -re ".*$gdb_prompt $" { fail "complete 'info asdfgh '"}
290 timeout {fail "(timeout) complete 'info asdfgh '"}
291 }
292 }
293 -re ".*$gdb_prompt $" { fail "complete 'info asdfgh '" }
294 timeout { fail "(timeout) complete 'info asdfgh '" }
295 }
296
297send_gdb "info\t"
298sleep 1
299gdb_expect {
300 -re "^info $"\
301 { send_gdb "\n"
302 gdb_expect {
085dd6e6 303 -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 $"\
c906108c
SS
304 { pass "complete 'info'"}
305 -re ".*$gdb_prompt $" { fail "complete 'info'"}
306 timeout {fail "(timeout) complete 'info'"}
307 }
308 }
309 -re ".*$gdb_prompt $" { fail "complete 'info'" }
310 timeout { fail "(timeout) complete 'info'" }
311 }
312
313send_gdb "info \t"
314sleep 1
315gdb_expect {
316 -re "^info \\\x07$"\
317 { send_gdb "\n"
318 gdb_expect {
085dd6e6 319 -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 $"\
c906108c
SS
320 { pass "complete 'info '"}
321 -re ".*$gdb_prompt $" { fail "complete 'info '"}
322 timeout {fail "(timeout) complete 'info '"}
323 }
324 }
325 -re ".*$gdb_prompt $" { fail "complete 'info '" }
326 timeout { fail "(timeout) complete 'info '" }
327 }
328
329
330send_gdb "info \t"
331sleep 1
332gdb_expect {
085dd6e6 333 -re "^info \\\x07$"\
c906108c
SS
334 { send_gdb "\t"
335 gdb_expect {
336 -re "address.*types.*$gdb_prompt info $"\
337 { send_gdb "\n"
338 gdb_expect {
339 -re "\"info\".*unambiguous\\..*$gdb_prompt $"\
340 { pass "complete (2) 'info '"}
341 -re ".*$gdb_prompt $" { fail "complete (2) 'info '"}
342 timeout {fail "(timeout) complete (2) 'info '"}
343 }
344 }
345 -re ".*$gdb_prompt $" { fail "complete (2) 'info '"}
346 timeout {fail "(timeout) complete (2) 'info '"}
347 }
348 }
349 -re ".*$gdb_prompt $" { fail "complete (2) 'info '" }
350 timeout { fail "(timeout) complete (2) 'info '" }
351 }
352
353
9b284272 354send_gdb "p \"break\t"
c906108c
SS
355sleep 1
356gdb_expect {
9b284272 357 -re "^p \"break\\\x07$"\
c906108c
SS
358 { send_gdb "\n"
359 gdb_expect {
9b284272
DJ
360 -re ".*$gdb_prompt $" { fail "complete 'p \"break'"}
361 timeout {fail "(timeout) complete 'p \"break'"}
c906108c
SS
362 }
363 }
9b284272
DJ
364 -re "^p \"break\\.c\"$"\
365 { send_gdb "\n"
366 gdb_expect {
367 -re ".*$gdb_prompt $" { pass "complete 'p \"break'"}
368 timeout {fail "(timeout) complete 'p \"break'"}
369 }
370 }
371 -re "^p \"break.*$"
372 { send_gdb "\n"
373 gdb_expect {
374 -re ".*$gdb_prompt $" { fail "complete 'p \"break'"}
375 timeout {fail "(timeout) complete 'p \"break'"}
376 }
377 }
378 -re ".*$gdb_prompt $" { fail "complete 'p \"break'" }
379 timeout { fail "(timeout) complete 'p \"break'" }
380 }
381
382setup_xfail "*-*-*"
383send_gdb "p \"break.\t"
384sleep 1
385gdb_expect {
386 -re "^p \"break\\.\\\x07$"\
387 { send_gdb "\n"
388 gdb_expect {
389 -re ".*$gdb_prompt $" { fail "complete 'p \"break.'"}
390 timeout {fail "(timeout) complete 'p \"break.'"}
391 }
392 }
393 -re "^p \"break\\.c\"$"\
394 { send_gdb "\n"
395 gdb_expect {
396 -re ".*$gdb_prompt $" { pass "complete 'p \"break.'"}
397 timeout {fail "(timeout) complete 'p \"break.'"}
398 }
399 }
400 -re "^p \"break\\..*$"
401 { send_gdb "\n"
402 gdb_expect {
403 -re ".*$gdb_prompt $" { fail "complete 'p \"break.'"}
404 timeout {fail "(timeout) complete 'p \"break.'"}
405 }
406 }
407 -re ".*$gdb_prompt $" { fail "complete 'p \"break.'" }
408 timeout { fail "(timeout) complete 'p \"break.'" }
c906108c
SS
409 }
410
411send_gdb "p 'a\t"
412sleep 1
413gdb_expect {
414 -re "^p 'a\\\x07$"\
415 { send_gdb "\n"
416 gdb_expect {
f617d2b6 417 -re "(Invalid character constant\\.|Unmatched single quote\\.).*$gdb_prompt $"\
c906108c
SS
418 { pass "complete 'p \'a'"}
419 -re ".*$gdb_prompt $" { fail "complete 'p \'a'"}
420 timeout {fail "(timeout) complete 'p \'a'"}
421 }
422 }
423 -re ".*$gdb_prompt $" { fail "complete 'p \'a'" }
424 timeout { fail "(timeout) complete 'p \'a'" }
425 }
426
427send_gdb "p 'a\t"
428sleep 1
085dd6e6
JM
429gdb_expect {
430 -re "^p 'a\\\x07$" {
431 send_gdb "\t"
432 gdb_expect {
0521c418 433 -re ".*argv.*$gdb_prompt p .a$" {
085dd6e6
JM
434 send_gdb "\n"
435 gdb_expect {
f617d2b6 436 -re "(Invalid character constant\\.|Unmatched single quote\\.).*$gdb_prompt $" {
085dd6e6
JM
437 pass "complete (2) 'p \'a'"
438 }
439 -re ".*$gdb_prompt $" { fail "complete (2) 'p \'a'" }
440 timeout { fail "(timeout) complete (2) 'p \'a'" }
441 }
442 }
443 -re "(There are $decimal possibilities\\. Do you really\r\nwish to see them all.|Display all $decimal possibilities.) \\(y or n\\)$" {
444 send_gdb "n"
445 gdb_expect {
446 -re "\\(gdb\\) p 'a$" {
447 send_gdb "\n"
448 gdb_expect {
f617d2b6 449 -re "(Invalid character constant\\.|Unmatched single quote\\.).*$gdb_prompt $" {
085dd6e6
JM
450 pass "complete (2) 'p \'a'"
451 }
452 -re ".*$gdb_prompt $" {
453 fail "complete (2) 'p \'a'"
454 }
455 timeout { fail "(timeout) complete (2) 'p \'a'" }
456 }
457 }
458 -re ".*$gdb_prompt $" { fail "complete (2) 'p \'a'" }
459 timeout { fail "(timeout) complete (2) 'p \'a'" }
460 }
461 }
462 -re ".*$gdb_prompt $" { fail "complete (2) 'p \'a'" }
463 timeout { fail "(timeout) complete (2) 'p \'a'" }
464 }
465 }
466 -re ".*$gdb_prompt $" { fail "complete (2) 'p \'a'" }
467 timeout { fail "(timeout) complete (2) 'p \'a'" }
468}
c906108c
SS
469
470
6970b5b1
JB
471# These tests used to try completing the shorter "p b-a".
472# Unfortunately, on some systems, there are .o files in system
473# libraries which declare static variables named `b'. Of course,
474# those variables aren't really in scope, as far as the compiler is
475# concerned. But GDB deliberately tries to be more liberal: if you
476# enter an identifier that doesn't have any binding in scope, GDB will
477# search all the program's compilation units for a static variable of
478# the given name.
479#
480# This behavior can help avoid a lot of pedantry, so it's usually a
481# good thing. But in this test case, it causes GDB to print the value
482# of some random variable, instead of giving us the "No symbol..."
483# error we were expecting.
484#
485# For example, on S/390 linux, the file s_atan.c in libm.a declares a
486# `b', which is a structure containing an int and a float, so GDB says
487# ``Argument to arithmetic operation not a number or boolean'' instead
488# of ``No symbol ...''.
489#
490# So, I'm hoping that there is no system with a static library variable named
491# `no_var_by_this_name'.
492send_gdb "p no_var_named_this-a\t"
c906108c 493sleep 1
2d842f13 494gdb_expect {
6970b5b1 495 -re "^p no_var_named_this-a\\\x07$" {
2d842f13
JB
496 send_gdb "\n"
497 gdb_expect {
6970b5b1
JB
498 -re "No symbol \"no_var_named_this\" in current context\\..*$gdb_prompt $" {
499 pass "complete 'p no_var_named_this-a'"
2d842f13
JB
500 }
501 -re ".*$gdb_prompt $" {
6970b5b1 502 fail "complete 'p no_var_named_this-a'"
2d842f13
JB
503 }
504 timeout {
6970b5b1 505 fail "(timeout) complete 'p no_var_named_this-a'"
c906108c 506 }
c906108c 507 }
2d842f13
JB
508 }
509 -re ".*$gdb_prompt $" {
6970b5b1 510 fail "complete 'p no_var_named_this-a'"
2d842f13
JB
511 }
512 timeout {
6970b5b1 513 fail "(timeout) complete 'p no_var_named_this-a'"
2d842f13
JB
514 }
515}
c906108c 516
6970b5b1 517send_gdb "p no_var_named_this-a\t"
c906108c 518sleep 1
085dd6e6 519gdb_expect {
6970b5b1 520 -re "^p no_var_named_this-a\\\x07$" {
085dd6e6
JM
521 send_gdb "\t"
522 gdb_expect {
6970b5b1 523 -re ".*argv.*$gdb_prompt p no_var_named_this-a$" {
085dd6e6
JM
524 send_gdb "\n"
525 gdb_expect {
6970b5b1
JB
526 -re "No symbol \"no_var_named_this\" in current context\\..*$gdb_prompt $" {
527 pass "complete (2) 'p no_var_named_this-a'"
085dd6e6 528 }
6970b5b1
JB
529 -re ".*$gdb_prompt $" {
530 fail "complete (2) 'p no_var_named_this-a'"
531 }
532 timeout {
533 fail "(timeout) complete (2) 'p no_var_named_this-a'"
534 }
085dd6e6
JM
535 }
536 }
537 -re "(There are $decimal possibilities\\. Do you really\r\nwish to see them all.|Display all $decimal possibilities.) \\(y or n\\)$" {
538 send_gdb "n"
539 gdb_expect {
6970b5b1 540 -re "\\(gdb\\) p no_var_named_this-a$" {
085dd6e6
JM
541 send_gdb "\n"
542 gdb_expect {
6970b5b1
JB
543 -re "No symbol \"no_var_named_this\" in current context\\..*$gdb_prompt $" {
544 pass "complete (2) 'p no_var_named_this-a'"
085dd6e6
JM
545 }
546 -re ".*$gdb_prompt $" {
6970b5b1 547 fail "complete (2) 'p no_var_named_this-a'"
085dd6e6 548 }
6970b5b1
JB
549 timeout {
550 fail "(timeout) complete (2) 'p no_var_named_this-a'"
551 }
085dd6e6
JM
552 }
553 }
6970b5b1
JB
554 -re ".*$gdb_prompt $" {
555 fail "complete (2) 'p no_var_named_this-a'"
556 }
557 timeout {
558 fail "(timeout) complete (2) 'p no_var_named_this-a'"
559 }
085dd6e6
JM
560 }
561 }
6970b5b1
JB
562 -re ".*$gdb_prompt $" {
563 fail "complete (2) 'p no_var_named_this-a'"
564 }
565 timeout { fail "(timeout) complete (2) 'p no_var_named_this-a'" }
c906108c 566 }
085dd6e6 567 }
6970b5b1
JB
568 -re ".*$gdb_prompt $" { fail "complete (2) 'p no_var_named_this-a'" }
569 timeout { fail "(timeout) complete (2) 'p no_var_named_this-a'" }
085dd6e6 570}
c906108c 571
6970b5b1 572send_gdb "p no_var_named_this-\t"
c906108c
SS
573sleep 1
574gdb_expect {
6970b5b1 575 -re "^p no_var_named_this-\\\x07$" {
085dd6e6
JM
576 send_gdb "\t"
577 gdb_expect {
578 -re "(There are $decimal possibilities\\. Do you really\r\nwish to see them all.|Display all $decimal possibilities.) \\(y or n\\)$" {
579 send_gdb "n"
580 gdb_expect {
6970b5b1 581 -re "\\(gdb\\) p no_var_named_this-$" {
085dd6e6
JM
582 send_gdb "\n"
583 gdb_expect {
6970b5b1
JB
584 -re "No symbol \"no_var_named_this\" in current context\\..*$gdb_prompt $" {
585 pass "complete (2) 'p no_var_named_this-'"
085dd6e6
JM
586 }
587 -re ".*$gdb_prompt $" {
6970b5b1 588 fail "complete (2) 'p no_var_named_this-'"
085dd6e6 589 }
6970b5b1
JB
590 timeout {
591 fail "(timeout) complete (2) 'p no_var_named_this-'"
592 }
085dd6e6
JM
593 }
594 }
6970b5b1
JB
595 -re ".*$gdb_prompt $" {
596 fail "complete (2) 'p no_var_named_this-'"
597 }
598 timeout {
599 fail "(timeout) complete (2) 'p no_var_named_this-'"
600 }
085dd6e6
JM
601 }
602 }
6970b5b1
JB
603 -re ".*$gdb_prompt $" {
604 fail "complete (2) 'p no_var_named_this-'"
605 }
606 timeout { fail "(timeout) complete (2) 'p no_var_named_this-'" }
085dd6e6
JM
607 }
608 }
6970b5b1
JB
609 -re ".*$gdb_prompt $" { fail "complete (2) 'p no_var_named_this-'" }
610 timeout { fail "(timeout) complete (2) 'p no_var_named_this-'" }
085dd6e6 611}
c906108c 612
0eba65ab
JB
613
614# The following tests used to simply try to complete `${objdir}/Make',
615# and so on. The problem is that ${objdir} can be very long; the
616# completed filename may be more than eighty characters wide. When
617# this happens, readline tries to manage things, producing output that
618# may make sense on the screen, but is rather hard for our script to
619# recognize.
620#
621# In the case that motivated this change, the (gdb) prompt occupied
622# the leftmost six columns, and `${objdump}/' was seventy-four
623# characters long --- eighty in all. After printing the slash,
624# readline emitted a space, a carriage return, and then `Makefile'
625# (the tab character being received as input after `Make'.
626#
627# Basically, you have to let readline do whatever it's going to do to
628# make the screen look right. If it happens to use a different
629# strategy on Tuesdays to get the cursor in the right place, that's
630# not something the testsuite should care about.
631#
632# So, we avoid long lines. We `cd' to ${objdir} first, and then do
633# the completion relative to the current directory.
a6befae8
FF
634#
635# Note that if we are building in the source tree, then there will be
636# more than one completion for ./Make, so we need to handle that also.
637# A better long term solution might be to create a temporary directory,
638# populate it with a set of known names, and use that directory to
639# test completions.
0eba65ab
JB
640
641gdb_test "cd ${objdir}" "Working directory ${objdir}.*" "cd to \${objdir}"
642send_gdb "file ./Make\t"
c906108c
SS
643sleep 1
644gdb_expect {
a6befae8 645 -re "^file ./Make(\\\x07|)file.*$"\
c906108c
SS
646 { send_gdb "\n"
647 gdb_expect {
648 -re "\r\nA program is being debugged already\\. Kill it\\? \\(y or n\\) $"\
649 { send_gdb "n\n"
650 gdb_expect {
651 -re "\r\nProgram not killed\\.\r\n$gdb_prompt $"\
0eba65ab
JB
652 { pass "complete 'file ./Make'"}
653 -re ".*$gdb_prompt $" { fail "complete 'file ./Make'"}
654 timeout {fail "(timeout) complete 'file ./Make'"}
c906108c
SS
655 }
656 }
0eba65ab
JB
657 -re ".*$gdb_prompt $" { fail "complete 'file ./Make'"}
658 timeout {fail "(timeout) complete 'file ./Make'"}
c906108c
SS
659 }
660 }
0eba65ab
JB
661 -re ".*$gdb_prompt $" { fail "complete 'file ./Make'" }
662 timeout { fail "(timeout) complete 'file ./Make'" }
c906108c
SS
663 }
664
37ab3bf8
DJ
665# ${srcdir} may be a relative path. We want to make sure we end up
666# in the right directory - so make sure we know where it is.
667set mydir [pwd]
668cd ${srcdir}
669set fullsrcdir [pwd]
670cd ${mydir}
671
68ab8fc5
EZ
672# If the directory name contains a '+' we must escape it, adding a backslash.
673# If not, the test below will fail because it will interpret the '+' as a
674# regexp operator. We use string_to_regexp for this purpose.
675
676gdb_test "cd ${fullsrcdir}" \
677 "Working directory [string_to_regexp ${fullsrcdir}].*" \
678 "cd to \${srcdir}"
679
0eba65ab 680send_gdb "file ./gdb.base/compl\t"
c906108c
SS
681sleep 1
682gdb_expect {
0eba65ab 683 -re "^file ./gdb.base/completion\\.exp $"\
c906108c
SS
684 { send_gdb "\n"
685 gdb_expect {
686 -re "\r\nA program is being debugged already\\. Kill it\\? \\(y or n\\) $"
687\
688 { send_gdb "n\n"
689 gdb_expect {
690 -re "\r\nProgram not killed\\.\r\n$gdb_prompt $"\
0eba65ab
JB
691 { pass "complete 'file ./gdb.base/compl'"}
692 -re ".*$gdb_prompt $" { fail "complete 'file ./gdb.base/compl'"}
693 timeout {fail "(timeout) complete 'file ./gdb.base/compl'"}
c906108c
SS
694 }
695 }
0eba65ab
JB
696 -re ".*$gdb_prompt $" { fail "complete 'file ./gdb.base/compl'"}
697 timeout {fail "(timeout) complete 'file ./gdb.base/compl'"}
c906108c
SS
698 }
699 }
0eba65ab
JB
700 -re ".*$gdb_prompt $" { fail "complete 'file ./gdb.base/compl'" }
701 timeout { fail "(timeout) complete 'file ./gdb.base/compl'" }
c906108c
SS
702 }
703
3fe60e3c 704send_gdb "info func marke\t"
c906108c
SS
705sleep 1
706gdb_expect {
3fe60e3c 707 -re "^info func marke.*r$"\
085dd6e6
JM
708 {
709 send_gdb "\t\t"
c906108c
SS
710 sleep 3
711 gdb_expect {
085dd6e6 712 -re "marker1.*$gdb_prompt info func marker$"\
c906108c
SS
713 { send_gdb "\n"
714 gdb_expect {
1e698235 715 -re "All functions matching regular expression \"marker\":.*File.*break.c:\r\nint marker1\\((void|)\\);\r\nint marker2\\(int\\).*marker3\\(char.*char.*\\).*marker4\\(long int\\);.*$gdb_prompt $"\
3fe60e3c
EZ
716 { pass "complete 'info func marke'"}
717 -re ".*$gdb_prompt $" { fail "complete 'info func marke'"}
718 timeout {fail "(timeout) complete 'info func marke'"}
c906108c
SS
719 }
720 }
3fe60e3c
EZ
721 -re ".*$gdb_prompt $" { fail "complete 'info func marke'"}
722 timeout {fail "(timeout) complete 'info func marke'"}
c906108c
SS
723 }
724 }
3fe60e3c
EZ
725 -re ".*$gdb_prompt $" { fail "complete 'info func marke'" }
726 timeout { fail "(timeout) complete 'info func marke'" }
c906108c
SS
727 }
728
729
730send_gdb "set follow-fork-mode \t\t"
731sleep 1
732gdb_expect {
733 -re "ask.*child.*parent.*$gdb_prompt set follow-fork-mode $"\
734 { send_gdb "\n"
735 gdb_expect {
a602d56b 736 -re "Requires an argument.*ask.*child.*parent.*$gdb_prompt $"\
085dd6e6 737 { pass "complete 'set follow-fork-mode'"}
c906108c
SS
738 -re "Ambiguous item \"\"\\..*$gdb_prompt $"\
739 { pass "complete 'set follow-fork-mode'"}
740 -re ".*$gdb_prompt $" { fail "complete 'set follow-fork-mode'"}
741 timeout {fail "(timeout) complete 'set follow-fork-mode'"}
742 }
743 }
744 -re ".*$gdb_prompt $" { fail "complete 'set follow-fork-mode'" }
745 timeout { fail "(timeout) complete 'set follow-fork-mode'" }
746 }
747
5ea2a32c
KB
748# Restore globals modified in this test...
749if [info exists old_inputrc] {
750 set env(INPUTRC) $old_inputrc
751} else {
752 unset env(INPUTRC)
753}
c906108c 754set timeout $oldtimeout1
c906108c 755
5ea2a32c 756return 0