Commit | Line | Data |
---|---|---|
ecd75fc8 | 1 | # Copyright 1998-2014 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 | ||
69 | set oldtimeout1 $timeout | |
085dd6e6 | 70 | set timeout 30 |
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 | ||
108 | foreach target_name ${targets} { | |
109 | gdb_test "complete target ${target_name} ./gdb.base/completion" \ | |
110 | "target ${target_name} \\./gdb.base/completion.*\\./gdb.base/completion0\\.o.*\\./gdb.base/completion1\\.o.*" | |
111 | } | |
112 | ||
113 | # | |
114 | # "set foo unlimited" completion. | |
115 | # | |
116 | ||
117 | # A var_uinteger command. | |
118 | gdb_test "complete set height " "set height unlimited" | |
119 | gdb_test "complete set height u" "set height unlimited" | |
120 | ||
121 | # A var_integer command. | |
122 | gdb_test "complete set listsize " "set listsize unlimited" | |
123 | gdb_test "complete set listsize unl" "set listsize unlimited" | |
124 | ||
125 | # A var_zuinteger_unlimited command. | |
126 | gdb_test "complete set trace-buffer-size " "set trace-buffer-size unlimited" | |
127 | gdb_test "complete set trace-buffer-size unl" "set trace-buffer-size unlimited" | |
128 | ||
129 | # Tests below are about tab-completion, which doesn't work if readline | |
130 | # library isn't used. Check it first. | |
131 | ||
132 | if { ![readline_is_used] } { | |
133 | return -1 | |
134 | } | |
135 | ||
8e28d804 | 136 | set test "complete 'hfgfh'" |
c906108c | 137 | send_gdb "hfgfh\t" |
8e28d804 PA |
138 | gdb_test_multiple "" "$test" { |
139 | -re "^hfgfh\\\x07$" { | |
140 | send_gdb "\n" | |
141 | gdb_test_multiple "" $test { | |
142 | -re "Undefined command: \"hfgfh\"\\. Try \"help\"\\..*$gdb_prompt $" { | |
143 | pass "$test" | |
144 | } | |
145 | } | |
146 | } | |
147 | } | |
c906108c SS |
148 | |
149 | #exp_internal 0 | |
150 | ||
8e28d804 | 151 | set test "complete 'show output'" |
c906108c | 152 | send_gdb "show output\t" |
8e28d804 PA |
153 | gdb_test_multiple "" "$test" { |
154 | -re "^show output-radix $" { | |
155 | send_gdb "\n" | |
156 | gdb_test_multiple "" "$test" { | |
157 | -re "Default output radix for printing of values is 10\\..*$gdb_prompt $" { | |
158 | pass "$test" | |
159 | } | |
160 | } | |
161 | } | |
162 | } | |
c906108c | 163 | |
8e28d804 | 164 | set test "complete 'show output-'" |
c906108c | 165 | send_gdb "show output-\t" |
8e28d804 PA |
166 | gdb_test_multiple "" "$test" { |
167 | -re "^show output-radix $" { | |
168 | send_gdb "\n" | |
169 | gdb_test_multiple "" "$test" { | |
170 | -re "Default output radix for printing of values is 10\\..*$gdb_prompt $" { | |
171 | pass "$test" | |
172 | } | |
c906108c | 173 | } |
8e28d804 PA |
174 | } |
175 | } | |
c906108c | 176 | |
8e28d804 | 177 | set test "complete 'p'" |
c906108c | 178 | send_gdb "p\t" |
8e28d804 PA |
179 | gdb_test_multiple "" "$test" { |
180 | -re "^p\\\x07$" { | |
181 | send_gdb "\n" | |
182 | gdb_test_multiple "" "$test" { | |
183 | -re "The history is empty\\..*$gdb_prompt $" { | |
184 | pass "$test" | |
185 | } | |
c906108c | 186 | } |
8e28d804 PA |
187 | } |
188 | } | |
c906108c | 189 | |
8e28d804 | 190 | set test "complete 'p '" |
c906108c | 191 | send_gdb "p \t" |
8e28d804 PA |
192 | gdb_test_multiple "" "$test" { |
193 | -re "^p \\\x07$" { | |
194 | send_gdb "\n" | |
195 | gdb_test_multiple "" "$test" { | |
196 | -re "The history is empty\\..*$gdb_prompt $" { | |
197 | pass "$test" | |
198 | } | |
199 | } | |
200 | } | |
201 | } | |
c906108c | 202 | |
8e28d804 | 203 | set test "complete 'info t foo'" |
c906108c | 204 | send_gdb "info t foo\t" |
8e28d804 PA |
205 | gdb_test_multiple "" "$test" { |
206 | -re "^info t foo\\\x07$" { | |
207 | send_gdb "\n" | |
208 | gdb_test_multiple "" "$test" { | |
18a9fc12 | 209 | -re "Ambiguous info command \"t foo\": target, tasks, terminal, threads, tp, tracepoints, tvariables, (type-printers, )?types\\..*$gdb_prompt $" { |
8e28d804 PA |
210 | pass "$test" |
211 | } | |
212 | } | |
213 | } | |
214 | } | |
c906108c | 215 | |
8e28d804 | 216 | set test "complete 'info t'" |
c906108c | 217 | send_gdb "info t\t" |
8e28d804 PA |
218 | gdb_test_multiple "" "$test" { |
219 | -re "^info t\\\x07$" { | |
220 | send_gdb "\n" | |
221 | gdb_test_multiple "" "$test" { | |
18a9fc12 | 222 | -re "Ambiguous info command \"t\": target, tasks, terminal, threads, tp, tracepoints, tvariables, (type-printers, )?types\\..*$gdb_prompt $" { |
8e28d804 PA |
223 | pass "$test" |
224 | } | |
225 | } | |
226 | } | |
227 | } | |
c906108c | 228 | |
8e28d804 | 229 | set test "complete 'info t '" |
c906108c | 230 | send_gdb "info t \t" |
8e28d804 PA |
231 | gdb_test_multiple "" "$test" { |
232 | -re "^info t \\\x07$" { | |
233 | send_gdb "\n" | |
234 | gdb_test_multiple "" "$test" { | |
18a9fc12 | 235 | -re "Ambiguous info command \"t \": target, tasks, terminal, threads, tp, tracepoints, tvariables, (type-printers, )?types\\..*$gdb_prompt $" { |
8e28d804 PA |
236 | pass "$test" |
237 | } | |
238 | } | |
239 | } | |
240 | } | |
c906108c | 241 | |
8e28d804 | 242 | set test "complete 'info asdfgh'" |
c906108c | 243 | send_gdb "info asdfgh\t" |
8e28d804 PA |
244 | gdb_test_multiple "" "$test" { |
245 | -re "^info asdfgh\\\x07$" { | |
246 | send_gdb "\n" | |
247 | gdb_test_multiple "" "$test" { | |
248 | -re "Undefined info command: \"asdfgh\". Try \"help info\"\\..*$gdb_prompt $" { | |
249 | pass "$test" | |
250 | } | |
251 | } | |
252 | } | |
253 | } | |
c906108c | 254 | |
8e28d804 | 255 | set test "complete 'info asdfgh '" |
c906108c | 256 | send_gdb "info asdfgh \t" |
8e28d804 PA |
257 | gdb_test_multiple "" "$test" { |
258 | -re "^info asdfgh \\\x07$" { | |
259 | send_gdb "\n" | |
260 | gdb_test_multiple "" "$test" { | |
261 | -re "Undefined info command: \"asdfgh \". Try \"help info\"\\..*$gdb_prompt $" { | |
262 | pass "$test" | |
263 | } | |
264 | } | |
265 | } | |
266 | } | |
c906108c | 267 | |
8e28d804 | 268 | set test "complete 'info'" |
c906108c | 269 | send_gdb "info\t" |
8e28d804 PA |
270 | gdb_test_multiple "" "$test" { |
271 | -re "^info $" { | |
272 | send_gdb "\n" | |
273 | gdb_test_multiple "" "$test" { | |
274 | -re "\"info\" must be followed by the name of an info command\\.\r\nList of info subcommands.*$gdb_prompt $" { | |
275 | pass "$test" | |
276 | } | |
277 | } | |
278 | } | |
279 | } | |
c906108c | 280 | |
8e28d804 | 281 | set test "complete 'info '" |
c906108c | 282 | send_gdb "info \t" |
8e28d804 PA |
283 | gdb_test_multiple "" "$test" { |
284 | -re "^info \\\x07$" { | |
285 | send_gdb "\n" | |
286 | gdb_test_multiple "" "$test" { | |
287 | -re "\"info\" must be followed by the name of an info command\\.\r\nList of info subcommands:\r\n\r\n.*$gdb_prompt $" { | |
288 | pass "$test" | |
289 | } | |
290 | } | |
291 | } | |
292 | } | |
c906108c | 293 | |
8e28d804 | 294 | set test "complete (2) 'info '" |
c906108c | 295 | send_gdb "info \t" |
8e28d804 PA |
296 | gdb_test_multiple "" "$test" { |
297 | -re "^info \\\x07$" { | |
298 | send_gdb "\t" | |
299 | gdb_test_multiple "" "$test" { | |
300 | -re "address.*types.*$gdb_prompt " { | |
301 | send_gdb "\n" | |
302 | gdb_test_multiple "" "$test" { | |
303 | -re "\"info\".*unambiguous\\..*$gdb_prompt $" { | |
304 | pass "$test" | |
305 | } | |
306 | } | |
307 | } | |
308 | } | |
309 | } | |
310 | } | |
c906108c | 311 | |
8ffd0459 | 312 | set test "complete 'help info wat'" |
14032a66 | 313 | send_gdb "help info wat\t" |
8e28d804 PA |
314 | gdb_test_multiple "" "$test" { |
315 | -re "^help info watchpoints $" { | |
316 | send_gdb "\n" | |
317 | gdb_test_multiple "" "$test" { | |
318 | -re "Status of specified watchpoints.*\r\n.*$gdb_prompt $" { | |
319 | pass "$test" | |
320 | } | |
321 | } | |
322 | } | |
323 | -re "^help info wat\\\x07$" { | |
324 | fail "$test" | |
325 | } | |
326 | } | |
14032a66 | 327 | |
8e28d804 | 328 | set test "complete 'p \"break1'" |
a1dea79a | 329 | send_gdb "p \"break1\t" |
8e28d804 PA |
330 | gdb_test_multiple "" "$test" { |
331 | -re "^p \"break1\\\x07$" { | |
332 | send_gdb "\n" | |
333 | gdb_test_multiple "" "$test" {} | |
334 | } | |
335 | -re "^p \"break1\\.c\"$" { | |
336 | send_gdb "\n" | |
337 | gdb_test_multiple "" "$test" { | |
8ffd0459 | 338 | -re "$gdb_prompt $" { |
8e28d804 | 339 | pass "$test" |
9b284272 | 340 | } |
8e28d804 PA |
341 | } |
342 | } | |
343 | } | |
9b284272 DJ |
344 | |
345 | setup_xfail "*-*-*" | |
8e28d804 | 346 | set test "complete 'p \"break1.'" |
a1dea79a | 347 | send_gdb "p \"break1.\t" |
8e28d804 PA |
348 | gdb_test_multiple "" "$test" { |
349 | -re "^p \"break1\\.\\\x07$" { | |
350 | send_gdb "\n" | |
351 | gdb_test_multiple "" "$test" {} | |
352 | } | |
353 | -re "^p \"break1\\.c\"$" { | |
354 | send_gdb "\n" | |
355 | gdb_test_multiple "" "$test" { | |
8ffd0459 | 356 | -re "$gdb_prompt $" { |
8e28d804 | 357 | pass "$test" |
9b284272 | 358 | } |
8e28d804 PA |
359 | } |
360 | } | |
361 | -re "^p \"break1\\..*$" { | |
362 | send_gdb "\n" | |
363 | gdb_test_multiple "" "$test" {} | |
364 | } | |
365 | } | |
c906108c | 366 | |
8ffd0459 | 367 | set test "complete 'p 'arg'" |
5ac01682 | 368 | send_gdb "p 'arg\t" |
8e28d804 PA |
369 | gdb_test_multiple "" "$test" { |
370 | -re "^p 'arg\\\x07$" { | |
371 | send_gdb "\n" | |
372 | gdb_test_multiple "" "$test" { | |
373 | -re "(Invalid character constant\\.|Unmatched single quote\\.).*$gdb_prompt $" { | |
374 | pass "$test" | |
375 | } | |
376 | } | |
377 | } | |
378 | } | |
c906108c | 379 | |
8ffd0459 | 380 | set test "complete (2) 'p 'arg'" |
5ac01682 | 381 | send_gdb "p 'arg\t" |
8e28d804 | 382 | gdb_test_multiple "" "$test" { |
5ac01682 | 383 | -re "^p 'arg\\\x07$" { |
085dd6e6 | 384 | send_gdb "\t" |
8e28d804 | 385 | gdb_test_multiple "" "$test" { |
8ffd0459 | 386 | -re "argv.*$gdb_prompt " { |
085dd6e6 | 387 | send_gdb "\n" |
8e28d804 | 388 | gdb_test_multiple "" "$test" { |
f617d2b6 | 389 | -re "(Invalid character constant\\.|Unmatched single quote\\.).*$gdb_prompt $" { |
8e28d804 | 390 | pass "$test" |
085dd6e6 | 391 | } |
085dd6e6 JM |
392 | } |
393 | } | |
394 | -re "(There are $decimal possibilities\\. Do you really\r\nwish to see them all.|Display all $decimal possibilities.) \\(y or n\\)$" { | |
395 | send_gdb "n" | |
8e28d804 | 396 | gdb_test_multiple "" "$test" { |
5ac01682 | 397 | -re "\\(gdb\\) p 'arg$" { |
085dd6e6 | 398 | send_gdb "\n" |
8e28d804 | 399 | gdb_test_multiple "" "$test" { |
f617d2b6 | 400 | -re "(Invalid character constant\\.|Unmatched single quote\\.).*$gdb_prompt $" { |
8e28d804 | 401 | pass "$test" |
085dd6e6 | 402 | } |
085dd6e6 JM |
403 | } |
404 | } | |
085dd6e6 JM |
405 | } |
406 | } | |
085dd6e6 JM |
407 | } |
408 | } | |
085dd6e6 | 409 | } |
c906108c | 410 | |
de0bea00 MF |
411 | set test "complete 'handle signal'" |
412 | send_gdb "handle sigq\t" | |
413 | gdb_test_multiple "" "$test" { | |
414 | -re "^handle sigq\b\b\b\bSIGQUIT $" { | |
415 | send_gdb "\n" | |
416 | gdb_test_multiple "" "$test" { | |
417 | -re "SIGQUIT.*Quit.*$gdb_prompt $" { | |
418 | pass "$test" | |
419 | } | |
420 | } | |
421 | } | |
422 | } | |
423 | ||
424 | set test "complete 'handle keyword'" | |
425 | send_gdb "handle nos\t" | |
426 | gdb_test_multiple "" "$test" { | |
427 | -re "^handle nostop $" { | |
428 | send_gdb "\n" | |
429 | gdb_test_multiple "" "$test" { | |
430 | -re "$gdb_prompt $" { | |
431 | pass "$test" | |
432 | } | |
433 | } | |
434 | } | |
435 | } | |
436 | ||
ace21957 MF |
437 | set test "complete help aliases" |
438 | send_gdb "help user-define\t" | |
439 | gdb_test_multiple "" "$test" { | |
440 | -re "^help user-defined $" { | |
441 | send_gdb "\n" | |
442 | gdb_test_multiple "" "$test" { | |
443 | -re "$gdb_prompt $" { | |
444 | pass "$test" | |
445 | } | |
446 | } | |
447 | } | |
448 | } | |
449 | ||
c906108c | 450 | |
6970b5b1 JB |
451 | # These tests used to try completing the shorter "p b-a". |
452 | # Unfortunately, on some systems, there are .o files in system | |
453 | # libraries which declare static variables named `b'. Of course, | |
454 | # those variables aren't really in scope, as far as the compiler is | |
455 | # concerned. But GDB deliberately tries to be more liberal: if you | |
456 | # enter an identifier that doesn't have any binding in scope, GDB will | |
457 | # search all the program's compilation units for a static variable of | |
458 | # the given name. | |
459 | # | |
460 | # This behavior can help avoid a lot of pedantry, so it's usually a | |
461 | # good thing. But in this test case, it causes GDB to print the value | |
462 | # of some random variable, instead of giving us the "No symbol..." | |
463 | # error we were expecting. | |
464 | # | |
465 | # For example, on S/390 linux, the file s_atan.c in libm.a declares a | |
466 | # `b', which is a structure containing an int and a float, so GDB says | |
467 | # ``Argument to arithmetic operation not a number or boolean'' instead | |
468 | # of ``No symbol ...''. | |
469 | # | |
470 | # So, I'm hoping that there is no system with a static library variable named | |
471 | # `no_var_by_this_name'. | |
8e28d804 PA |
472 | |
473 | set test "complete 'p no_var_named_this-arg'" | |
5ac01682 | 474 | send_gdb "p no_var_named_this-arg\t" |
8e28d804 | 475 | gdb_test_multiple "" "$test" { |
5ac01682 | 476 | -re "^p no_var_named_this-arg\\\x07$" { |
2d842f13 | 477 | send_gdb "\n" |
8e28d804 | 478 | gdb_test_multiple "" "$test" { |
6970b5b1 | 479 | -re "No symbol \"no_var_named_this\" in current context\\..*$gdb_prompt $" { |
8e28d804 | 480 | pass "$test" |
c906108c | 481 | } |
c906108c | 482 | } |
2d842f13 | 483 | } |
2d842f13 | 484 | } |
c906108c | 485 | |
8e28d804 | 486 | set test "complete (2) 'p no_var_named_this-arg'" |
5ac01682 | 487 | send_gdb "p no_var_named_this-arg\t" |
8e28d804 | 488 | gdb_test_multiple "" "$test" { |
5ac01682 | 489 | -re "^p no_var_named_this-arg\\\x07$" { |
085dd6e6 | 490 | send_gdb "\t" |
8e28d804 | 491 | gdb_test_multiple "" "$test" { |
8ffd0459 | 492 | -re "argv.*$gdb_prompt " { |
085dd6e6 | 493 | send_gdb "\n" |
8e28d804 | 494 | gdb_test_multiple "" "$test" { |
6970b5b1 | 495 | -re "No symbol \"no_var_named_this\" in current context\\..*$gdb_prompt $" { |
8e28d804 | 496 | pass "$test" |
085dd6e6 | 497 | } |
085dd6e6 JM |
498 | } |
499 | } | |
500 | -re "(There are $decimal possibilities\\. Do you really\r\nwish to see them all.|Display all $decimal possibilities.) \\(y or n\\)$" { | |
c4cbc0df PA |
501 | send_gdb "n\n" |
502 | ||
503 | # Eat the prompt | |
085dd6e6 | 504 | gdb_expect { |
c4cbc0df | 505 | -re "$gdb_prompt " { |
8e28d804 PA |
506 | pass "$test (eat prompt)" |
507 | } | |
508 | timeout { | |
509 | fail "(timeout) $test (eat prompt)" | |
c4cbc0df | 510 | } |
c4cbc0df PA |
511 | } |
512 | ||
8e28d804 | 513 | gdb_test_multiple "" "$test" { |
c4cbc0df | 514 | -re "No symbol \"no_var_named_this\" in current context\\..*$gdb_prompt $" { |
8e28d804 | 515 | pass "$test" |
c4cbc0df | 516 | } |
085dd6e6 JM |
517 | } |
518 | } | |
c906108c | 519 | } |
085dd6e6 | 520 | } |
085dd6e6 | 521 | } |
c906108c | 522 | |
8e28d804 | 523 | set test "complete (2) 'p no_var_named_this-'" |
6970b5b1 | 524 | send_gdb "p no_var_named_this-\t" |
8e28d804 | 525 | gdb_test_multiple "" "$test" { |
6970b5b1 | 526 | -re "^p no_var_named_this-\\\x07$" { |
085dd6e6 | 527 | send_gdb "\t" |
8e28d804 | 528 | gdb_test_multiple "" "$test" { |
085dd6e6 | 529 | -re "(There are $decimal possibilities\\. Do you really\r\nwish to see them all.|Display all $decimal possibilities.) \\(y or n\\)$" { |
c4cbc0df PA |
530 | send_gdb "n\n" |
531 | ||
532 | # Eat the prompt | |
085dd6e6 | 533 | gdb_expect { |
c4cbc0df | 534 | -re "$gdb_prompt " { |
8e28d804 PA |
535 | pass "$test (eat prompt)" |
536 | } | |
537 | timeout { | |
538 | fail "(timeout) $test (eat prompt)" | |
c4cbc0df | 539 | } |
c4cbc0df PA |
540 | } |
541 | ||
8e28d804 | 542 | gdb_test_multiple "" "$test" { |
c4cbc0df | 543 | -re "No symbol \"no_var_named_this\" in current context\\..*$gdb_prompt $" { |
8e28d804 | 544 | pass "$test" |
c4cbc0df | 545 | } |
085dd6e6 JM |
546 | } |
547 | } | |
8ffd0459 | 548 | -re "argv.*$gdb_prompt $" { |
5ac01682 | 549 | send_gdb "\n" |
8e28d804 | 550 | gdb_test_multiple "" "$test" { |
5ac01682 | 551 | -re "No symbol \"no_var_named_this\" in current context\\..*$gdb_prompt $" { |
8e28d804 | 552 | pass "$test" |
5ac01682 DJ |
553 | } |
554 | } | |
555 | } | |
085dd6e6 JM |
556 | } |
557 | } | |
085dd6e6 | 558 | } |
c906108c | 559 | |
8e28d804 | 560 | set test "complete 'p values\[0\].a'" |
65d12d83 | 561 | send_gdb "p values\[0\].a\t" |
8e28d804 PA |
562 | gdb_test_multiple "" "$test" { |
563 | -re "^p values.0..a_field $" { | |
564 | send_gdb "\n" | |
565 | gdb_test_multiple "" "$test" { | |
8ffd0459 | 566 | -re " = 0.*$gdb_prompt $" { |
8e28d804 PA |
567 | pass "$test" |
568 | } | |
569 | } | |
570 | } | |
571 | } | |
0eba65ab | 572 | |
8e28d804 | 573 | set test "complete 'p values\[0\] . a'" |
37cd5d19 | 574 | send_gdb "p values\[0\] . a\t" |
8e28d804 PA |
575 | gdb_test_multiple "" "$test" { |
576 | -re "^p values.0. . a_field $" { | |
577 | send_gdb "\n" | |
578 | gdb_test_multiple "" "$test" { | |
8ffd0459 | 579 | -re " = 0.*$gdb_prompt $" { |
8e28d804 PA |
580 | pass "$test" |
581 | } | |
582 | } | |
583 | } | |
584 | } | |
37cd5d19 | 585 | |
8e28d804 | 586 | set test "complete 'p &values\[0\] -> a'" |
37cd5d19 | 587 | send_gdb "p &values\[0\] -> a\t" |
8e28d804 PA |
588 | gdb_test_multiple "" "$test" { |
589 | -re "^p &values.0. -> a_field $" { | |
590 | send_gdb "\n" | |
591 | gdb_test_multiple "" "$test" { | |
8ffd0459 | 592 | -re " = .*0x\[0-9a-fA-F\]*.*$gdb_prompt $" { |
8e28d804 PA |
593 | pass "$test" |
594 | } | |
595 | } | |
596 | } | |
597 | } | |
37cd5d19 | 598 | |
9ae8282d TT |
599 | gdb_test "complete p &values\[0\]->z" \ |
600 | "p &values.0.->z_field" \ | |
8e28d804 | 601 | "completion of field in anonymous union" |
9ae8282d | 602 | |
4fc5d43e TT |
603 | gdb_test "complete ptype &values\[0\]->z" \ |
604 | "ptype &values.0.->z_field" \ | |
605 | "ptype completion of field in anonymous union" | |
606 | ||
607 | gdb_test "complete whatis &values\[0\]->z" \ | |
608 | "whatis &values.0.->z_field" \ | |
609 | "whatis completion of field in anonymous union" | |
610 | ||
1a371f2e | 611 | # The following tests used to simply try to complete `${objdir}/file', |
0eba65ab JB |
612 | # and so on. The problem is that ${objdir} can be very long; the |
613 | # completed filename may be more than eighty characters wide. When | |
614 | # this happens, readline tries to manage things, producing output that | |
615 | # may make sense on the screen, but is rather hard for our script to | |
616 | # recognize. | |
617 | # | |
618 | # In the case that motivated this change, the (gdb) prompt occupied | |
1a371f2e | 619 | # the leftmost six columns, and `${objdir}/' was seventy-four |
0eba65ab JB |
620 | # characters long --- eighty in all. After printing the slash, |
621 | # readline emitted a space, a carriage return, and then `Makefile' | |
622 | # (the tab character being received as input after `Make'. | |
623 | # | |
624 | # Basically, you have to let readline do whatever it's going to do to | |
625 | # make the screen look right. If it happens to use a different | |
626 | # strategy on Tuesdays to get the cursor in the right place, that's | |
627 | # not something the testsuite should care about. | |
628 | # | |
629 | # So, we avoid long lines. We `cd' to ${objdir} first, and then do | |
630 | # the completion relative to the current directory. | |
c906108c | 631 | |
37ab3bf8 DJ |
632 | # ${srcdir} may be a relative path. We want to make sure we end up |
633 | # in the right directory - so make sure we know where it is. | |
634 | set mydir [pwd] | |
635 | cd ${srcdir} | |
636 | set fullsrcdir [pwd] | |
637 | cd ${mydir} | |
638 | ||
68ab8fc5 EZ |
639 | # If the directory name contains a '+' we must escape it, adding a backslash. |
640 | # If not, the test below will fail because it will interpret the '+' as a | |
641 | # regexp operator. We use string_to_regexp for this purpose. | |
642 | ||
643 | gdb_test "cd ${fullsrcdir}" \ | |
644 | "Working directory [string_to_regexp ${fullsrcdir}].*" \ | |
645 | "cd to \${srcdir}" | |
646 | ||
cc1d7add | 647 | |
40974f91 | 648 | # GDB used to fail adding / on directories, on the first try only. |
fdc498b8 | 649 | set uniquedir ../testsuite/gdb.base/comp-dir |
40974f91 JK |
650 | set escapeduniquedir [string_to_regexp ${uniquedir}] |
651 | set uniquesu subdi | |
652 | set uniquesub ${uniquesu}r | |
653 | set escapeuniquesub [string_to_regexp ${uniquesub}] | |
40974f91 | 654 | send_gdb "dir ${uniquedir}\t" |
cc1d7add | 655 | gdb_expect { |
40974f91 | 656 | -re "${escapeduniquedir}/" { |
cc1d7add | 657 | pass "directory completion" |
40974f91 | 658 | send_gdb "${uniquesu}\t" |
cc1d7add | 659 | } |
40974f91 | 660 | -re "${escapeduniquedir} $" { |
cc1d7add | 661 | fail "directory completion (old gdb bug)" |
40974f91 | 662 | send_gdb "\b/${uniquesu}\t" |
cc1d7add PM |
663 | } |
664 | default { | |
665 | fail "directory completion (timeout)" | |
40974f91 | 666 | send_gdb "\ndir ${uniquedir}/${uniquesu}\t" |
cc1d7add PM |
667 | } |
668 | } | |
669 | ||
670 | gdb_expect { | |
40974f91 | 671 | -re "${escapeuniquesub}/$" { |
cc1d7add PM |
672 | pass "directory completion 2" |
673 | } | |
674 | timeout { | |
675 | fail "directory completion 2" | |
676 | } | |
677 | } | |
678 | ||
40974f91 JK |
679 | # Empty COMMAND sends no newline while " " sends the newline we need. |
680 | gdb_test " " "Source directories searched: .*" "Glob remaining of directory test" | |
cc1d7add | 681 | |
8e28d804 PA |
682 | gdb_test "complete file ./gdb.base/compl" \ |
683 | "file ./gdb.base/completion\\.exp.*" \ | |
684 | "complete-command 'file ./gdb.base/compl'" | |
cc1d7add | 685 | |
8e28d804 | 686 | set test "complete 'file ./gdb.base/complet'" |
f1c2644b | 687 | send_gdb "file ./gdb.base/complet\t" |
8e28d804 PA |
688 | gdb_test_multiple "" "$test" { |
689 | -re "^file ./gdb.base/completion\\.exp $" { | |
690 | send_gdb "\n" | |
691 | # Ignore the exact error message. | |
692 | gdb_test_multiple "" "complete 'file ./gdb.base/complet'" { | |
693 | -re "\r\nA program is being debugged already\\.\[\r\n\]+Are you sure you want to change the file\\? \\(y or n\\) $" { | |
694 | send_gdb "n\n" | |
695 | exp_continue | |
696 | } | |
8ffd0459 | 697 | -re "$gdb_prompt $" { |
8e28d804 PA |
698 | pass "$test" |
699 | } | |
700 | } | |
701 | } | |
702 | } | |
c906108c | 703 | |
8e28d804 | 704 | set test "complete 'info func marke'" |
3fe60e3c | 705 | send_gdb "info func marke\t" |
8e28d804 PA |
706 | gdb_test_multiple "" "$test" { |
707 | -re "^info func marke.*r$" { | |
708 | send_gdb "\t\t" | |
709 | gdb_test_multiple "" "$test" { | |
710 | -re "marker1.*$gdb_prompt " { | |
711 | send_gdb "\n" | |
712 | gdb_test_multiple "" "$test" { | |
713 | -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 $" { | |
714 | pass "$test" | |
715 | } | |
716 | } | |
717 | } | |
718 | } | |
719 | } | |
720 | } | |
c906108c SS |
721 | |
722 | ||
8e28d804 | 723 | set test "complete 'set follow-fork-mode'" |
c906108c | 724 | send_gdb "set follow-fork-mode \t\t" |
8e28d804 PA |
725 | gdb_test_multiple "" "$test" { |
726 | -re "child.*parent.*$gdb_prompt " { | |
727 | send_gdb "\n" | |
728 | gdb_test_multiple "" "$test" { | |
729 | -re "Requires an argument.*child.*parent.*$gdb_prompt $" { | |
730 | pass "$test" | |
731 | } | |
732 | -re "Ambiguous item \"\"\\..*$gdb_prompt $" { | |
733 | pass "$test" | |
734 | } | |
735 | } | |
736 | } | |
737 | } | |
c906108c | 738 | |
5ea2a32c | 739 | # Restore globals modified in this test... |
c906108c | 740 | set timeout $oldtimeout1 |
c906108c | 741 | |
5ea2a32c | 742 | return 0 |