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