Forgot to add these files. They are referent to the last commit,
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.base / completion.exp
CommitLineData
0fb0cc75 1# Copyright 1998, 1999, 2002, 2003, 2004, 2007, 2008, 2009
9b254dd1 2# Free Software Foundation, Inc.
c906108c
SS
3
4# This program is free software; you can redistribute it and/or modify
5# it under the terms of the GNU General Public License as published by
e22f8b7c 6# the Free Software Foundation; either version 3 of the License, or
c906108c 7# (at your option) any later version.
e22f8b7c 8#
c906108c
SS
9# This program is distributed in the hope that it will be useful,
10# but WITHOUT ANY WARRANTY; without even the implied warranty of
11# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12# GNU General Public License for more details.
e22f8b7c 13#
c906108c 14# You should have received a copy of the GNU General Public License
e22f8b7c 15# along with this program. If not, see <http://www.gnu.org/licenses/>.
c906108c 16
c906108c
SS
17# This file was written by Elena Zannoni (ezannoni@cygnus.com)
18
19# This file is part of the gdb testsuite.
20
21#
22# tests for command completion
23#
24# Here are some useful test cases for completion.
25# They should be tested with both M-? and TAB.
26#
27# "show output-" "radix"
28# "show output" "-radix"
29# "p" ambiguous (commands starting with p--path, print, printf, etc.)
30# "p " ambiguous (all symbols)
31# "info t foo" no completions
32# "info t " no completions
33# "info t" ambiguous ("info target", "info terminal", etc.)
34# "info ajksdlfk" no completions
35# "info ajksdlfk " no completions
36# "info" " "
37# "info " ambiguous (all info commands)
a1dea79a
FF
38# "p \"break1" unambiguous (completes to filename "break1.c")
39# "p \"break1." unambiguous (should complete to "break1.c" but does not,
9b284272 40# due to readline limitations)
5ac01682
DJ
41# "p 'arg" ambiguous (all symbols starting with arg)
42# "p b-arg" ambiguous (all symbols starting with arg)
c906108c
SS
43# "p b-" ambiguous (all symbols)
44# "file Make" "file" (word break hard to screw up here)
45# "file ../gdb.stabs/we" "ird" (needs to not break word at slash)
46#
47
48
49if $tracelevel then {
50 strace $tracelevel
51 }
52
53
c906108c
SS
54global usestubs
55
56#
57# test running programs
58#
59set prms_id 0
60set bug_id 0
61
62set testfile "break"
63set srcfile ${testfile}.c
a1dea79a 64set srcfile1 ${testfile}1.c
c906108c 65set binfile ${objdir}/${subdir}/${testfile}
a1dea79a 66
fc91c6c2 67if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}0.o" object {debug nowarnings}] != "" } {
b60f0898
JB
68 untested completion.exp
69 return -1
a1dea79a
FF
70}
71
fc91c6c2 72if { [gdb_compile "${srcdir}/${subdir}/${srcfile1}" "${binfile}1.o" object {debug nowarnings}] != "" } {
b60f0898
JB
73 untested completion.exp
74 return -1
a1dea79a
FF
75}
76
fc91c6c2 77if { [gdb_compile "${binfile}0.o ${binfile}1.o" "${binfile}" executable {debug nowarnings}] != "" } {
b60f0898
JB
78 untested completion.exp
79 return -1
c906108c
SS
80}
81
085dd6e6
JM
82if [get_compiler_info ${binfile}] {
83 return -1;
84}
85
c906108c 86gdb_exit
5ea2a32c 87
c906108c
SS
88gdb_start
89gdb_reinitialize_dir $srcdir/$subdir
90gdb_load ${binfile}
91
92if ![runto_main] then {
93 perror "tests suppressed"
94}
95
96set oldtimeout1 $timeout
085dd6e6 97set timeout 30
c906108c
SS
98
99
100send_gdb "hfgfh\t"
101sleep 1
102gdb_expect {
103 -re "^hfgfh\\\x07$"\
104 { send_gdb "\n"
105 gdb_expect {
106 -re "Undefined command: \"hfgfh\"\\. Try \"help\"\\..*$gdb_prompt $"\
107 { pass "complete 'hfgfh'"}
108 -re ".*$gdb_prompt $" { fail "complete 'hfgfh'"}
109 timeout {fail "(timeout) complete 'hfgfh'"}
110 }
111 }
112 -re ".*$gdb_prompt $" { fail "complete 'hfgfh'" }
113 timeout { fail "(timeout) complete 'hfgfh'" }
114 }
115
116#exp_internal 0
117
118send_gdb "show output\t"
119sleep 1
120gdb_expect {
121 -re "^show output-radix $"\
122 { send_gdb "\n"
123 gdb_expect {
124 -re "Default output radix for printing of values is 10\\..*$gdb_prompt $"\
125 { pass "complete 'show output'"}
126 -re ".*$gdb_prompt $" { fail "complete 'show output'"}
127 timeout {fail "(timeout) complete 'show output'"}
128 }
129 }
130 -re "^show output$"\
131 { send_gdb "\n"
132 gdb_expect {
133 -re "Default output radix for printing of values is 10\\..*$gdb_prompt $"\
134 { fail "complete 'show output'"}
135 -re ".*$gdb_prompt $" { fail "complete 'show output'"}
136 timeout { fail "(timeout) complete 'show output'"}
137 }
138
139 }
140
141 -re ".*$gdb_prompt $" { fail "complete 'show output'" }
142 timeout { fail "(timeout) complete 'show output'" }
143 }
144
145
146send_gdb "show output-\t"
147sleep 1
148gdb_expect {
149 -re "^show output-radix $"\
150 { send_gdb "\n"
151 gdb_expect {
152 -re "Default output radix for printing of values is 10\\..*$gdb_prompt $"\
153 { pass "complete 'show output-'"}
154 -re ".*$gdb_prompt $" { fail "complete 'show output-'"}
155 timeout {fail "(timeout) complete 'show output-'"}
156 }
157 }
158 -re "^show output-$"\
159 { send_gdb "\n"
160 gdb_expect {
161 -re "Default output radix for printing of values is 10\\..*$gdb_prompt $"\
162 { fail "complete 'show output-'"}
163 -re ".*$gdb_prompt $" { fail "complete 'show output-'"}
164 timeout { fail "(timeout) complete 'show output-'"}
165 }
166
167 }
168
169 -re ".*$gdb_prompt $" { fail "complete 'show output-'" }
170 timeout { fail "(timeout) complete 'show output-'" }
171 }
172
173send_gdb "p\t"
174sleep 1
175gdb_expect {
176 -re "^p\\\x07$"\
177 { send_gdb "\n"
085dd6e6 178 sleep 1
c906108c
SS
179 gdb_expect {
180 -re "The history is empty\\..*$gdb_prompt $"\
181 { pass "complete 'p'"}
182 -re ".*$gdb_prompt $" { fail "complete 'p'"}
085dd6e6 183 timeout {fail "(timeout) complete 'p' 2"}
c906108c
SS
184 }
185 }
186 -re ".*$gdb_prompt $" { fail "complete 'p'" }
085dd6e6 187 timeout { fail "(timeout) complete 'p' 1" }
c906108c
SS
188 }
189
190send_gdb "p \t"
085dd6e6 191sleep 3
c906108c
SS
192gdb_expect {
193 -re "^p \\\x07$"\
194 { send_gdb "\n"
085dd6e6 195 sleep 1
c906108c
SS
196 gdb_expect {
197 -re "The history is empty\\..*$gdb_prompt $"\
198 { pass "complete 'p '"}
199 -re ".*$gdb_prompt $" { fail "complete 'p '"}
085dd6e6 200 timeout {fail "(timeout) complete 'p ' 1"}
c906108c
SS
201 }
202 }
203 -re ".*$gdb_prompt $" { fail "complete 'p '" }
085dd6e6 204 timeout { fail "(timeout) complete 'p ' 2" }
c906108c
SS
205 }
206
207
208send_gdb "info t foo\t"
209sleep 1
210gdb_expect {
211 -re "^info t foo\\\x07$"\
212 { send_gdb "\n"
213 gdb_expect {
28148e3d 214 -re "Ambiguous info command \"t foo\": target, tasks, terminal, threads, tp, tracepoints, types\\..*$gdb_prompt $"\
c906108c
SS
215 { pass "complete 'info t foo'"}
216 -re ".*$gdb_prompt $" { fail "complete 'info t foo'"}
217 timeout {fail "(timeout) complete 'info t foo'"}
218 }
219 }
220 -re ".*$gdb_prompt $" { fail "complete 'info t foo'" }
221 timeout { fail "(timeout) complete 'info t foo'" }
222 }
223
224send_gdb "info t\t"
225sleep 1
226gdb_expect {
227 -re "^info t\\\x07$"\
228 { send_gdb "\n"
229 gdb_expect {
28148e3d 230 -re "Ambiguous info command \"t\": target, tasks, terminal, threads, tp, tracepoints, types\\..
c906108c
SS
231*$gdb_prompt $"\
232 { pass "complete 'info t'"}
233 -re ".*$gdb_prompt $" { fail "complete 'info t'"}
234 timeout {fail "(timeout) complete 'info t'"}
235 }
236 }
237 -re ".*$gdb_prompt $" { fail "complete 'info t'" }
238 timeout { fail "(timeout) complete 'info t'" }
239 }
240
241
242send_gdb "info t \t"
243sleep 1
244gdb_expect {
245 -re "^info t \\\x07$"\
246 { send_gdb "\n"
247 gdb_expect {
28148e3d 248 -re "Ambiguous info command \"t \": target, tasks, terminal, threads, tp, tracepoints, types\\..
c906108c
SS
249*$gdb_prompt $"\
250 { pass "complete 'info t '"}
251 -re ".*$gdb_prompt $" { fail "complete 'info t '"}
252 timeout {fail "(timeout) complete 'info t '"}
253 }
254 }
255 -re ".*$gdb_prompt $" { fail "complete 'info t '" }
256 timeout { fail "(timeout) complete 'info t '" }
257 }
258
259
260send_gdb "info asdfgh\t"
261sleep 1
262gdb_expect {
263 -re "^info asdfgh\\\x07$"\
264 { send_gdb "\n"
265 gdb_expect {
266 -re "Undefined info command: \"asdfgh\". Try \"help info\"\\..
267*$gdb_prompt $"\
268 { pass "complete 'info asdfgh'"}
269 -re ".*$gdb_prompt $" { fail "complete 'info asdfgh'"}
270 timeout {fail "(timeout) complete 'info asdfgh'"}
271 }
272 }
273 -re ".*$gdb_prompt $" { fail "complete 'info asdfgh'" }
274 timeout { fail "(timeout) complete 'info asdfgh'" }
275 }
276
277
278send_gdb "info asdfgh \t"
279sleep 1
280gdb_expect {
281 -re "^info asdfgh \\\x07$"\
282 { send_gdb "\n"
283 gdb_expect {
284 -re "Undefined info command: \"asdfgh \". Try \"help info\"\\..
285*$gdb_prompt $"\
286 { pass "complete 'info asdfgh '"}
287 -re ".*$gdb_prompt $" { fail "complete 'info asdfgh '"}
288 timeout {fail "(timeout) complete 'info asdfgh '"}
289 }
290 }
291 -re ".*$gdb_prompt $" { fail "complete 'info asdfgh '" }
292 timeout { fail "(timeout) complete 'info asdfgh '" }
293 }
294
295send_gdb "info\t"
296sleep 1
297gdb_expect {
298 -re "^info $"\
299 { send_gdb "\n"
300 gdb_expect {
d8295fe9 301 -re "\"info\" must be followed by the name of an info command\\.\r\nList of info subcommands.*$gdb_prompt $"\
c906108c
SS
302 { pass "complete 'info'"}
303 -re ".*$gdb_prompt $" { fail "complete 'info'"}
304 timeout {fail "(timeout) complete 'info'"}
305 }
306 }
307 -re ".*$gdb_prompt $" { fail "complete 'info'" }
308 timeout { fail "(timeout) complete 'info'" }
309 }
310
311send_gdb "info \t"
312sleep 1
313gdb_expect {
314 -re "^info \\\x07$"\
315 { send_gdb "\n"
316 gdb_expect {
d8295fe9 317 -re "\"info\" must be followed by the name of an info command\\.\r\nList of info subcommands:\r\n\r\n.*$gdb_prompt $"\
c906108c
SS
318 { pass "complete 'info '"}
319 -re ".*$gdb_prompt $" { fail "complete 'info '"}
320 timeout {fail "(timeout) complete 'info '"}
321 }
322 }
323 -re ".*$gdb_prompt $" { fail "complete 'info '" }
324 timeout { fail "(timeout) complete 'info '" }
325 }
326
327
328send_gdb "info \t"
329sleep 1
330gdb_expect {
085dd6e6 331 -re "^info \\\x07$"\
c906108c
SS
332 { send_gdb "\t"
333 gdb_expect {
334 -re "address.*types.*$gdb_prompt info $"\
335 { send_gdb "\n"
336 gdb_expect {
337 -re "\"info\".*unambiguous\\..*$gdb_prompt $"\
338 { pass "complete (2) 'info '"}
339 -re ".*$gdb_prompt $" { fail "complete (2) 'info '"}
340 timeout {fail "(timeout) complete (2) 'info '"}
341 }
342 }
343 -re ".*$gdb_prompt $" { fail "complete (2) 'info '"}
344 timeout {fail "(timeout) complete (2) 'info '"}
345 }
346 }
347 -re ".*$gdb_prompt $" { fail "complete (2) 'info '" }
348 timeout { fail "(timeout) complete (2) 'info '" }
349 }
350
351
14032a66
TT
352send_gdb "help info wat\t"
353gdb_expect {
354 -re "^help info watchpoints $"\
355 { send_gdb "\n"
356 gdb_expect {
357 -re "Synonym for .*\r\n.*$gdb_prompt $"\
358 { pass "complete help info wat" }
359 -re ".*$gdb_prompt $" { fail "complete help info wat"}
360 timeout {fail "(timeout) complete help info wat"}
361 }
362 }
363 -re "^help info wat\\\x07$" { fail "complete (2) help info wat" }
364 -re ".*$gdb_prompt $" { fail "complete (3) help info wat" }
365 timeout { fail "(timeout) complete (3) help info wat" }
366 }
367
368
a1dea79a 369send_gdb "p \"break1\t"
c906108c
SS
370sleep 1
371gdb_expect {
a1dea79a 372 -re "^p \"break1\\\x07$"\
c906108c
SS
373 { send_gdb "\n"
374 gdb_expect {
a1dea79a
FF
375 -re ".*$gdb_prompt $" { fail "complete 'p \"break1'"}
376 timeout {fail "(timeout) complete 'p \"break1'"}
c906108c
SS
377 }
378 }
a1dea79a 379 -re "^p \"break1\\.c\"$"\
9b284272
DJ
380 { send_gdb "\n"
381 gdb_expect {
a1dea79a
FF
382 -re ".*$gdb_prompt $" { pass "complete 'p \"break1'"}
383 timeout {fail "(timeout) complete 'p \"break1'"}
9b284272
DJ
384 }
385 }
a1dea79a 386 -re "^p \"break1.*$"
9b284272
DJ
387 { send_gdb "\n"
388 gdb_expect {
a1dea79a
FF
389 -re ".*$gdb_prompt $" { fail "complete 'p \"break1'"}
390 timeout {fail "(timeout) complete 'p \"break1'"}
9b284272
DJ
391 }
392 }
a1dea79a
FF
393 -re ".*$gdb_prompt $" { fail "complete 'p \"break1'" }
394 timeout { fail "(timeout) complete 'p \"break1'" }
9b284272
DJ
395 }
396
397setup_xfail "*-*-*"
a1dea79a 398send_gdb "p \"break1.\t"
9b284272
DJ
399sleep 1
400gdb_expect {
a1dea79a 401 -re "^p \"break1\\.\\\x07$"\
9b284272
DJ
402 { send_gdb "\n"
403 gdb_expect {
a1dea79a
FF
404 -re ".*$gdb_prompt $" { fail "complete 'p \"break1.'"}
405 timeout {fail "(timeout) complete 'p \"break1.'"}
9b284272
DJ
406 }
407 }
a1dea79a 408 -re "^p \"break1\\.c\"$"\
9b284272
DJ
409 { send_gdb "\n"
410 gdb_expect {
a1dea79a
FF
411 -re ".*$gdb_prompt $" { pass "complete 'p \"break1.'"}
412 timeout {fail "(timeout) complete 'p \"break1.'"}
9b284272
DJ
413 }
414 }
a1dea79a 415 -re "^p \"break1\\..*$"
9b284272
DJ
416 { send_gdb "\n"
417 gdb_expect {
a1dea79a
FF
418 -re ".*$gdb_prompt $" { fail "complete 'p \"break1.'"}
419 timeout {fail "(timeout) complete 'p \"break1.'"}
9b284272
DJ
420 }
421 }
a1dea79a
FF
422 -re ".*$gdb_prompt $" { fail "complete 'p \"break1.'" }
423 timeout { fail "(timeout) complete 'p \"break1.'" }
c906108c
SS
424 }
425
5ac01682 426send_gdb "p 'arg\t"
c906108c
SS
427sleep 1
428gdb_expect {
5ac01682 429 -re "^p 'arg\\\x07$"\
c906108c
SS
430 { send_gdb "\n"
431 gdb_expect {
f617d2b6 432 -re "(Invalid character constant\\.|Unmatched single quote\\.).*$gdb_prompt $"\
5ac01682
DJ
433 { pass "complete 'p \'arg'"}
434 -re ".*$gdb_prompt $" { fail "complete 'p \'arg'"}
435 timeout {fail "(timeout) complete 'p \'arg'"}
c906108c
SS
436 }
437 }
5ac01682
DJ
438 -re ".*$gdb_prompt $" { fail "complete 'p \'arg'" }
439 timeout { fail "(timeout) complete 'p \'arg'" }
c906108c
SS
440 }
441
5ac01682 442send_gdb "p 'arg\t"
c906108c 443sleep 1
085dd6e6 444gdb_expect {
5ac01682 445 -re "^p 'arg\\\x07$" {
085dd6e6
JM
446 send_gdb "\t"
447 gdb_expect {
5ac01682 448 -re ".*argv.*$gdb_prompt p 'arg$" {
085dd6e6
JM
449 send_gdb "\n"
450 gdb_expect {
f617d2b6 451 -re "(Invalid character constant\\.|Unmatched single quote\\.).*$gdb_prompt $" {
5ac01682 452 pass "complete (2) 'p \'arg'"
085dd6e6 453 }
5ac01682
DJ
454 -re ".*$gdb_prompt $" { fail "complete (2) 'p \'arg'" }
455 timeout { fail "(timeout) complete (2) 'p \'arg'" }
085dd6e6
JM
456 }
457 }
458 -re "(There are $decimal possibilities\\. Do you really\r\nwish to see them all.|Display all $decimal possibilities.) \\(y or n\\)$" {
459 send_gdb "n"
460 gdb_expect {
5ac01682 461 -re "\\(gdb\\) p 'arg$" {
085dd6e6
JM
462 send_gdb "\n"
463 gdb_expect {
f617d2b6 464 -re "(Invalid character constant\\.|Unmatched single quote\\.).*$gdb_prompt $" {
5ac01682 465 pass "complete (2) 'p \'arg'"
085dd6e6
JM
466 }
467 -re ".*$gdb_prompt $" {
5ac01682 468 fail "complete (2) 'p \'arg'"
085dd6e6 469 }
5ac01682 470 timeout { fail "(timeout) complete (2) 'p \'arg'" }
085dd6e6
JM
471 }
472 }
5ac01682
DJ
473 -re ".*$gdb_prompt $" { fail "complete (2) 'p \'arg'" }
474 timeout { fail "(timeout) complete (2) 'p \'arg'" }
085dd6e6
JM
475 }
476 }
5ac01682
DJ
477 -re ".*$gdb_prompt $" { fail "complete (2) 'p \'arg'" }
478 timeout { fail "(timeout) complete (2) 'p \'arg'" }
085dd6e6
JM
479 }
480 }
5ac01682
DJ
481 -re ".*$gdb_prompt $" { fail "complete (2) 'p \'arg'" }
482 timeout { fail "(timeout) complete (2) 'p \'arg'" }
085dd6e6 483}
c906108c
SS
484
485
6970b5b1
JB
486# These tests used to try completing the shorter "p b-a".
487# Unfortunately, on some systems, there are .o files in system
488# libraries which declare static variables named `b'. Of course,
489# those variables aren't really in scope, as far as the compiler is
490# concerned. But GDB deliberately tries to be more liberal: if you
491# enter an identifier that doesn't have any binding in scope, GDB will
492# search all the program's compilation units for a static variable of
493# the given name.
494#
495# This behavior can help avoid a lot of pedantry, so it's usually a
496# good thing. But in this test case, it causes GDB to print the value
497# of some random variable, instead of giving us the "No symbol..."
498# error we were expecting.
499#
500# For example, on S/390 linux, the file s_atan.c in libm.a declares a
501# `b', which is a structure containing an int and a float, so GDB says
502# ``Argument to arithmetic operation not a number or boolean'' instead
503# of ``No symbol ...''.
504#
505# So, I'm hoping that there is no system with a static library variable named
506# `no_var_by_this_name'.
5ac01682 507send_gdb "p no_var_named_this-arg\t"
c906108c 508sleep 1
2d842f13 509gdb_expect {
5ac01682 510 -re "^p no_var_named_this-arg\\\x07$" {
2d842f13
JB
511 send_gdb "\n"
512 gdb_expect {
6970b5b1 513 -re "No symbol \"no_var_named_this\" in current context\\..*$gdb_prompt $" {
5ac01682 514 pass "complete 'p no_var_named_this-arg'"
2d842f13
JB
515 }
516 -re ".*$gdb_prompt $" {
5ac01682 517 fail "complete 'p no_var_named_this-arg'"
2d842f13
JB
518 }
519 timeout {
5ac01682 520 fail "(timeout) complete 'p no_var_named_this-arg'"
c906108c 521 }
c906108c 522 }
2d842f13
JB
523 }
524 -re ".*$gdb_prompt $" {
5ac01682 525 fail "complete 'p no_var_named_this-arg'"
2d842f13
JB
526 }
527 timeout {
5ac01682 528 fail "(timeout) complete 'p no_var_named_this-arg'"
2d842f13
JB
529 }
530}
c906108c 531
5ac01682 532send_gdb "p no_var_named_this-arg\t"
c906108c 533sleep 1
085dd6e6 534gdb_expect {
5ac01682 535 -re "^p no_var_named_this-arg\\\x07$" {
085dd6e6
JM
536 send_gdb "\t"
537 gdb_expect {
5ac01682 538 -re ".*argv.*$gdb_prompt p no_var_named_this-arg$" {
085dd6e6
JM
539 send_gdb "\n"
540 gdb_expect {
6970b5b1 541 -re "No symbol \"no_var_named_this\" in current context\\..*$gdb_prompt $" {
5ac01682 542 pass "complete (2) 'p no_var_named_this-arg'"
085dd6e6 543 }
6970b5b1 544 -re ".*$gdb_prompt $" {
5ac01682 545 fail "complete (2) 'p no_var_named_this-arg'"
6970b5b1
JB
546 }
547 timeout {
5ac01682 548 fail "(timeout) complete (2) 'p no_var_named_this-arg'"
6970b5b1 549 }
085dd6e6
JM
550 }
551 }
552 -re "(There are $decimal possibilities\\. Do you really\r\nwish to see them all.|Display all $decimal possibilities.) \\(y or n\\)$" {
553 send_gdb "n"
554 gdb_expect {
5ac01682 555 -re "\\(gdb\\) p no_var_named_this-arg$" {
085dd6e6
JM
556 send_gdb "\n"
557 gdb_expect {
6970b5b1 558 -re "No symbol \"no_var_named_this\" in current context\\..*$gdb_prompt $" {
5ac01682 559 pass "complete (2) 'p no_var_named_this-arg'"
085dd6e6
JM
560 }
561 -re ".*$gdb_prompt $" {
5ac01682 562 fail "complete (2) 'p no_var_named_this-arg'"
085dd6e6 563 }
6970b5b1 564 timeout {
5ac01682 565 fail "(timeout) complete (2) 'p no_var_named_this-arg'"
6970b5b1 566 }
085dd6e6
JM
567 }
568 }
6970b5b1 569 -re ".*$gdb_prompt $" {
5ac01682 570 fail "complete (2) 'p no_var_named_this-arg'"
6970b5b1
JB
571 }
572 timeout {
5ac01682 573 fail "(timeout) complete (2) 'p no_var_named_this-arg'"
6970b5b1 574 }
085dd6e6
JM
575 }
576 }
6970b5b1 577 -re ".*$gdb_prompt $" {
5ac01682 578 fail "complete (2) 'p no_var_named_this-arg'"
6970b5b1 579 }
5ac01682 580 timeout { fail "(timeout) complete (2) 'p no_var_named_this-arg'" }
c906108c 581 }
085dd6e6 582 }
5ac01682
DJ
583 -re ".*$gdb_prompt $" { fail "complete (2) 'p no_var_named_this-arg'" }
584 timeout { fail "(timeout) complete (2) 'p no_var_named_this-arg'" }
085dd6e6 585}
c906108c 586
6970b5b1 587send_gdb "p no_var_named_this-\t"
c906108c
SS
588sleep 1
589gdb_expect {
6970b5b1 590 -re "^p no_var_named_this-\\\x07$" {
085dd6e6
JM
591 send_gdb "\t"
592 gdb_expect {
593 -re "(There are $decimal possibilities\\. Do you really\r\nwish to see them all.|Display all $decimal possibilities.) \\(y or n\\)$" {
594 send_gdb "n"
595 gdb_expect {
6970b5b1 596 -re "\\(gdb\\) p no_var_named_this-$" {
085dd6e6
JM
597 send_gdb "\n"
598 gdb_expect {
6970b5b1
JB
599 -re "No symbol \"no_var_named_this\" in current context\\..*$gdb_prompt $" {
600 pass "complete (2) 'p no_var_named_this-'"
085dd6e6
JM
601 }
602 -re ".*$gdb_prompt $" {
6970b5b1 603 fail "complete (2) 'p no_var_named_this-'"
085dd6e6 604 }
6970b5b1
JB
605 timeout {
606 fail "(timeout) complete (2) 'p no_var_named_this-'"
607 }
085dd6e6
JM
608 }
609 }
6970b5b1
JB
610 -re ".*$gdb_prompt $" {
611 fail "complete (2) 'p no_var_named_this-'"
612 }
613 timeout {
614 fail "(timeout) complete (2) 'p no_var_named_this-'"
615 }
085dd6e6
JM
616 }
617 }
5ac01682
DJ
618 -re ".*argv.*$gdb_prompt p no_var_named_this-$" {
619 send_gdb "\n"
620 gdb_expect {
621 -re "No symbol \"no_var_named_this\" in current context\\..*$gdb_prompt $" {
622 pass "complete (2) 'p no_var_named_this-'"
623 }
624 -re ".*$gdb_prompt $" {
625 fail "complete (2) 'p no_var_named_this-'"
626 }
627 timeout {
628 fail "(timeout) complete (2) 'p no_var_named_this-'"
629 }
630 }
631 }
6970b5b1
JB
632 -re ".*$gdb_prompt $" {
633 fail "complete (2) 'p no_var_named_this-'"
634 }
635 timeout { fail "(timeout) complete (2) 'p no_var_named_this-'" }
085dd6e6
JM
636 }
637 }
6970b5b1
JB
638 -re ".*$gdb_prompt $" { fail "complete (2) 'p no_var_named_this-'" }
639 timeout { fail "(timeout) complete (2) 'p no_var_named_this-'" }
085dd6e6 640}
c906108c 641
65d12d83
TT
642send_gdb "p values\[0\].a\t"
643sleep 3
644gdb_expect {
645 -re "^p values.0..a_field $"\
646 { send_gdb "\n"
647 sleep 1
648 gdb_expect {
649 -re "^.* = 0.*$gdb_prompt $"\
650 { pass "complete 'p values\[0\].a'"}
651 -re ".*$gdb_prompt $" { fail "complete 'p values\[0\].a'"}
652 timeout {fail "(timeout) complete 'p values\[0\].a'"}
653 }
654 }
655 -re ".*$gdb_prompt $" { fail "complete 'p values\[0\].a'" }
656 timeout { fail "(timeout) complete 'p values\[0\].a' 2" }
657 }
0eba65ab 658
37cd5d19
TT
659send_gdb "p values\[0\] . a\t"
660gdb_expect {
661 -re "^p values.0. . a_field $"\
662 { send_gdb "\n"
663 gdb_expect {
664 -re "^.* = 0.*$gdb_prompt $"\
665 { pass "complete 'p values\[0\] . a'"}
666 -re ".*$gdb_prompt $" { fail "complete 'p values\[0\] . a'"}
667 timeout {fail "(timeout) complete 'p values\[0\] . a'"}
668 }
669 }
670 -re ".*$gdb_prompt $" { fail "complete 'p values\[0\] . a'" }
671 timeout { fail "(timeout) complete 'p values\[0\] . a' 2" }
672 }
673
674send_gdb "p &values\[0\] -> a\t"
675gdb_expect {
676 -re "^p &values.0. -> a_field $"\
677 { send_gdb "\n"
678 gdb_expect {
679 -re "^.* = .*0x\[0-9a-fA-F\]*.*$gdb_prompt $"\
680 { pass "complete 'p &values\[0\] -> a'"}
681 -re ".*$gdb_prompt $" { fail "complete 'p &values\[0\] -> a'"}
682 timeout {fail "(timeout) complete 'p &values\[0\] -> a'"}
683 }
684 }
685 -re ".*$gdb_prompt $" { fail "complete 'p &values\[0\] -> a'" }
686 timeout { fail "(timeout) complete 'p &values\[0\] -> a' 2" }
687 }
688
1a371f2e 689# The following tests used to simply try to complete `${objdir}/file',
0eba65ab
JB
690# and so on. The problem is that ${objdir} can be very long; the
691# completed filename may be more than eighty characters wide. When
692# this happens, readline tries to manage things, producing output that
693# may make sense on the screen, but is rather hard for our script to
694# recognize.
695#
696# In the case that motivated this change, the (gdb) prompt occupied
1a371f2e 697# the leftmost six columns, and `${objdir}/' was seventy-four
0eba65ab
JB
698# characters long --- eighty in all. After printing the slash,
699# readline emitted a space, a carriage return, and then `Makefile'
700# (the tab character being received as input after `Make'.
701#
702# Basically, you have to let readline do whatever it's going to do to
703# make the screen look right. If it happens to use a different
704# strategy on Tuesdays to get the cursor in the right place, that's
705# not something the testsuite should care about.
706#
707# So, we avoid long lines. We `cd' to ${objdir} first, and then do
708# the completion relative to the current directory.
c906108c 709
37ab3bf8
DJ
710# ${srcdir} may be a relative path. We want to make sure we end up
711# in the right directory - so make sure we know where it is.
712set mydir [pwd]
713cd ${srcdir}
714set fullsrcdir [pwd]
715cd ${mydir}
716
68ab8fc5
EZ
717# If the directory name contains a '+' we must escape it, adding a backslash.
718# If not, the test below will fail because it will interpret the '+' as a
719# regexp operator. We use string_to_regexp for this purpose.
720
721gdb_test "cd ${fullsrcdir}" \
722 "Working directory [string_to_regexp ${fullsrcdir}].*" \
723 "cd to \${srcdir}"
724
cc1d7add 725
40974f91
JK
726# GDB used to fail adding / on directories, on the first try only.
727# Do not use the `completion' start here as it would conflict with the
728# testcase (complete 'file ./gdb.base/complet') expectations.
729set uniquedir ${objdir}/${subdir}/compl-uNiQuEdIr
730set escapeduniquedir [string_to_regexp ${uniquedir}]
731set uniquesu subdi
732set uniquesub ${uniquesu}r
733set escapeuniquesub [string_to_regexp ${uniquesub}]
734file mkdir ${uniquedir}/${uniquesub}
735send_gdb "dir ${uniquedir}\t"
cc1d7add 736gdb_expect {
40974f91 737 -re "${escapeduniquedir}/" {
cc1d7add 738 pass "directory completion"
40974f91 739 send_gdb "${uniquesu}\t"
cc1d7add 740 }
40974f91 741 -re "${escapeduniquedir} $" {
cc1d7add 742 fail "directory completion (old gdb bug)"
40974f91 743 send_gdb "\b/${uniquesu}\t"
cc1d7add
PM
744 }
745 default {
746 fail "directory completion (timeout)"
40974f91 747 send_gdb "\ndir ${uniquedir}/${uniquesu}\t"
cc1d7add
PM
748 }
749}
750
751gdb_expect {
40974f91 752 -re "${escapeuniquesub}/$" {
cc1d7add
PM
753 pass "directory completion 2"
754 }
755 timeout {
756 fail "directory completion 2"
757 }
758}
759
40974f91
JK
760# Empty COMMAND sends no newline while " " sends the newline we need.
761gdb_test " " "Source directories searched: .*" "Glob remaining of directory test"
cc1d7add
PM
762
763
ce22a4f1
DJ
764send_gdb "complete file ./gdb.base/compl\n"
765sleep 1
766gdb_expect {
767 -re "file ./gdb.base/completion\\.exp.*$gdb_prompt $"
768 { pass "complete-command 'file ./gdb.base/compl'"}
769 -re ".*$gdb_prompt $" { fail "complete-command 'file ./gdb.base/compl'" }
770 timeout { fail "(timeout) complete-command 'file ./gdb.base/compl'" }
771}
772
f1c2644b 773send_gdb "file ./gdb.base/complet\t"
c906108c
SS
774sleep 1
775gdb_expect {
0eba65ab 776 -re "^file ./gdb.base/completion\\.exp $"\
c906108c 777 { send_gdb "\n"
4c42eaff
DJ
778 # Ignore the exact error message.
779 gdb_test_multiple "" "complete 'file ./gdb.base/complet'" {
780 -re "\r\nA program is being debugged already\\.\[\r\n\]+Are you sure you want to change the file\\? \\(y or n\\) $" {
781 send_gdb "n\n"
782 exp_continue
783 }
784 -re ".*$gdb_prompt $" { pass "complete 'file ./gdb.base/complet'" }
785 }
c906108c 786 }
f1c2644b
DJ
787 -re ".*$gdb_prompt $" { fail "complete 'file ./gdb.base/complet'" }
788 timeout { fail "(timeout) complete 'file ./gdb.base/complet'" }
c906108c
SS
789 }
790
3fe60e3c 791send_gdb "info func marke\t"
c906108c
SS
792sleep 1
793gdb_expect {
3fe60e3c 794 -re "^info func marke.*r$"\
085dd6e6
JM
795 {
796 send_gdb "\t\t"
c906108c
SS
797 sleep 3
798 gdb_expect {
085dd6e6 799 -re "marker1.*$gdb_prompt info func marker$"\
c906108c
SS
800 { send_gdb "\n"
801 gdb_expect {
a1dea79a 802 -re "All functions matching regular expression \"marker\":.*File.*break1.c:\r\nint marker1\\((void|)\\);\r\nint marker2\\(int\\).*marker3\\(char.*char.*\\).*marker4\\(long int\\);.*$gdb_prompt $"\
3fe60e3c
EZ
803 { pass "complete 'info func marke'"}
804 -re ".*$gdb_prompt $" { fail "complete 'info func marke'"}
805 timeout {fail "(timeout) complete 'info func marke'"}
c906108c
SS
806 }
807 }
3fe60e3c
EZ
808 -re ".*$gdb_prompt $" { fail "complete 'info func marke'"}
809 timeout {fail "(timeout) complete 'info func marke'"}
c906108c
SS
810 }
811 }
3fe60e3c
EZ
812 -re ".*$gdb_prompt $" { fail "complete 'info func marke'" }
813 timeout { fail "(timeout) complete 'info func marke'" }
c906108c
SS
814 }
815
816
817send_gdb "set follow-fork-mode \t\t"
818sleep 1
819gdb_expect {
2970ae72 820 -re "child.*parent.*$gdb_prompt set follow-fork-mode $"\
c906108c
SS
821 { send_gdb "\n"
822 gdb_expect {
2970ae72 823 -re "Requires an argument.*child.*parent.*$gdb_prompt $"\
085dd6e6 824 { pass "complete 'set follow-fork-mode'"}
c906108c
SS
825 -re "Ambiguous item \"\"\\..*$gdb_prompt $"\
826 { pass "complete 'set follow-fork-mode'"}
827 -re ".*$gdb_prompt $" { fail "complete 'set follow-fork-mode'"}
828 timeout {fail "(timeout) complete 'set follow-fork-mode'"}
829 }
830 }
831 -re ".*$gdb_prompt $" { fail "complete 'set follow-fork-mode'" }
832 timeout { fail "(timeout) complete 'set follow-fork-mode'" }
833 }
834
6f4de6c9
JK
835send_gdb "p values\[0\].nonex.\t"
836gdb_expect {
837 -re "Type struct some_struct has no component named nonex.\r\n$gdb_prompt $"\
838 { pass "Completing non-existing component" }
839 -re ".*$gdb_prompt $" { fail "Completing non-existing component" }
840 timeout { fail "(timeout) Completing non-existing component" }
841 eof { fail "(eof) Completing non-existing component #2" }
842 }
843# Double memory freeing gets found only on the second run:
844send_gdb "p values\[0\].nonex.\t"
845gdb_expect {
846 -re "Type struct some_struct has no component named nonex.\r\n$gdb_prompt $"\
847 { pass "Completing non-existing component #2" }
848 -re ".*$gdb_prompt $" { fail "Completing non-existing component #2" }
849 timeout { fail "(timeout) Completing non-existing component #2" }
850 eof { fail "(eof) Completing non-existing component #2" }
851 }
852
5ea2a32c 853# Restore globals modified in this test...
c906108c 854set timeout $oldtimeout1
c906108c 855
5ea2a32c 856return 0
This page took 0.972275 seconds and 4 git commands to generate.