Commit | Line | Data |
---|---|---|
32d0add0 | 1 | # Copyright 1998-2015 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 | |
e22f8b7c | 5 | # the Free Software Foundation; either version 3 of the License, or |
c906108c | 6 | # (at your option) any later version. |
e22f8b7c | 7 | # |
c906108c SS |
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. | |
e22f8b7c | 12 | # |
c906108c | 13 | # You should have received a copy of the GNU General Public License |
e22f8b7c | 14 | # along with this program. If not, see <http://www.gnu.org/licenses/>. |
c906108c | 15 | |
c906108c SS |
16 | # This file was written by Elena Zannoni (ezannoni@cygnus.com) |
17 | ||
18 | # This file is part of the gdb testsuite. | |
19 | ||
20 | # | |
21 | # tests for command completion | |
22 | # | |
23 | # Here are some useful test cases for completion. | |
24 | # They should be tested with both M-? and TAB. | |
25 | # | |
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 | |
35 | # "info" " " | |
36 | # "info " ambiguous (all info commands) | |
a1dea79a FF |
37 | # "p \"break1" unambiguous (completes to filename "break1.c") |
38 | # "p \"break1." unambiguous (should complete to "break1.c" but does not, | |
9b284272 | 39 | # due to readline limitations) |
5ac01682 DJ |
40 | # "p 'arg" ambiguous (all symbols starting with arg) |
41 | # "p b-arg" ambiguous (all symbols starting with arg) | |
c906108c SS |
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) | |
45 | # | |
46 | ||
47 | ||
c906108c | 48 | |
c906108c SS |
49 | # |
50 | # test running programs | |
51 | # | |
c906108c | 52 | |
f76495c8 | 53 | standard_testfile break.c break1.c |
c906108c | 54 | |
4c93b1db | 55 | if [get_compiler_info] { |
ae59b1da | 56 | return -1 |
085dd6e6 JM |
57 | } |
58 | ||
f76495c8 TT |
59 | if {[prepare_for_testing $testfile.exp $testfile \ |
60 | [list $srcfile $srcfile2] {debug nowarnings}]} { | |
61 | untested $testfile.exp | |
62 | return -1 | |
63 | } | |
c906108c SS |
64 | |
65 | if ![runto_main] then { | |
66 | perror "tests suppressed" | |
67 | } | |
68 | ||
085dd6e6 | 69 | set timeout 30 |
ef0b411a | 70 | gdb_test_no_output "set max-completions unlimited" |
c906108c | 71 | |
0d4d0e77 YQ |
72 | gdb_test_no_output "complete print values\[0\].x." \ |
73 | "field completion with invalid field" | |
74 | ||
75 | # If there is a non-deprecated completion, it should be returned. | |
76 | gdb_test "complete sav" "save" "test non-deprecated completion" | |
77 | # If there is only a deprecated completion, then it should be returned. | |
78 | gdb_test "complete save-t" "save-tracepoints" "test deprecated completion" | |
79 | ||
80 | ||
81 | # | |
82 | # Tag name completion. | |
83 | # | |
84 | ||
85 | gdb_test "complete ptype struct some_" "ptype struct some_struct" | |
86 | gdb_test "complete ptype enum some_" "ptype enum some_enum" | |
87 | gdb_test "complete ptype union some_" "ptype union some_union" | |
88 | ||
89 | ||
90 | gdb_test "complete set gnutarget aut" "set gnutarget auto" | |
91 | ||
92 | ||
93 | gdb_test "complete set cp-abi aut" "set cp-abi auto" | |
94 | ||
95 | # Test that completion of commands 'target FOO' works well. | |
96 | set targets [list "core" "tfile" "exec"] | |
97 | ||
98 | # Test that completion of command 'target ctf' if GDB supports ctf | |
99 | # target. | |
100 | gdb_test_multiple "target ctf" "" { | |
101 | -re "Undefined target command: \"ctf\"\. Try \"help target\"\.\r\n$gdb_prompt $" { | |
102 | } | |
103 | -re "No CTF directory specified.*\r\n$gdb_prompt $" { | |
104 | lappend targets "ctf" | |
105 | } | |
106 | } | |
107 | ||
322f9c21 YQ |
108 | # Test artifacts are put in different locations depending on test |
109 | # is a parallel run or not. Firstly check file exists, and then | |
110 | # do the test on file completion. | |
111 | ||
112 | foreach dir1 [ list "./gdb.base" "./outputs/gdb.base/completion" ] { | |
d7761c2c DE |
113 | if { [remote_file host exists ${dir1}/completion] |
114 | && [remote_file host exists ${dir1}/completion0.o] | |
115 | && [remote_file host exists ${dir1}/completion1.o] } { | |
322f9c21 YQ |
116 | foreach target_name ${targets} { |
117 | gdb_test "complete target ${target_name} ${dir1}/completion" \ | |
f9579b99 TT |
118 | "target ${target_name} ${dir1}/completion.*${dir1}/completion0\\.o.*${dir1}/completion1\\.o.*" \ |
119 | "complete target ${target_name}" | |
322f9c21 YQ |
120 | } |
121 | break | |
122 | } | |
0d4d0e77 YQ |
123 | } |
124 | ||
125 | # | |
126 | # "set foo unlimited" completion. | |
127 | # | |
128 | ||
129 | # A var_uinteger command. | |
130 | gdb_test "complete set height " "set height unlimited" | |
131 | gdb_test "complete set height u" "set height unlimited" | |
132 | ||
133 | # A var_integer command. | |
134 | gdb_test "complete set listsize " "set listsize unlimited" | |
135 | gdb_test "complete set listsize unl" "set listsize unlimited" | |
136 | ||
137 | # A var_zuinteger_unlimited command. | |
138 | gdb_test "complete set trace-buffer-size " "set trace-buffer-size unlimited" | |
139 | gdb_test "complete set trace-buffer-size unl" "set trace-buffer-size unlimited" | |
140 | ||
71c24708 AA |
141 | # Test "info registers" completion: First determine this |
142 | # architecture's registers and reggroups... | |
143 | ||
144 | set regs_output [capture_command_output "mt print registers" \ | |
145 | ".*Name.*Nr.*Rel.*Offset.*Size.*Type.\[^\n\]*\n"] | |
146 | append regs_output "\n" | |
147 | append regs_output [capture_command_output "mt print reggroups" \ | |
148 | ".*Group.*Type\[^\n]*\n"] | |
25dda427 AA |
149 | append regs_output "\n" |
150 | append regs_output [capture_command_output "mt print user-registers" \ | |
151 | ".*Name.*Nr\[^\n]*\n"] | |
71c24708 AA |
152 | set all_regs {} |
153 | foreach {- reg} [regexp -all -inline -line {^\s+(\w+)} $regs_output] { | |
154 | lappend all_regs $reg | |
155 | } | |
156 | ||
71c24708 AA |
157 | set all_regs [join [lsort -unique $all_regs]] |
158 | ||
159 | # ... and then compare them to the completion of "info registers". | |
160 | ||
161 | set regs_output [capture_command_output "complete info registers " ""] | |
162 | set completed_regs {} | |
163 | foreach {-> reg} [regexp -all -inline -line {^info registers (\w+\S*)} $regs_output] { | |
164 | lappend completed_regs $reg | |
165 | } | |
166 | set completed_regs [join [lsort $completed_regs]] | |
167 | gdb_assert {{$all_regs eq $completed_regs}} "complete 'info registers '" | |
168 | ||
0d4d0e77 YQ |
169 | # Tests below are about tab-completion, which doesn't work if readline |
170 | # library isn't used. Check it first. | |
171 | ||
172 | if { ![readline_is_used] } { | |
173 | return -1 | |
174 | } | |
175 | ||
8e28d804 | 176 | set test "complete 'hfgfh'" |
c906108c | 177 | send_gdb "hfgfh\t" |
8e28d804 PA |
178 | gdb_test_multiple "" "$test" { |
179 | -re "^hfgfh\\\x07$" { | |
180 | send_gdb "\n" | |
181 | gdb_test_multiple "" $test { | |
182 | -re "Undefined command: \"hfgfh\"\\. Try \"help\"\\..*$gdb_prompt $" { | |
183 | pass "$test" | |
184 | } | |
185 | } | |
186 | } | |
187 | } | |
c906108c SS |
188 | |
189 | #exp_internal 0 | |
190 | ||
8e28d804 | 191 | set test "complete 'show output'" |
c906108c | 192 | send_gdb "show output\t" |
8e28d804 PA |
193 | gdb_test_multiple "" "$test" { |
194 | -re "^show output-radix $" { | |
195 | send_gdb "\n" | |
196 | gdb_test_multiple "" "$test" { | |
197 | -re "Default output radix for printing of values is 10\\..*$gdb_prompt $" { | |
198 | pass "$test" | |
199 | } | |
200 | } | |
201 | } | |
202 | } | |
c906108c | 203 | |
8e28d804 | 204 | set test "complete 'show output-'" |
c906108c | 205 | send_gdb "show output-\t" |
8e28d804 PA |
206 | gdb_test_multiple "" "$test" { |
207 | -re "^show output-radix $" { | |
208 | send_gdb "\n" | |
209 | gdb_test_multiple "" "$test" { | |
210 | -re "Default output radix for printing of values is 10\\..*$gdb_prompt $" { | |
211 | pass "$test" | |
212 | } | |
c906108c | 213 | } |
8e28d804 PA |
214 | } |
215 | } | |
c906108c | 216 | |
8e28d804 | 217 | set test "complete 'p'" |
c906108c | 218 | send_gdb "p\t" |
8e28d804 PA |
219 | gdb_test_multiple "" "$test" { |
220 | -re "^p\\\x07$" { | |
221 | send_gdb "\n" | |
222 | gdb_test_multiple "" "$test" { | |
223 | -re "The history is empty\\..*$gdb_prompt $" { | |
224 | pass "$test" | |
225 | } | |
c906108c | 226 | } |
8e28d804 PA |
227 | } |
228 | } | |
c906108c | 229 | |
8e28d804 | 230 | set test "complete 'p '" |
c906108c | 231 | send_gdb "p \t" |
8e28d804 PA |
232 | gdb_test_multiple "" "$test" { |
233 | -re "^p \\\x07$" { | |
234 | send_gdb "\n" | |
235 | gdb_test_multiple "" "$test" { | |
236 | -re "The history is empty\\..*$gdb_prompt $" { | |
237 | pass "$test" | |
238 | } | |
239 | } | |
240 | } | |
241 | } | |
c906108c | 242 | |
8e28d804 | 243 | set test "complete 'info t foo'" |
c906108c | 244 | send_gdb "info t foo\t" |
8e28d804 PA |
245 | gdb_test_multiple "" "$test" { |
246 | -re "^info t foo\\\x07$" { | |
247 | send_gdb "\n" | |
248 | gdb_test_multiple "" "$test" { | |
18a9fc12 | 249 | -re "Ambiguous info command \"t foo\": target, tasks, terminal, threads, tp, tracepoints, tvariables, (type-printers, )?types\\..*$gdb_prompt $" { |
8e28d804 PA |
250 | pass "$test" |
251 | } | |
252 | } | |
253 | } | |
254 | } | |
c906108c | 255 | |
8e28d804 | 256 | set test "complete 'info t'" |
c906108c | 257 | send_gdb "info t\t" |
8e28d804 PA |
258 | gdb_test_multiple "" "$test" { |
259 | -re "^info t\\\x07$" { | |
260 | send_gdb "\n" | |
261 | gdb_test_multiple "" "$test" { | |
18a9fc12 | 262 | -re "Ambiguous info command \"t\": target, tasks, terminal, threads, tp, tracepoints, tvariables, (type-printers, )?types\\..*$gdb_prompt $" { |
8e28d804 PA |
263 | pass "$test" |
264 | } | |
265 | } | |
266 | } | |
267 | } | |
c906108c | 268 | |
8e28d804 | 269 | set test "complete 'info t '" |
c906108c | 270 | send_gdb "info t \t" |
8e28d804 PA |
271 | gdb_test_multiple "" "$test" { |
272 | -re "^info t \\\x07$" { | |
273 | send_gdb "\n" | |
274 | gdb_test_multiple "" "$test" { | |
18a9fc12 | 275 | -re "Ambiguous info command \"t \": target, tasks, terminal, threads, tp, tracepoints, tvariables, (type-printers, )?types\\..*$gdb_prompt $" { |
8e28d804 PA |
276 | pass "$test" |
277 | } | |
278 | } | |
279 | } | |
280 | } | |
c906108c | 281 | |
8e28d804 | 282 | set test "complete 'info asdfgh'" |
c906108c | 283 | send_gdb "info asdfgh\t" |
8e28d804 PA |
284 | gdb_test_multiple "" "$test" { |
285 | -re "^info asdfgh\\\x07$" { | |
286 | send_gdb "\n" | |
287 | gdb_test_multiple "" "$test" { | |
288 | -re "Undefined info command: \"asdfgh\". Try \"help info\"\\..*$gdb_prompt $" { | |
289 | pass "$test" | |
290 | } | |
291 | } | |
292 | } | |
293 | } | |
c906108c | 294 | |
8e28d804 | 295 | set test "complete 'info asdfgh '" |
c906108c | 296 | send_gdb "info asdfgh \t" |
8e28d804 PA |
297 | gdb_test_multiple "" "$test" { |
298 | -re "^info asdfgh \\\x07$" { | |
299 | send_gdb "\n" | |
300 | gdb_test_multiple "" "$test" { | |
301 | -re "Undefined info command: \"asdfgh \". Try \"help info\"\\..*$gdb_prompt $" { | |
302 | pass "$test" | |
303 | } | |
304 | } | |
305 | } | |
306 | } | |
c906108c | 307 | |
8e28d804 | 308 | set test "complete 'info'" |
c906108c | 309 | send_gdb "info\t" |
8e28d804 PA |
310 | gdb_test_multiple "" "$test" { |
311 | -re "^info $" { | |
312 | send_gdb "\n" | |
313 | gdb_test_multiple "" "$test" { | |
314 | -re "\"info\" must be followed by the name of an info command\\.\r\nList of info subcommands.*$gdb_prompt $" { | |
315 | pass "$test" | |
316 | } | |
317 | } | |
318 | } | |
319 | } | |
c906108c | 320 | |
8e28d804 | 321 | set test "complete 'info '" |
c906108c | 322 | send_gdb "info \t" |
8e28d804 PA |
323 | gdb_test_multiple "" "$test" { |
324 | -re "^info \\\x07$" { | |
325 | send_gdb "\n" | |
326 | gdb_test_multiple "" "$test" { | |
327 | -re "\"info\" must be followed by the name of an info command\\.\r\nList of info subcommands:\r\n\r\n.*$gdb_prompt $" { | |
328 | pass "$test" | |
329 | } | |
330 | } | |
331 | } | |
332 | } | |
c906108c | 333 | |
8e28d804 | 334 | set test "complete (2) 'info '" |
c906108c | 335 | send_gdb "info \t" |
8e28d804 PA |
336 | gdb_test_multiple "" "$test" { |
337 | -re "^info \\\x07$" { | |
338 | send_gdb "\t" | |
339 | gdb_test_multiple "" "$test" { | |
340 | -re "address.*types.*$gdb_prompt " { | |
341 | send_gdb "\n" | |
342 | gdb_test_multiple "" "$test" { | |
343 | -re "\"info\".*unambiguous\\..*$gdb_prompt $" { | |
344 | pass "$test" | |
345 | } | |
346 | } | |
347 | } | |
348 | } | |
349 | } | |
350 | } | |
c906108c | 351 | |
8ffd0459 | 352 | set test "complete 'help info wat'" |
14032a66 | 353 | send_gdb "help info wat\t" |
8e28d804 PA |
354 | gdb_test_multiple "" "$test" { |
355 | -re "^help info watchpoints $" { | |
356 | send_gdb "\n" | |
357 | gdb_test_multiple "" "$test" { | |
358 | -re "Status of specified watchpoints.*\r\n.*$gdb_prompt $" { | |
359 | pass "$test" | |
360 | } | |
361 | } | |
362 | } | |
363 | -re "^help info wat\\\x07$" { | |
364 | fail "$test" | |
365 | } | |
366 | } | |
14032a66 | 367 | |
8e28d804 | 368 | set test "complete 'p \"break1'" |
a1dea79a | 369 | send_gdb "p \"break1\t" |
8e28d804 PA |
370 | gdb_test_multiple "" "$test" { |
371 | -re "^p \"break1\\\x07$" { | |
372 | send_gdb "\n" | |
373 | gdb_test_multiple "" "$test" {} | |
374 | } | |
375 | -re "^p \"break1\\.c\"$" { | |
376 | send_gdb "\n" | |
377 | gdb_test_multiple "" "$test" { | |
8ffd0459 | 378 | -re "$gdb_prompt $" { |
8e28d804 | 379 | pass "$test" |
9b284272 | 380 | } |
8e28d804 PA |
381 | } |
382 | } | |
383 | } | |
9b284272 DJ |
384 | |
385 | setup_xfail "*-*-*" | |
8e28d804 | 386 | set test "complete 'p \"break1.'" |
a1dea79a | 387 | send_gdb "p \"break1.\t" |
8e28d804 PA |
388 | gdb_test_multiple "" "$test" { |
389 | -re "^p \"break1\\.\\\x07$" { | |
390 | send_gdb "\n" | |
391 | gdb_test_multiple "" "$test" {} | |
392 | } | |
393 | -re "^p \"break1\\.c\"$" { | |
394 | send_gdb "\n" | |
395 | gdb_test_multiple "" "$test" { | |
8ffd0459 | 396 | -re "$gdb_prompt $" { |
8e28d804 | 397 | pass "$test" |
9b284272 | 398 | } |
8e28d804 PA |
399 | } |
400 | } | |
401 | -re "^p \"break1\\..*$" { | |
402 | send_gdb "\n" | |
403 | gdb_test_multiple "" "$test" {} | |
404 | } | |
405 | } | |
c906108c | 406 | |
8ffd0459 | 407 | set test "complete 'p 'arg'" |
5ac01682 | 408 | send_gdb "p 'arg\t" |
8e28d804 PA |
409 | gdb_test_multiple "" "$test" { |
410 | -re "^p 'arg\\\x07$" { | |
411 | send_gdb "\n" | |
412 | gdb_test_multiple "" "$test" { | |
413 | -re "(Invalid character constant\\.|Unmatched single quote\\.).*$gdb_prompt $" { | |
414 | pass "$test" | |
415 | } | |
416 | } | |
417 | } | |
418 | } | |
c906108c | 419 | |
8ffd0459 | 420 | set test "complete (2) 'p 'arg'" |
5ac01682 | 421 | send_gdb "p 'arg\t" |
8e28d804 | 422 | gdb_test_multiple "" "$test" { |
5ac01682 | 423 | -re "^p 'arg\\\x07$" { |
085dd6e6 | 424 | send_gdb "\t" |
8e28d804 | 425 | gdb_test_multiple "" "$test" { |
8ffd0459 | 426 | -re "argv.*$gdb_prompt " { |
085dd6e6 | 427 | send_gdb "\n" |
8e28d804 | 428 | gdb_test_multiple "" "$test" { |
f617d2b6 | 429 | -re "(Invalid character constant\\.|Unmatched single quote\\.).*$gdb_prompt $" { |
8e28d804 | 430 | pass "$test" |
085dd6e6 | 431 | } |
085dd6e6 JM |
432 | } |
433 | } | |
434 | -re "(There are $decimal possibilities\\. Do you really\r\nwish to see them all.|Display all $decimal possibilities.) \\(y or n\\)$" { | |
435 | send_gdb "n" | |
8e28d804 | 436 | gdb_test_multiple "" "$test" { |
5ac01682 | 437 | -re "\\(gdb\\) p 'arg$" { |
085dd6e6 | 438 | send_gdb "\n" |
8e28d804 | 439 | gdb_test_multiple "" "$test" { |
f617d2b6 | 440 | -re "(Invalid character constant\\.|Unmatched single quote\\.).*$gdb_prompt $" { |
8e28d804 | 441 | pass "$test" |
085dd6e6 | 442 | } |
085dd6e6 JM |
443 | } |
444 | } | |
085dd6e6 JM |
445 | } |
446 | } | |
085dd6e6 JM |
447 | } |
448 | } | |
085dd6e6 | 449 | } |
c906108c | 450 | |
de0bea00 MF |
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 $" { | |
455 | send_gdb "\n" | |
456 | gdb_test_multiple "" "$test" { | |
457 | -re "SIGQUIT.*Quit.*$gdb_prompt $" { | |
458 | pass "$test" | |
459 | } | |
460 | } | |
461 | } | |
462 | } | |
463 | ||
464 | set test "complete 'handle keyword'" | |
465 | send_gdb "handle nos\t" | |
466 | gdb_test_multiple "" "$test" { | |
467 | -re "^handle nostop $" { | |
468 | send_gdb "\n" | |
469 | gdb_test_multiple "" "$test" { | |
470 | -re "$gdb_prompt $" { | |
471 | pass "$test" | |
472 | } | |
473 | } | |
474 | } | |
475 | } | |
476 | ||
ace21957 MF |
477 | set test "complete help aliases" |
478 | send_gdb "help user-define\t" | |
479 | gdb_test_multiple "" "$test" { | |
480 | -re "^help user-defined $" { | |
481 | send_gdb "\n" | |
482 | gdb_test_multiple "" "$test" { | |
483 | -re "$gdb_prompt $" { | |
484 | pass "$test" | |
485 | } | |
486 | } | |
487 | } | |
488 | } | |
489 | ||
c906108c | 490 | |
6970b5b1 JB |
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 | |
498 | # the given name. | |
499 | # | |
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. | |
504 | # | |
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 ...''. | |
509 | # | |
510 | # So, I'm hoping that there is no system with a static library variable named | |
511 | # `no_var_by_this_name'. | |
8e28d804 PA |
512 | |
513 | set test "complete 'p no_var_named_this-arg'" | |
5ac01682 | 514 | send_gdb "p no_var_named_this-arg\t" |
8e28d804 | 515 | gdb_test_multiple "" "$test" { |
5ac01682 | 516 | -re "^p no_var_named_this-arg\\\x07$" { |
2d842f13 | 517 | send_gdb "\n" |
8e28d804 | 518 | gdb_test_multiple "" "$test" { |
6970b5b1 | 519 | -re "No symbol \"no_var_named_this\" in current context\\..*$gdb_prompt $" { |
8e28d804 | 520 | pass "$test" |
c906108c | 521 | } |
c906108c | 522 | } |
2d842f13 | 523 | } |
2d842f13 | 524 | } |
c906108c | 525 | |
8e28d804 | 526 | set test "complete (2) 'p no_var_named_this-arg'" |
5ac01682 | 527 | send_gdb "p no_var_named_this-arg\t" |
8e28d804 | 528 | gdb_test_multiple "" "$test" { |
5ac01682 | 529 | -re "^p no_var_named_this-arg\\\x07$" { |
085dd6e6 | 530 | send_gdb "\t" |
8e28d804 | 531 | gdb_test_multiple "" "$test" { |
8ffd0459 | 532 | -re "argv.*$gdb_prompt " { |
085dd6e6 | 533 | send_gdb "\n" |
8e28d804 | 534 | gdb_test_multiple "" "$test" { |
6970b5b1 | 535 | -re "No symbol \"no_var_named_this\" in current context\\..*$gdb_prompt $" { |
8e28d804 | 536 | pass "$test" |
085dd6e6 | 537 | } |
085dd6e6 JM |
538 | } |
539 | } | |
540 | -re "(There are $decimal possibilities\\. Do you really\r\nwish to see them all.|Display all $decimal possibilities.) \\(y or n\\)$" { | |
c4cbc0df PA |
541 | send_gdb "n\n" |
542 | ||
543 | # Eat the prompt | |
085dd6e6 | 544 | gdb_expect { |
c4cbc0df | 545 | -re "$gdb_prompt " { |
8e28d804 PA |
546 | pass "$test (eat prompt)" |
547 | } | |
548 | timeout { | |
549 | fail "(timeout) $test (eat prompt)" | |
c4cbc0df | 550 | } |
c4cbc0df PA |
551 | } |
552 | ||
8e28d804 | 553 | gdb_test_multiple "" "$test" { |
c4cbc0df | 554 | -re "No symbol \"no_var_named_this\" in current context\\..*$gdb_prompt $" { |
8e28d804 | 555 | pass "$test" |
c4cbc0df | 556 | } |
085dd6e6 JM |
557 | } |
558 | } | |
c906108c | 559 | } |
085dd6e6 | 560 | } |
085dd6e6 | 561 | } |
c906108c | 562 | |
8e28d804 | 563 | set test "complete (2) 'p no_var_named_this-'" |
6970b5b1 | 564 | send_gdb "p no_var_named_this-\t" |
8e28d804 | 565 | gdb_test_multiple "" "$test" { |
6970b5b1 | 566 | -re "^p no_var_named_this-\\\x07$" { |
085dd6e6 | 567 | send_gdb "\t" |
8e28d804 | 568 | gdb_test_multiple "" "$test" { |
085dd6e6 | 569 | -re "(There are $decimal possibilities\\. Do you really\r\nwish to see them all.|Display all $decimal possibilities.) \\(y or n\\)$" { |
c4cbc0df PA |
570 | send_gdb "n\n" |
571 | ||
572 | # Eat the prompt | |
085dd6e6 | 573 | gdb_expect { |
c4cbc0df | 574 | -re "$gdb_prompt " { |
8e28d804 PA |
575 | pass "$test (eat prompt)" |
576 | } | |
577 | timeout { | |
578 | fail "(timeout) $test (eat prompt)" | |
c4cbc0df | 579 | } |
c4cbc0df PA |
580 | } |
581 | ||
8e28d804 | 582 | gdb_test_multiple "" "$test" { |
c4cbc0df | 583 | -re "No symbol \"no_var_named_this\" in current context\\..*$gdb_prompt $" { |
8e28d804 | 584 | pass "$test" |
c4cbc0df | 585 | } |
085dd6e6 JM |
586 | } |
587 | } | |
8ffd0459 | 588 | -re "argv.*$gdb_prompt $" { |
5ac01682 | 589 | send_gdb "\n" |
8e28d804 | 590 | gdb_test_multiple "" "$test" { |
5ac01682 | 591 | -re "No symbol \"no_var_named_this\" in current context\\..*$gdb_prompt $" { |
8e28d804 | 592 | pass "$test" |
5ac01682 DJ |
593 | } |
594 | } | |
595 | } | |
085dd6e6 JM |
596 | } |
597 | } | |
085dd6e6 | 598 | } |
c906108c | 599 | |
8e28d804 | 600 | set test "complete 'p values\[0\].a'" |
65d12d83 | 601 | send_gdb "p values\[0\].a\t" |
8e28d804 PA |
602 | gdb_test_multiple "" "$test" { |
603 | -re "^p values.0..a_field $" { | |
604 | send_gdb "\n" | |
605 | gdb_test_multiple "" "$test" { | |
8ffd0459 | 606 | -re " = 0.*$gdb_prompt $" { |
8e28d804 PA |
607 | pass "$test" |
608 | } | |
609 | } | |
610 | } | |
611 | } | |
0eba65ab | 612 | |
8e28d804 | 613 | set test "complete 'p values\[0\] . a'" |
37cd5d19 | 614 | send_gdb "p values\[0\] . a\t" |
8e28d804 PA |
615 | gdb_test_multiple "" "$test" { |
616 | -re "^p values.0. . a_field $" { | |
617 | send_gdb "\n" | |
618 | gdb_test_multiple "" "$test" { | |
8ffd0459 | 619 | -re " = 0.*$gdb_prompt $" { |
8e28d804 PA |
620 | pass "$test" |
621 | } | |
622 | } | |
623 | } | |
624 | } | |
37cd5d19 | 625 | |
8e28d804 | 626 | set test "complete 'p &values\[0\] -> a'" |
37cd5d19 | 627 | send_gdb "p &values\[0\] -> a\t" |
8e28d804 PA |
628 | gdb_test_multiple "" "$test" { |
629 | -re "^p &values.0. -> a_field $" { | |
630 | send_gdb "\n" | |
631 | gdb_test_multiple "" "$test" { | |
8ffd0459 | 632 | -re " = .*0x\[0-9a-fA-F\]*.*$gdb_prompt $" { |
8e28d804 PA |
633 | pass "$test" |
634 | } | |
635 | } | |
636 | } | |
637 | } | |
37cd5d19 | 638 | |
9ae8282d TT |
639 | gdb_test "complete p &values\[0\]->z" \ |
640 | "p &values.0.->z_field" \ | |
8e28d804 | 641 | "completion of field in anonymous union" |
9ae8282d | 642 | |
4fc5d43e TT |
643 | gdb_test "complete ptype &values\[0\]->z" \ |
644 | "ptype &values.0.->z_field" \ | |
645 | "ptype completion of field in anonymous union" | |
646 | ||
647 | gdb_test "complete whatis &values\[0\]->z" \ | |
648 | "whatis &values.0.->z_field" \ | |
649 | "whatis completion of field in anonymous union" | |
650 | ||
1a371f2e | 651 | # The following tests used to simply try to complete `${objdir}/file', |
0eba65ab JB |
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 | |
656 | # recognize. | |
657 | # | |
658 | # In the case that motivated this change, the (gdb) prompt occupied | |
1a371f2e | 659 | # the leftmost six columns, and `${objdir}/' was seventy-four |
0eba65ab JB |
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'. | |
663 | # | |
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. | |
668 | # | |
669 | # So, we avoid long lines. We `cd' to ${objdir} first, and then do | |
670 | # the completion relative to the current directory. | |
c906108c | 671 | |
37ab3bf8 DJ |
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. | |
674 | set mydir [pwd] | |
675 | cd ${srcdir} | |
676 | set fullsrcdir [pwd] | |
677 | cd ${mydir} | |
678 | ||
68ab8fc5 EZ |
679 | # If the directory name contains a '+' we must escape it, adding a backslash. |
680 | # If not, the test below will fail because it will interpret the '+' as a | |
681 | # regexp operator. We use string_to_regexp for this purpose. | |
682 | ||
683 | gdb_test "cd ${fullsrcdir}" \ | |
684 | "Working directory [string_to_regexp ${fullsrcdir}].*" \ | |
685 | "cd to \${srcdir}" | |
686 | ||
cc1d7add | 687 | |
40974f91 | 688 | # GDB used to fail adding / on directories, on the first try only. |
fdc498b8 | 689 | set uniquedir ../testsuite/gdb.base/comp-dir |
40974f91 JK |
690 | set escapeduniquedir [string_to_regexp ${uniquedir}] |
691 | set uniquesu subdi | |
692 | set uniquesub ${uniquesu}r | |
693 | set escapeuniquesub [string_to_regexp ${uniquesub}] | |
40974f91 | 694 | send_gdb "dir ${uniquedir}\t" |
cc1d7add | 695 | gdb_expect { |
40974f91 | 696 | -re "${escapeduniquedir}/" { |
cc1d7add | 697 | pass "directory completion" |
40974f91 | 698 | send_gdb "${uniquesu}\t" |
cc1d7add | 699 | } |
40974f91 | 700 | -re "${escapeduniquedir} $" { |
cc1d7add | 701 | fail "directory completion (old gdb bug)" |
40974f91 | 702 | send_gdb "\b/${uniquesu}\t" |
cc1d7add PM |
703 | } |
704 | default { | |
705 | fail "directory completion (timeout)" | |
40974f91 | 706 | send_gdb "\ndir ${uniquedir}/${uniquesu}\t" |
cc1d7add PM |
707 | } |
708 | } | |
709 | ||
710 | gdb_expect { | |
40974f91 | 711 | -re "${escapeuniquesub}/$" { |
cc1d7add PM |
712 | pass "directory completion 2" |
713 | } | |
714 | timeout { | |
715 | fail "directory completion 2" | |
716 | } | |
717 | } | |
718 | ||
40974f91 JK |
719 | # Empty COMMAND sends no newline while " " sends the newline we need. |
720 | gdb_test " " "Source directories searched: .*" "Glob remaining of directory test" | |
cc1d7add | 721 | |
8e28d804 PA |
722 | gdb_test "complete file ./gdb.base/compl" \ |
723 | "file ./gdb.base/completion\\.exp.*" \ | |
724 | "complete-command 'file ./gdb.base/compl'" | |
cc1d7add | 725 | |
8e28d804 | 726 | set test "complete 'file ./gdb.base/complet'" |
f1c2644b | 727 | send_gdb "file ./gdb.base/complet\t" |
8e28d804 PA |
728 | gdb_test_multiple "" "$test" { |
729 | -re "^file ./gdb.base/completion\\.exp $" { | |
730 | send_gdb "\n" | |
731 | # Ignore the exact error message. | |
732 | gdb_test_multiple "" "complete 'file ./gdb.base/complet'" { | |
733 | -re "\r\nA program is being debugged already\\.\[\r\n\]+Are you sure you want to change the file\\? \\(y or n\\) $" { | |
734 | send_gdb "n\n" | |
735 | exp_continue | |
736 | } | |
8ffd0459 | 737 | -re "$gdb_prompt $" { |
8e28d804 PA |
738 | pass "$test" |
739 | } | |
740 | } | |
741 | } | |
742 | } | |
c906108c | 743 | |
8e28d804 | 744 | set test "complete 'info func marke'" |
3fe60e3c | 745 | send_gdb "info func marke\t" |
8e28d804 PA |
746 | gdb_test_multiple "" "$test" { |
747 | -re "^info func marke.*r$" { | |
748 | send_gdb "\t\t" | |
749 | gdb_test_multiple "" "$test" { | |
750 | -re "marker1.*$gdb_prompt " { | |
751 | send_gdb "\n" | |
752 | gdb_test_multiple "" "$test" { | |
753 | -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 $" { | |
754 | pass "$test" | |
755 | } | |
756 | } | |
757 | } | |
758 | } | |
759 | } | |
760 | } | |
c906108c SS |
761 | |
762 | ||
8e28d804 | 763 | set test "complete 'set follow-fork-mode'" |
c906108c | 764 | send_gdb "set follow-fork-mode \t\t" |
8e28d804 PA |
765 | gdb_test_multiple "" "$test" { |
766 | -re "child.*parent.*$gdb_prompt " { | |
767 | send_gdb "\n" | |
768 | gdb_test_multiple "" "$test" { | |
769 | -re "Requires an argument.*child.*parent.*$gdb_prompt $" { | |
770 | pass "$test" | |
771 | } | |
772 | -re "Ambiguous item \"\"\\..*$gdb_prompt $" { | |
773 | pass "$test" | |
774 | } | |
775 | } | |
776 | } | |
777 | } | |
c906108c | 778 | |
e27852be DE |
779 | # |
780 | # Tests for the location completer | |
781 | # | |
782 | ||
783 | # Turn off pending breakpoint support so that we don't get queried | |
784 | # all the time. | |
785 | gdb_test_no_output "set breakpoint pending off" | |
786 | ||
787 | set subsrc [string range $srcfile 0 [expr {[string length $srcfile] - 3}]] | |
788 | set test "tab complete break $subsrc" | |
789 | send_gdb "break $subsrc\t\t" | |
790 | gdb_test_multiple "" $test { | |
791 | -re "break\.c.*break1\.c.*$gdb_prompt " { | |
792 | send_gdb "1\t\n" | |
793 | gdb_test_multiple "" $test { | |
794 | -re ".*Function \"$srcfile2\" not defined\..*$gdb_prompt " { | |
795 | pass $test | |
796 | } | |
797 | -re "$gdb_prompt p$" { | |
798 | fail $test | |
799 | } | |
800 | } | |
801 | } | |
802 | ||
803 | -re "$gdb_prompt p$" { | |
804 | fail $test | |
805 | } | |
806 | } | |
807 | ||
808 | gdb_test "complete break $subsrc" "break\.c.*break1\.c" | |
809 | ||
810 | set test "tab complete break need" | |
811 | send_gdb "break need\t" | |
812 | gdb_test_multiple "" $test { | |
813 | -re "break need_malloc " { | |
814 | send_gdb "\n" | |
815 | gdb_test_multiple "" $test { | |
816 | -re ".*Breakpoint.*at .*/$srcfile, line .*$gdb_prompt " { | |
817 | pass $test | |
818 | gdb_test_no_output "delete breakpoint \$bpnum" \ | |
819 | "delete breakpoint for $test" | |
820 | } | |
821 | -re "$gdb_prompt p$" { | |
822 | fail $test | |
823 | } | |
824 | } | |
825 | } | |
826 | -re "$gdb_prompt p$" { | |
827 | fail $test | |
828 | } | |
829 | } | |
830 | ||
831 | gdb_test "complete break need" "need_malloc" | |
832 | ||
833 | # gdb/17960 | |
834 | # Enabling max-completions is necessary to trigger the bug. | |
835 | gdb_test_no_output "set max-completions 10" | |
836 | set test "tab complete break $srcfile:ma" | |
837 | send_gdb "break $srcfile:ma\t" | |
838 | gdb_test_multiple "" $test { | |
839 | -re "break $srcfile:main " { | |
840 | send_gdb "\n" | |
841 | gdb_test_multiple "" $test { | |
842 | -re ".*Breakpoint.*at .*/$srcfile, line .*$gdb_prompt " { | |
843 | pass $test | |
844 | gdb_test_no_output "delete breakpoint \$bpnum" \ | |
845 | "delete breakpoint for $test" | |
846 | } | |
847 | -re "$gdb_prompt p$" { | |
848 | fail $test | |
849 | } | |
850 | } | |
851 | } | |
852 | -re "$gdb_prompt p$" { | |
853 | fail $test | |
854 | } | |
855 | } | |
856 | ||
857 | gdb_test "complete break $srcfile:ma" "break\.c:main" | |
858 | ||
859 | # End of gdb/17960 testing. | |
860 | ||
ef0b411a GB |
861 | # |
862 | # Completion limiting. | |
863 | # | |
864 | ||
865 | gdb_test_no_output "set max-completions 5" | |
866 | ||
867 | set test "command-name completion limiting using tab character" | |
868 | send_gdb "p\t" | |
869 | gdb_test_multiple "" "$test" { | |
870 | -re "^p\\\x07$" { | |
871 | send_gdb "\t" | |
872 | gdb_test_multiple "" "$test" { | |
873 | -re "List may be truncated, max-completions reached.*\r\n$gdb_prompt p$" { | |
874 | # Complete the command and ignore the output to resync | |
875 | # gdb for the next test. | |
876 | send_gdb "\n" | |
877 | gdb_test_multiple "" "$test" { | |
878 | -re "$gdb_prompt $" { | |
879 | pass "$test" | |
880 | } | |
881 | } | |
882 | } | |
883 | -re "$gdb_prompt p$" { | |
884 | # Complete the command and ignore the output to resync | |
885 | # gdb for the next test. | |
886 | send_gdb "\n" | |
887 | gdb_test_multiple "" "$test" { | |
888 | -re "$gdb_prompt $" { | |
889 | fail "$test" | |
890 | } | |
891 | } | |
892 | } | |
893 | } | |
894 | } | |
895 | } | |
896 | ||
897 | set test "command-name completion limiting using complete command" | |
898 | send_gdb "complete p\n" | |
899 | gdb_test_multiple "" "$test" { | |
900 | -re "List may be truncated, max-completions reached.*\r\n$gdb_prompt $" { | |
901 | pass "$test" | |
902 | } | |
903 | } | |
904 | ||
905 | gdb_test_no_output "set max-completions 3" | |
906 | ||
907 | set test "symbol-name completion limiting using tab character" | |
908 | send_gdb "p marker\t" | |
909 | gdb_test_multiple "" "$test" { | |
910 | -re "^p marker\\\x07$" { | |
911 | send_gdb "\t" | |
912 | gdb_test_multiple "" "$test" { | |
913 | -re "List may be truncated, max-completions reached.*\r\n$gdb_prompt p marker$" { | |
914 | # Complete the command and ignore the output to resync | |
915 | # gdb for the next test. | |
916 | send_gdb "\n" | |
917 | gdb_test_multiple "" "$test" { | |
918 | -re "$gdb_prompt $" { | |
919 | pass "$test" | |
920 | } | |
921 | } | |
922 | } | |
923 | -re "$gdb_prompt p marker$" { | |
924 | # Complete the command and ignore the output to resync | |
925 | # gdb for the next test. | |
926 | send_gdb "\n" | |
927 | gdb_test_multiple "" "$test" { | |
928 | -re "$gdb_prompt $" { | |
929 | fail "$test" | |
930 | } | |
931 | } | |
932 | } | |
933 | } | |
934 | } | |
935 | } | |
936 | ||
937 | set test "symbol-name completion limiting using complete command" | |
938 | send_gdb "complete p mark\n" | |
939 | gdb_test_multiple "" "$test" { | |
940 | -re "List may be truncated, max-completions reached.*\r\n$gdb_prompt $" { | |
941 | pass "$test" | |
942 | } | |
943 | } | |
a0145030 AB |
944 | |
945 | gdb_test_no_output "set max-completions unlimited" | |
946 | ||
947 | if {![skip_tui_tests]} { | |
948 | set test "test completion of layout names" | |
949 | send_gdb "layout\t\t\t" | |
950 | gdb_test_multiple "" "$test" { | |
951 | -re "asm *next *prev *regs *split *src *\r\n$gdb_prompt layout $" { | |
952 | pass "$test" | |
953 | } | |
954 | } | |
955 | send_gdb "\003" | |
956 | set test "quit command input after testing layout completion" | |
957 | gdb_test_multiple "" "$test" { | |
958 | -re "$gdb_prompt $" { | |
959 | pass "$test" | |
960 | } | |
961 | } | |
962 | } | |
2e52ae68 PP |
963 | if {![skip_tui_tests]} { |
964 | with_test_prefix "focus command" { | |
965 | set test "test completion" | |
966 | send_gdb "focus \t\t" | |
967 | gdb_test_multiple "" "$test" { | |
968 | -re "cmd *next *prev *src *\r\n$gdb_prompt focus $" { | |
969 | pass "$test" | |
970 | } | |
971 | } | |
972 | send_gdb "\003" | |
973 | set test "quit command input after testing completion" | |
974 | gdb_test_multiple "" "$test" { | |
975 | -re "$gdb_prompt $" { | |
976 | pass "$test" | |
977 | } | |
978 | } | |
979 | } | |
980 | } |