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