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