Commit | Line | Data |
---|---|---|
2970ae72 | 1 | # Copyright 1998, 1999, 2002, 2003, 2004 Free Software Foundation, Inc. |
c906108c SS |
2 | |
3 | # This program is free software; you can redistribute it and/or modify | |
4 | # it under the terms of the GNU General Public License as published by | |
5 | # the Free Software Foundation; either version 2 of the License, or | |
6 | # (at your option) any later version. | |
7 | # | |
8 | # This program is distributed in the hope that it will be useful, | |
9 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
11 | # GNU General Public License for more details. | |
12 | # | |
13 | # You should have received a copy of the GNU General Public License | |
14 | # along with this program; if not, write to the Free Software | |
15 | # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | |
16 | ||
17 | # Please email any bugs, comments, and/or additions to this file to: | |
18 | # bug-gdb@prep.ai.mit.edu | |
19 | ||
20 | # This file was written by Elena Zannoni (ezannoni@cygnus.com) | |
21 | ||
22 | # This file is part of the gdb testsuite. | |
23 | ||
24 | # | |
25 | # tests for command completion | |
26 | # | |
27 | # Here are some useful test cases for completion. | |
28 | # They should be tested with both M-? and TAB. | |
29 | # | |
30 | # "show output-" "radix" | |
31 | # "show output" "-radix" | |
32 | # "p" ambiguous (commands starting with p--path, print, printf, etc.) | |
33 | # "p " ambiguous (all symbols) | |
34 | # "info t foo" no completions | |
35 | # "info t " no completions | |
36 | # "info t" ambiguous ("info target", "info terminal", etc.) | |
37 | # "info ajksdlfk" no completions | |
38 | # "info ajksdlfk " no completions | |
39 | # "info" " " | |
40 | # "info " ambiguous (all info commands) | |
a1dea79a FF |
41 | # "p \"break1" unambiguous (completes to filename "break1.c") |
42 | # "p \"break1." unambiguous (should complete to "break1.c" but does not, | |
9b284272 | 43 | # due to readline limitations) |
c906108c SS |
44 | # "p 'a" ambiguous (all symbols starting with a) |
45 | # "p b-a" ambiguous (all symbols starting with a) | |
46 | # "p b-" ambiguous (all symbols) | |
47 | # "file Make" "file" (word break hard to screw up here) | |
48 | # "file ../gdb.stabs/we" "ird" (needs to not break word at slash) | |
49 | # | |
50 | ||
51 | ||
52 | if $tracelevel then { | |
53 | strace $tracelevel | |
54 | } | |
55 | ||
56 | ||
c906108c SS |
57 | global usestubs |
58 | ||
59 | # | |
60 | # test running programs | |
61 | # | |
62 | set prms_id 0 | |
63 | set bug_id 0 | |
64 | ||
65 | set testfile "break" | |
66 | set srcfile ${testfile}.c | |
a1dea79a | 67 | set srcfile1 ${testfile}1.c |
c906108c | 68 | set binfile ${objdir}/${subdir}/${testfile} |
a1dea79a FF |
69 | |
70 | if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}0.o" object {debug additional_flags=-w}] != "" } { | |
71 | gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail." | |
72 | } | |
73 | ||
74 | if { [gdb_compile "${srcdir}/${subdir}/${srcfile1}" "${binfile}1.o" object {debug additional_flags=-w}] != "" } { | |
75 | gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail." | |
76 | } | |
77 | ||
78 | if { [gdb_compile "${binfile}0.o ${binfile}1.o" "${binfile}" executable {debug additional_flags=-w}] != "" } { | |
79 | gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail." | |
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 { | |
226 | -re "Ambiguous info command \"t foo\": target, terminal, threads, tp, tracepoints, types\\..*$gdb_prompt $"\ | |
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 { | |
242 | -re "Ambiguous info command \"t\": target, terminal, threads, tp, tracepoints, types\\.. | |
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 { | |
260 | -re "Ambiguous info command \"t \": target, terminal, threads, tp, tracepoints, types\\.. | |
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 { | |
085dd6e6 | 313 | -re "\"info\" must be followed by the name of an info command\\.\r\nList of info subcommands:\r\n\r\n.*info address.*info watchpoints.*\r\n\r\nType \"help info\" followed by info subcommand name for full documentation.\r\nCommand name abbreviations are allowed if unambiguous\\..*$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 { | |
085dd6e6 | 329 | -re "\"info\" must be followed by the name of an info command\\.\r\nList of info subcommands:\r\n\r\n.*info address.*Type \"help info\" followed by info subcommand name for full documentation.\r\nCommand name abbreviations are allowed if unambiguous\\..*$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 | ||
a1dea79a | 364 | send_gdb "p \"break1\t" |
c906108c SS |
365 | sleep 1 |
366 | gdb_expect { | |
a1dea79a | 367 | -re "^p \"break1\\\x07$"\ |
c906108c SS |
368 | { send_gdb "\n" |
369 | gdb_expect { | |
a1dea79a FF |
370 | -re ".*$gdb_prompt $" { fail "complete 'p \"break1'"} |
371 | timeout {fail "(timeout) complete 'p \"break1'"} | |
c906108c SS |
372 | } |
373 | } | |
a1dea79a | 374 | -re "^p \"break1\\.c\"$"\ |
9b284272 DJ |
375 | { send_gdb "\n" |
376 | gdb_expect { | |
a1dea79a FF |
377 | -re ".*$gdb_prompt $" { pass "complete 'p \"break1'"} |
378 | timeout {fail "(timeout) complete 'p \"break1'"} | |
9b284272 DJ |
379 | } |
380 | } | |
a1dea79a | 381 | -re "^p \"break1.*$" |
9b284272 DJ |
382 | { send_gdb "\n" |
383 | gdb_expect { | |
a1dea79a FF |
384 | -re ".*$gdb_prompt $" { fail "complete 'p \"break1'"} |
385 | timeout {fail "(timeout) complete 'p \"break1'"} | |
9b284272 DJ |
386 | } |
387 | } | |
a1dea79a FF |
388 | -re ".*$gdb_prompt $" { fail "complete 'p \"break1'" } |
389 | timeout { fail "(timeout) complete 'p \"break1'" } | |
9b284272 DJ |
390 | } |
391 | ||
392 | setup_xfail "*-*-*" | |
a1dea79a | 393 | send_gdb "p \"break1.\t" |
9b284272 DJ |
394 | sleep 1 |
395 | gdb_expect { | |
a1dea79a | 396 | -re "^p \"break1\\.\\\x07$"\ |
9b284272 DJ |
397 | { send_gdb "\n" |
398 | gdb_expect { | |
a1dea79a FF |
399 | -re ".*$gdb_prompt $" { fail "complete 'p \"break1.'"} |
400 | timeout {fail "(timeout) complete 'p \"break1.'"} | |
9b284272 DJ |
401 | } |
402 | } | |
a1dea79a | 403 | -re "^p \"break1\\.c\"$"\ |
9b284272 DJ |
404 | { send_gdb "\n" |
405 | gdb_expect { | |
a1dea79a FF |
406 | -re ".*$gdb_prompt $" { pass "complete 'p \"break1.'"} |
407 | timeout {fail "(timeout) complete 'p \"break1.'"} | |
9b284272 DJ |
408 | } |
409 | } | |
a1dea79a | 410 | -re "^p \"break1\\..*$" |
9b284272 DJ |
411 | { send_gdb "\n" |
412 | gdb_expect { | |
a1dea79a FF |
413 | -re ".*$gdb_prompt $" { fail "complete 'p \"break1.'"} |
414 | timeout {fail "(timeout) complete 'p \"break1.'"} | |
9b284272 DJ |
415 | } |
416 | } | |
a1dea79a FF |
417 | -re ".*$gdb_prompt $" { fail "complete 'p \"break1.'" } |
418 | timeout { fail "(timeout) complete 'p \"break1.'" } | |
c906108c SS |
419 | } |
420 | ||
421 | send_gdb "p 'a\t" | |
422 | sleep 1 | |
423 | gdb_expect { | |
424 | -re "^p 'a\\\x07$"\ | |
425 | { send_gdb "\n" | |
426 | gdb_expect { | |
f617d2b6 | 427 | -re "(Invalid character constant\\.|Unmatched single quote\\.).*$gdb_prompt $"\ |
c906108c SS |
428 | { pass "complete 'p \'a'"} |
429 | -re ".*$gdb_prompt $" { fail "complete 'p \'a'"} | |
430 | timeout {fail "(timeout) complete 'p \'a'"} | |
431 | } | |
432 | } | |
433 | -re ".*$gdb_prompt $" { fail "complete 'p \'a'" } | |
434 | timeout { fail "(timeout) complete 'p \'a'" } | |
435 | } | |
436 | ||
437 | send_gdb "p 'a\t" | |
438 | sleep 1 | |
085dd6e6 JM |
439 | gdb_expect { |
440 | -re "^p 'a\\\x07$" { | |
441 | send_gdb "\t" | |
442 | gdb_expect { | |
0521c418 | 443 | -re ".*argv.*$gdb_prompt p .a$" { |
085dd6e6 JM |
444 | send_gdb "\n" |
445 | gdb_expect { | |
f617d2b6 | 446 | -re "(Invalid character constant\\.|Unmatched single quote\\.).*$gdb_prompt $" { |
085dd6e6 JM |
447 | pass "complete (2) 'p \'a'" |
448 | } | |
449 | -re ".*$gdb_prompt $" { fail "complete (2) 'p \'a'" } | |
450 | timeout { fail "(timeout) complete (2) 'p \'a'" } | |
451 | } | |
452 | } | |
453 | -re "(There are $decimal possibilities\\. Do you really\r\nwish to see them all.|Display all $decimal possibilities.) \\(y or n\\)$" { | |
454 | send_gdb "n" | |
455 | gdb_expect { | |
456 | -re "\\(gdb\\) p 'a$" { | |
457 | send_gdb "\n" | |
458 | gdb_expect { | |
f617d2b6 | 459 | -re "(Invalid character constant\\.|Unmatched single quote\\.).*$gdb_prompt $" { |
085dd6e6 JM |
460 | pass "complete (2) 'p \'a'" |
461 | } | |
462 | -re ".*$gdb_prompt $" { | |
463 | fail "complete (2) 'p \'a'" | |
464 | } | |
465 | timeout { fail "(timeout) complete (2) 'p \'a'" } | |
466 | } | |
467 | } | |
468 | -re ".*$gdb_prompt $" { fail "complete (2) 'p \'a'" } | |
469 | timeout { fail "(timeout) complete (2) 'p \'a'" } | |
470 | } | |
471 | } | |
472 | -re ".*$gdb_prompt $" { fail "complete (2) 'p \'a'" } | |
473 | timeout { fail "(timeout) complete (2) 'p \'a'" } | |
474 | } | |
475 | } | |
476 | -re ".*$gdb_prompt $" { fail "complete (2) 'p \'a'" } | |
477 | timeout { fail "(timeout) complete (2) 'p \'a'" } | |
478 | } | |
c906108c SS |
479 | |
480 | ||
6970b5b1 JB |
481 | # These tests used to try completing the shorter "p b-a". |
482 | # Unfortunately, on some systems, there are .o files in system | |
483 | # libraries which declare static variables named `b'. Of course, | |
484 | # those variables aren't really in scope, as far as the compiler is | |
485 | # concerned. But GDB deliberately tries to be more liberal: if you | |
486 | # enter an identifier that doesn't have any binding in scope, GDB will | |
487 | # search all the program's compilation units for a static variable of | |
488 | # the given name. | |
489 | # | |
490 | # This behavior can help avoid a lot of pedantry, so it's usually a | |
491 | # good thing. But in this test case, it causes GDB to print the value | |
492 | # of some random variable, instead of giving us the "No symbol..." | |
493 | # error we were expecting. | |
494 | # | |
495 | # For example, on S/390 linux, the file s_atan.c in libm.a declares a | |
496 | # `b', which is a structure containing an int and a float, so GDB says | |
497 | # ``Argument to arithmetic operation not a number or boolean'' instead | |
498 | # of ``No symbol ...''. | |
499 | # | |
500 | # So, I'm hoping that there is no system with a static library variable named | |
501 | # `no_var_by_this_name'. | |
502 | send_gdb "p no_var_named_this-a\t" | |
c906108c | 503 | sleep 1 |
2d842f13 | 504 | gdb_expect { |
6970b5b1 | 505 | -re "^p no_var_named_this-a\\\x07$" { |
2d842f13 JB |
506 | send_gdb "\n" |
507 | gdb_expect { | |
6970b5b1 JB |
508 | -re "No symbol \"no_var_named_this\" in current context\\..*$gdb_prompt $" { |
509 | pass "complete 'p no_var_named_this-a'" | |
2d842f13 JB |
510 | } |
511 | -re ".*$gdb_prompt $" { | |
6970b5b1 | 512 | fail "complete 'p no_var_named_this-a'" |
2d842f13 JB |
513 | } |
514 | timeout { | |
6970b5b1 | 515 | fail "(timeout) complete 'p no_var_named_this-a'" |
c906108c | 516 | } |
c906108c | 517 | } |
2d842f13 JB |
518 | } |
519 | -re ".*$gdb_prompt $" { | |
6970b5b1 | 520 | fail "complete 'p no_var_named_this-a'" |
2d842f13 JB |
521 | } |
522 | timeout { | |
6970b5b1 | 523 | fail "(timeout) complete 'p no_var_named_this-a'" |
2d842f13 JB |
524 | } |
525 | } | |
c906108c | 526 | |
6970b5b1 | 527 | send_gdb "p no_var_named_this-a\t" |
c906108c | 528 | sleep 1 |
085dd6e6 | 529 | gdb_expect { |
6970b5b1 | 530 | -re "^p no_var_named_this-a\\\x07$" { |
085dd6e6 JM |
531 | send_gdb "\t" |
532 | gdb_expect { | |
6970b5b1 | 533 | -re ".*argv.*$gdb_prompt p no_var_named_this-a$" { |
085dd6e6 JM |
534 | send_gdb "\n" |
535 | gdb_expect { | |
6970b5b1 JB |
536 | -re "No symbol \"no_var_named_this\" in current context\\..*$gdb_prompt $" { |
537 | pass "complete (2) 'p no_var_named_this-a'" | |
085dd6e6 | 538 | } |
6970b5b1 JB |
539 | -re ".*$gdb_prompt $" { |
540 | fail "complete (2) 'p no_var_named_this-a'" | |
541 | } | |
542 | timeout { | |
543 | fail "(timeout) complete (2) 'p no_var_named_this-a'" | |
544 | } | |
085dd6e6 JM |
545 | } |
546 | } | |
547 | -re "(There are $decimal possibilities\\. Do you really\r\nwish to see them all.|Display all $decimal possibilities.) \\(y or n\\)$" { | |
548 | send_gdb "n" | |
549 | gdb_expect { | |
6970b5b1 | 550 | -re "\\(gdb\\) p no_var_named_this-a$" { |
085dd6e6 JM |
551 | send_gdb "\n" |
552 | gdb_expect { | |
6970b5b1 JB |
553 | -re "No symbol \"no_var_named_this\" in current context\\..*$gdb_prompt $" { |
554 | pass "complete (2) 'p no_var_named_this-a'" | |
085dd6e6 JM |
555 | } |
556 | -re ".*$gdb_prompt $" { | |
6970b5b1 | 557 | fail "complete (2) 'p no_var_named_this-a'" |
085dd6e6 | 558 | } |
6970b5b1 JB |
559 | timeout { |
560 | fail "(timeout) complete (2) 'p no_var_named_this-a'" | |
561 | } | |
085dd6e6 JM |
562 | } |
563 | } | |
6970b5b1 JB |
564 | -re ".*$gdb_prompt $" { |
565 | fail "complete (2) 'p no_var_named_this-a'" | |
566 | } | |
567 | timeout { | |
568 | fail "(timeout) complete (2) 'p no_var_named_this-a'" | |
569 | } | |
085dd6e6 JM |
570 | } |
571 | } | |
6970b5b1 JB |
572 | -re ".*$gdb_prompt $" { |
573 | fail "complete (2) 'p no_var_named_this-a'" | |
574 | } | |
575 | timeout { fail "(timeout) complete (2) 'p no_var_named_this-a'" } | |
c906108c | 576 | } |
085dd6e6 | 577 | } |
6970b5b1 JB |
578 | -re ".*$gdb_prompt $" { fail "complete (2) 'p no_var_named_this-a'" } |
579 | timeout { fail "(timeout) complete (2) 'p no_var_named_this-a'" } | |
085dd6e6 | 580 | } |
c906108c | 581 | |
6970b5b1 | 582 | send_gdb "p no_var_named_this-\t" |
c906108c SS |
583 | sleep 1 |
584 | gdb_expect { | |
6970b5b1 | 585 | -re "^p no_var_named_this-\\\x07$" { |
085dd6e6 JM |
586 | send_gdb "\t" |
587 | gdb_expect { | |
588 | -re "(There are $decimal possibilities\\. Do you really\r\nwish to see them all.|Display all $decimal possibilities.) \\(y or n\\)$" { | |
589 | send_gdb "n" | |
590 | gdb_expect { | |
6970b5b1 | 591 | -re "\\(gdb\\) p no_var_named_this-$" { |
085dd6e6 JM |
592 | send_gdb "\n" |
593 | gdb_expect { | |
6970b5b1 JB |
594 | -re "No symbol \"no_var_named_this\" in current context\\..*$gdb_prompt $" { |
595 | pass "complete (2) 'p no_var_named_this-'" | |
085dd6e6 JM |
596 | } |
597 | -re ".*$gdb_prompt $" { | |
6970b5b1 | 598 | fail "complete (2) 'p no_var_named_this-'" |
085dd6e6 | 599 | } |
6970b5b1 JB |
600 | timeout { |
601 | fail "(timeout) complete (2) 'p no_var_named_this-'" | |
602 | } | |
085dd6e6 JM |
603 | } |
604 | } | |
6970b5b1 JB |
605 | -re ".*$gdb_prompt $" { |
606 | fail "complete (2) 'p no_var_named_this-'" | |
607 | } | |
608 | timeout { | |
609 | fail "(timeout) complete (2) 'p no_var_named_this-'" | |
610 | } | |
085dd6e6 JM |
611 | } |
612 | } | |
6970b5b1 JB |
613 | -re ".*$gdb_prompt $" { |
614 | fail "complete (2) 'p no_var_named_this-'" | |
615 | } | |
616 | timeout { fail "(timeout) complete (2) 'p no_var_named_this-'" } | |
085dd6e6 JM |
617 | } |
618 | } | |
6970b5b1 JB |
619 | -re ".*$gdb_prompt $" { fail "complete (2) 'p no_var_named_this-'" } |
620 | timeout { fail "(timeout) complete (2) 'p no_var_named_this-'" } | |
085dd6e6 | 621 | } |
c906108c | 622 | |
0eba65ab | 623 | |
1a371f2e | 624 | # The following tests used to simply try to complete `${objdir}/file', |
0eba65ab JB |
625 | # and so on. The problem is that ${objdir} can be very long; the |
626 | # completed filename may be more than eighty characters wide. When | |
627 | # this happens, readline tries to manage things, producing output that | |
628 | # may make sense on the screen, but is rather hard for our script to | |
629 | # recognize. | |
630 | # | |
631 | # In the case that motivated this change, the (gdb) prompt occupied | |
1a371f2e | 632 | # the leftmost six columns, and `${objdir}/' was seventy-four |
0eba65ab JB |
633 | # characters long --- eighty in all. After printing the slash, |
634 | # readline emitted a space, a carriage return, and then `Makefile' | |
635 | # (the tab character being received as input after `Make'. | |
636 | # | |
637 | # Basically, you have to let readline do whatever it's going to do to | |
638 | # make the screen look right. If it happens to use a different | |
639 | # strategy on Tuesdays to get the cursor in the right place, that's | |
640 | # not something the testsuite should care about. | |
641 | # | |
642 | # So, we avoid long lines. We `cd' to ${objdir} first, and then do | |
643 | # the completion relative to the current directory. | |
c906108c | 644 | |
37ab3bf8 DJ |
645 | # ${srcdir} may be a relative path. We want to make sure we end up |
646 | # in the right directory - so make sure we know where it is. | |
647 | set mydir [pwd] | |
648 | cd ${srcdir} | |
649 | set fullsrcdir [pwd] | |
650 | cd ${mydir} | |
651 | ||
68ab8fc5 EZ |
652 | # If the directory name contains a '+' we must escape it, adding a backslash. |
653 | # If not, the test below will fail because it will interpret the '+' as a | |
654 | # regexp operator. We use string_to_regexp for this purpose. | |
655 | ||
656 | gdb_test "cd ${fullsrcdir}" \ | |
657 | "Working directory [string_to_regexp ${fullsrcdir}].*" \ | |
658 | "cd to \${srcdir}" | |
659 | ||
f1c2644b | 660 | send_gdb "file ./gdb.base/complet\t" |
c906108c SS |
661 | sleep 1 |
662 | gdb_expect { | |
0eba65ab | 663 | -re "^file ./gdb.base/completion\\.exp $"\ |
c906108c SS |
664 | { send_gdb "\n" |
665 | gdb_expect { | |
666 | -re "\r\nA program is being debugged already\\. Kill it\\? \\(y or n\\) $" | |
667 | \ | |
668 | { send_gdb "n\n" | |
669 | gdb_expect { | |
670 | -re "\r\nProgram not killed\\.\r\n$gdb_prompt $"\ | |
f1c2644b DJ |
671 | { pass "complete 'file ./gdb.base/complet'"} |
672 | -re ".*$gdb_prompt $" { fail "complete 'file ./gdb.base/complet'"} | |
673 | timeout {fail "(timeout) complete 'file ./gdb.base/complet'"} | |
c906108c SS |
674 | } |
675 | } | |
f1c2644b DJ |
676 | -re ".*$gdb_prompt $" { fail "complete 'file ./gdb.base/complet'"} |
677 | timeout {fail "(timeout) complete 'file ./gdb.base/complet'"} | |
c906108c SS |
678 | } |
679 | } | |
f1c2644b DJ |
680 | -re ".*$gdb_prompt $" { fail "complete 'file ./gdb.base/complet'" } |
681 | timeout { fail "(timeout) complete 'file ./gdb.base/complet'" } | |
c906108c SS |
682 | } |
683 | ||
3fe60e3c | 684 | send_gdb "info func marke\t" |
c906108c SS |
685 | sleep 1 |
686 | gdb_expect { | |
3fe60e3c | 687 | -re "^info func marke.*r$"\ |
085dd6e6 JM |
688 | { |
689 | send_gdb "\t\t" | |
c906108c SS |
690 | sleep 3 |
691 | gdb_expect { | |
085dd6e6 | 692 | -re "marker1.*$gdb_prompt info func marker$"\ |
c906108c SS |
693 | { send_gdb "\n" |
694 | gdb_expect { | |
a1dea79a | 695 | -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 |
696 | { pass "complete 'info func marke'"} |
697 | -re ".*$gdb_prompt $" { fail "complete 'info func marke'"} | |
698 | timeout {fail "(timeout) complete 'info func marke'"} | |
c906108c SS |
699 | } |
700 | } | |
3fe60e3c EZ |
701 | -re ".*$gdb_prompt $" { fail "complete 'info func marke'"} |
702 | timeout {fail "(timeout) complete 'info func marke'"} | |
c906108c SS |
703 | } |
704 | } | |
3fe60e3c EZ |
705 | -re ".*$gdb_prompt $" { fail "complete 'info func marke'" } |
706 | timeout { fail "(timeout) complete 'info func marke'" } | |
c906108c SS |
707 | } |
708 | ||
709 | ||
710 | send_gdb "set follow-fork-mode \t\t" | |
711 | sleep 1 | |
712 | gdb_expect { | |
2970ae72 | 713 | -re "child.*parent.*$gdb_prompt set follow-fork-mode $"\ |
c906108c SS |
714 | { send_gdb "\n" |
715 | gdb_expect { | |
2970ae72 | 716 | -re "Requires an argument.*child.*parent.*$gdb_prompt $"\ |
085dd6e6 | 717 | { pass "complete 'set follow-fork-mode'"} |
c906108c SS |
718 | -re "Ambiguous item \"\"\\..*$gdb_prompt $"\ |
719 | { pass "complete 'set follow-fork-mode'"} | |
720 | -re ".*$gdb_prompt $" { fail "complete 'set follow-fork-mode'"} | |
721 | timeout {fail "(timeout) complete 'set follow-fork-mode'"} | |
722 | } | |
723 | } | |
724 | -re ".*$gdb_prompt $" { fail "complete 'set follow-fork-mode'" } | |
725 | timeout { fail "(timeout) complete 'set follow-fork-mode'" } | |
726 | } | |
727 | ||
5ea2a32c KB |
728 | # Restore globals modified in this test... |
729 | if [info exists old_inputrc] { | |
730 | set env(INPUTRC) $old_inputrc | |
731 | } else { | |
732 | unset env(INPUTRC) | |
733 | } | |
c906108c | 734 | set timeout $oldtimeout1 |
c906108c | 735 | |
5ea2a32c | 736 | return 0 |