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