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