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