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