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