]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - gdb/testsuite/gdb.base/list.exp
import gdb-1999-09-08 snapshot
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.base / list.exp
CommitLineData
c906108c
SS
1# Copyright (C) 1992, 1994, 1995, 1997, 1998 Free Software Foundation, Inc.
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 Fred Fish. (fnf@cygnus.com)
21
22if $tracelevel then {
23 strace $tracelevel
24}
25
26set prms_id 0
27set bug_id 0
28
29set testfile "list"
30set binfile ${objdir}/${subdir}/${testfile}
31
32# Need to download the header to the host.
33remote_download host ${srcdir}/${subdir}/list0.h list0.h
34
35
36if { [gdb_compile "${srcdir}/${subdir}/list0.c" "${binfile}0.o" object {debug}] != "" } {
37 gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail."
38}
39
40if { [gdb_compile "${srcdir}/${subdir}/list1.c" "${binfile}1.o" object {debug}] != "" } {
41 gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail."
42}
43
44if { [gdb_compile "${binfile}0.o ${binfile}1.o" ${binfile} executable {debug}] != "" } {
45 gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail."
46}
47
48
49
50# Create and source the file that provides information about the compiler
51# used to compile the test case.
52if [get_compiler_info ${binfile}] {
53 return -1;
54}
55
56#
57# Local utility proc just to set and verify listsize
58# Return 1 if success, 0 if fail.
59#
60
61set set_listsize_count 0;
62
63proc set_listsize { arg } {
64 global gdb_prompt
65 global set_listsize_count;
66
67 incr set_listsize_count;
68 if [gdb_test "set listsize $arg" "" "setting listsize to $arg #$set_listsize_count"] {
69 return 0;
70 }
71 if { $arg <= 0 } {
72 set arg "unlimited";
73 }
74
75 if [gdb_test "show listsize" "Number of source lines.* is ${arg}.*" "show listsize $arg #$set_listsize_count"] {
76 return 0;
77 }
78 return 1
79}
80
81#
82# Test display of listsize lines around a given line number.
83#
84
85proc test_listsize {} {
86 global gdb_prompt
085dd6e6
JM
87 global hp_cc_compiler
88 global hp_aCC_compiler
c906108c
SS
89
90 # Show default size
91
92 gdb_test "show listsize" "Number of source lines gdb will list by default is 10.*" "show default list size"
93
94 # Show the default lines
95 # The second case is for optimized code, it is still correct.
96
97 if ![isnative] {
98 runto_main;
99 unsupported "list default lines around main";
100 } else {
101 gdb_test "list" "(1\[ \t\]+#include \"list0.h\".*10\[ \t\]+x = 0;|2.*11\[ \t\]+foo .x\[+)\]+;)" "list default lines around main"
102 }
103
104 # Ensure we can limit printouts to one line
105
085dd6e6 106 if [set_listsize 1] {
c906108c 107 gdb_test "list 1" "1\[ \t\]+#include \"list0.h\"" "list line 1 with listsize 1"
c906108c
SS
108 gdb_test "list 2" "2\[ \t\]+" "list line 2 with listsize 1"
109 }
110
111 # Try just two lines
112
113 if [ set_listsize 2 ] {
d4f3574e 114 gdb_test "list 1" "1\[ \t\]+#include \"list0.h\"\r\n2\[ \t\]+" "list line 1 with listsize 2"
c906108c 115 gdb_test "list 2" "1\[ \t\]+#include \"list0.h\"\r\n2\[ \t\]+" "list line 2 with listsize 2"
085dd6e6 116 gdb_test "list 3" "2\[ \t\]+\r\n3\[ \t\]+int main \[)(\]+" "list line 3 with listsize 2"
c906108c
SS
117 }
118
119 # Try small listsize > 1 that is an odd number
120
121 if [ set_listsize 3 ] {
d4f3574e 122 gdb_test "list 1" "1\[ \t\]+#include \"list0.h\".*3\[ \t\]+int main \[)(\]+" "list line 1 with listsize 3"
085dd6e6 123 gdb_test "list 2" "1\[ \t\]+#include \"list0.h\".*3\[ \t\]+int main \[)(\]+" "list line 2 with listsize 3"
085dd6e6 124 gdb_test "list 3" "2\[ \t\]+\r\n3\[ \t\]+int main \[(\]+\[)\]+\r\n4\[ \t\]+\{" "list line 3 with listsize 3"
c906108c
SS
125 }
126
127 # Try small listsize > 2 that is an even number.
128
129 if [ set_listsize 4 ] then {
d4f3574e
SS
130 gdb_test "list 1" "1\[ \t\]+#include \"list0.h\".*4\[ \t\]+\{" "list line 1 with listsize 4"
131 gdb_test "list 2" "1\[ \t\]+#include \"list0.h\".*4\[ \t\]+\{" "list line 2 with listsize 4"
c906108c
SS
132
133 gdb_test "list 3" "1\[ \t\]+#include \"list0.h\".*4\[ \t\]+\{" "list line 3 with listsize 4"
134 gdb_test "list 4" "2\[ \t\]+\r\n.*5\[ \t\]+int x;.*" "list line 4 with listsize 4"
135 }
136
137 # Try a size larger than the entire file.
138
139 if [ set_listsize 100 ] then {
085dd6e6 140 gdb_test "list 1" "1\[ \t\]+#include \"list0.h\".*\r\n4\[23\]\[ \t\]+\}" "list line 1 with listsize 100"
c906108c 141
085dd6e6 142 gdb_test "list 10" "1\[ \t\]+#include \"list0.h\".*\r\n4\[23\]\[ \t\]+\}" "list line 10 with listsize 100"
c906108c
SS
143 }
144
145 # Try listsize of 0 which suppresses printing.
146
147 set_listsize 0
148 gdb_test "list 1" "" "listsize of 0 suppresses output"
149
150 # Try listsize of -1 which is special, and means unlimited.
151
152 set_listsize -1
153 setup_xfail "*-*-*"
154 gdb_test "list 1" "1\[ \t\]+#include .*\r\n39\[ \t\]+\}" "list line 1 with unlimited listsize"
155}
156
157#
158# Test "list filename:number" for C include file
159#
160
161proc test_list_include_file {} {
162 global gdb_prompt
163
164 setup_xfail "a29k-*-udi"
165 setup_xfail_format "DWARF 1"
166 setup_xfail_format "COFF"
d4f3574e 167 gdb_test "list list0.h:1" "1\[ \t\]+/\[*\]+ An include file .*10\[ \t\]+bar \\(x\\+\\+\\);" "list line 1 in include file"
c906108c
SS
168
169 setup_xfail "a29k-*-udi"
170 setup_xfail_format "DWARF 1"
171 setup_xfail_format "COFF"
085dd6e6 172 gdb_test "list list0.h:100" "Line number 95 out of range; .*list0.h has 3\[67\] lines." "list message for lines past EOF"
c906108c
SS
173}
174
175#
176# Test "list filename:number" for C source file
177#
178
179proc test_list_filename_and_number {} {
180 global gdb_prompt
181
182 set testcnt 0
183
184 send_gdb "list list0.c:1\n"
185 gdb_expect {
d4f3574e 186 -re "1\[ \t\]+#include \"list0.h\".*10\[ \t]+x = 0;\r\n$gdb_prompt $" {
c906108c
SS
187 incr testcnt
188 }
189 -re ".*$gdb_prompt $" { fail "list list0.c:1" ; gdb_suppress_tests }
190 timeout { fail "list list0.c:1 (timeout)" ; gdb_suppress_tests }
191 }
192 send_gdb "list list0.c:10\n"
193 gdb_expect {
194 -re "5\[ \t\]+int x;.*14\[ \t\]+foo .x\[+)\]+;\r\n$gdb_prompt $" {
195 incr testcnt
196 }
197 -re ".*$gdb_prompt $" { fail "list list.c:10" ; gdb_suppress_tests }
198 timeout { fail "list list.c:10 (timeout)" ; gdb_suppress_tests }
199 }
200 send_gdb "list list1.c:1\n"
201 gdb_expect {
085dd6e6 202 -re "1\[ \t\]+\#include.*4\[ \t\]+.*int oof\[ \t\]*\(.*\);\r\n.*$gdb_prompt $" {
c906108c
SS
203 incr testcnt
204 }
205 -re ".*$gdb_prompt $" { fail "list list1.c:1" ; gdb_suppress_tests }
206 timeout { fail "list list1.c:1 (timeout)" ; gdb_suppress_tests }
207 }
208 send_gdb "list list1.c:12\n"
209 gdb_expect {
085dd6e6 210 -re "12\[ \t\]+long_line \[(\]+.*\[)\]+;.*13\[ \t\]+\}\r\n.*$gdb_prompt $" {
c906108c
SS
211 incr testcnt
212 }
213 -re ".*$gdb_prompt $" { fail "list list1.c:12" ; gdb_suppress_tests }
214 timeout { fail "list list1.c:12 (timeout)" ; gdb_suppress_tests }
215 }
216 pass "list filename:number ($testcnt tests)"
217 gdb_stop_suppressing_tests;
218}
219
220#
221# Test "list function" for C source file
222#
223
224proc test_list_function {} {
225 global gdb_prompt
226 global gcc_compiled
227
228 # gcc appears to generate incorrect debugging information for code
229 # in include files, which breaks this test.
230 # SunPRO cc is the second case below, it's also correct.
231 setup_xfail "a29k-*-udi"
d4f3574e 232 gdb_test "list main" "(5\[ \t\]+int x;.*14\[ \t\]+foo \[(\]+.*\[)\]+;|1\[ \t\]+#include .*10\[ \t\]+x = 0;)" "list function in source file 1"
c906108c
SS
233
234 # Ultrix gdb takes the second case below; it's also correct.
235 # SunPRO cc is the third case.
085dd6e6 236 gdb_test "list bar" "(4\[ \t\]+void.*\[ \t\]*long_line.*;.*bar.*9\[ \t\]*.*|1\[ \t\]+void.*8\[ \t\]+\}|1\[ \t\]+void.*7\[ \t\]*long_line ..;|7\[ \t\]+void.*14\[ \t\]+\})" "list function in source file 2"
c906108c
SS
237
238 # Test "list function" for C include file
239 # Ultrix gdb is the second case, still correct.
240 # SunPRO cc is the third case.
241 setup_xfail "powerpc-*-*"
242 setup_xfail_format "DWARF 1"
243 gdb_test "list foo" "(3\[ \t\]+.*12\[ \t\]+bar \[(\]+.*\[)\]+;|2\[ \t\]+including file.*11\[ \t\]+bar \[(\]+.*\[)\]+;|1\[ \t\]+/. An include file.*10\[ \t\]+bar \[(\]+.*\[)\]+;)" "list function in include file"
244}
245
246proc test_list_forward {} {
247 global gdb_prompt
248
249 set testcnt 0
250
251 send_gdb "list list0.c:10\n"
252 gdb_expect {
253 -re "5\[ \t\]+int x;.*14\[ \t\]+foo \[(\]+.*\[)\]+;\r\n$gdb_prompt $" { incr testcnt }
254 -re ".*$gdb_prompt $" { fail "list list0.c:10" ; gdb_suppress_tests }
255 timeout { fail "list list0.c:10 (timeout)" ; gdb_suppress_tests }
256 }
257
258 send_gdb "list\n"
259 gdb_expect {
260 -re "15\[ \t\]+foo \[(\]+.*\[)\]+;.*24\[ \t\]+foo \[(\]+.*\[)\]+;\r\n$gdb_prompt $" { incr testcnt }
261 -re ".*$gdb_prompt $" { fail "list 15-24" ; gdb_suppress_tests }
262 timeout { fail "list 15-24 (timeout)" ; gdb_suppress_tests }
263 }
264
265 send_gdb "list\n"
266 gdb_expect {
267 -re "25\[ \t\]+foo \[(\]+.*\[)\]+;.*34\[ \t\]+foo \[(\]+.*\[)\]+;\r\n$gdb_prompt $" { incr testcnt }
268 -re ".*$gdb_prompt $" { fail "list 25-34" ; gdb_suppress_tests }
269 timeout { fail "list 25-34 (timeout)" ; gdb_suppress_tests }
270 }
271
272 send_gdb "list\n"
273 gdb_expect {
085dd6e6 274 -re "35\[ \t\]+foo \\(.*\\);.*42\[ \t\]+.*\}\r\n$gdb_prompt $" { incr testcnt }
c906108c
SS
275 -re ".*$gdb_prompt $" { fail "list 35-42" ; gdb_suppress_tests }
276 timeout { fail "list 35-42 (timeout)" ; gdb_suppress_tests }
277 }
278
279 pass "successive list commands to page forward ($testcnt tests)"
280 gdb_stop_suppressing_tests;
281}
282
a0b3c4fd
JM
283# Test that repeating the list linenum command doesn't print the same
284# lines over again. Note that this test makes sure that the argument
285# linenum is dropped, when we repeat the previous command. 'x/5i $pc'
286# works the same way.
287
288proc test_repeat_list_command {} {
289 global gdb_prompt
290
291 set testcnt 0
292
293 send_gdb "list list0.c:10\n"
294 gdb_expect {
295 -re "5\[ \t\]+int x;.*14\[ \t\]+foo \[(\]+.*\[)\]+;\r\n$gdb_prompt $" { incr testcnt }
296 -re ".*$gdb_prompt $" { fail "list list0.c:10" ; gdb_suppress_tests }
297 timeout { fail "list list0.c:10 (timeout)" ; gdb_suppress_tests }
298 }
299
300 send_gdb "\n"
301 gdb_expect {
302 -re "15\[ \t\]+foo \[(\]+.*\[)\]+;.*24\[ \t\]+foo \[(\]+.*\[)\]+;\r\n$gdb_prompt $" { incr testcnt }
303 -re ".*$gdb_prompt $" { fail "list 15-24" ; gdb_suppress_tests }
304 timeout { fail "list 15-24 (timeout)" ; gdb_suppress_tests }
305 }
306
307 send_gdb "\n"
308 gdb_expect {
309 -re "25\[ \t\]+foo \[(\]+.*\[)\]+;.*34\[ \t\]+foo \[(\]+.*\[)\]+;\r\n$gdb_prompt $" { incr testcnt }
310 -re ".*$gdb_prompt $" { fail "list 25-34" ; gdb_suppress_tests }
311 timeout { fail "list 25-34 (timeout)" ; gdb_suppress_tests }
312 }
313
314 send_gdb "\n"
315 gdb_expect {
316 -re "35\[ \t\]+foo \\(.*\\);.*42\[ \t\]+.*\}\r\n$gdb_prompt $" { incr testcnt }
317 -re ".*$gdb_prompt $" { fail "list 35-42" ; gdb_suppress_tests }
318 timeout { fail "list 35-42 (timeout)" ; gdb_suppress_tests }
319 }
320
321 pass "repeat list commands to page forward using 'return' ($testcnt tests)"
322 gdb_stop_suppressing_tests;
323}
324
c906108c
SS
325proc test_list_backwards {} {
326 global gdb_prompt
327
328 set testcnt 0
329
330 send_gdb "list list0.c:33\n"
331 gdb_expect {
085dd6e6 332 -re "28\[ \t\]+foo \\(.*\\);.*37\[ \t\]+\}\r\n$gdb_prompt $" { incr testcnt }
c906108c
SS
333 -re ".*$gdb_prompt $" { fail "list list0.c:33" ; gdb_suppress_tests }
334 timeout { fail "list list0.c:33 (timeout)" ; gdb_suppress_tests }
335 }
336
337 send_gdb "list -\n"
338 gdb_expect {
339 -re "18\[ \t\]+foo \[(\]+.*\[)\]+;.*27\[ \t\]+foo \[(\]+.*\[)\]+;\r\n$gdb_prompt $" { incr testcnt }
340 -re ".*$gdb_prompt $" { fail "list 18-27" ; gdb_suppress_tests }
341 timeout { fail "list 18-27 (timeout)" ; gdb_suppress_tests }
342 }
343
344 send_gdb "list -\n"
345 gdb_expect {
346 -re "8\[ \t\]+breakpoint\[(\]\[)\];.*17\[ \t\]+foo \[(\]+.*\[)\]+;\r\n$gdb_prompt $" { incr testcnt }
347 -re ".*$gdb_prompt $" { fail "list 8-17" ; gdb_suppress_tests }
348 timeout { fail "list 8-17 (timeout)" ; gdb_suppress_tests }
349 }
350
351 send_gdb "list -\n"
352 gdb_expect {
353 -re "1\[ \t\]+#include .*7\[ \t\]+set_debug_traps\[(\]\[)\]+;\r\n$gdb_prompt $" { incr testcnt }
354 -re ".*$gdb_prompt $" { fail "list 1-7" ; gdb_suppress_tests }
355 timeout { fail "list 1-7 (timeout)" ; gdb_suppress_tests }
356 }
357
358 pass "$testcnt successive \"list -\" commands to page backwards"
359 gdb_stop_suppressing_tests;
360}
361
362#
363# Test "list first,last"
364#
365
366proc test_list_range {} {
367 global gdb_prompt
368
085dd6e6 369 gdb_test "list list0.c:2,list0.c:5" "2\[ \t\]+\r\n3\[ \t\]+int main \[)(\]+.*5\[ \t\]+int x;" "list range; filename:line1,filename:line2"
c906108c 370
085dd6e6 371 gdb_test "list 2,5" "2\[ \t\]+\r\n3\[ \t\]+int main \[)(\]+.*5\[ \t\]+int x;" "list range; line1,line2"
c906108c
SS
372
373# gdb_test "list -1,6" "Line number 0 out of range; .*list0.c has 39 lines." "list range; lower bound negative"
374
375# gdb_test "list -100,-40" "Line number -60 out of range; .*list0.c has 39 lines." "list range; both bounds negative"
376
085dd6e6 377 gdb_test "list 30,45" "30\[ \t\]+foo \(.*\);.*43\[ \t\]+\}" "list range; upper bound past EOF"
c906108c 378
085dd6e6 379 gdb_test "list 45,100" "Line number 45 out of range; .*list0.c has 43 lines." "list range; both bounds past EOF"
c906108c
SS
380
381 gdb_test "list list0.c:2,list1.c:17" "Specified start and end are in different files." "list range, must be same files"
382}
383
384#
385# Test "list filename:function"
386#
387
388proc test_list_filename_and_function {} {
389 global gdb_prompt
390
391 set testcnt 0
392
393 # gcc appears to generate incorrect debugging information for code
394 # in include files, which breaks this test.
395 # SunPRO cc is the second case below, it's also correct.
396 setup_xfail "a29k-*-udi"
397 send_gdb "list list0.c:main\n"
398 gdb_expect {
d4f3574e 399 -re "1\[ \t\]+#include .*10\[ \t\]+x = 0;\r\n$gdb_prompt $" {
c906108c
SS
400 incr testcnt
401 }
402 -re "5\[ \t\]+int x;.*14\[ \t\]+foo \[(\]+.*\[)\]+;\r\n$gdb_prompt $" {
403 pass "list function in source file 1"
404 }
405 -re ".*$gdb_prompt $" { fail "list list0.c:main" }
406 timeout { fail "list list0.c:main (timeout)" }
407 }
408
409 # The i960 and a29k-amd-udi are the second case
410
411 # Not sure what the point of having this function be unused is.
412 # AIX is legitimately removing it.
413 setup_xfail "rs6000-*-aix*"
414 send_gdb "list list0.c:unused\n"
415 gdb_expect {
085dd6e6 416 -re "40\[ \t\]+unused.*43\[ \t\]+\}\r\n$gdb_prompt $" {
c906108c
SS
417 incr testcnt
418 }
419 -re "37.*42\[ \t\]+\}\r\n$gdb_prompt $" {
420 incr testcnt
421 }
422 -re ".*$gdb_prompt $" { fail "list list0.c:unused" }
423 timeout { fail "list list0.c:unused (timeout)" }
424 }
425 clear_xfail "rs6000-*-aix*"
426
427 # gcc appears to generate incorrect debugging information for code
428 # in include files, which breaks this test.
429 # Ultrix gdb is the second case, one line different but still correct.
430 # SunPRO cc is the third case.
431 setup_xfail "rs6000-*-*" 1804
432 setup_xfail "powerpc-*-*" 1804
433 setup_xfail "a29k-*-udi"
434 setup_xfail_format "DWARF 1"
435 setup_xfail_format "COFF"
436 send_gdb "list list0.h:foo\n"
437 gdb_expect {
438 -re "2\[ \t\]+including file. This.*11\[ \t\]+bar \[(\]+.*\[)\]+;\r\n$gdb_prompt $" {
439 incr testcnt
440 }
441 -re "1\[ \t\]+/. An include file.*10\[ \t\]+bar \[(\]+.*\[)\]+;\r\n$gdb_prompt $" {
442 incr testcnt
443 }
444 -re "3\[ \t\]+.*12\[ \t\]+bar \[(\]+.*\[)\]+;\r\n$gdb_prompt $" {
445 incr testcnt
446 }
447 -re "No source file named list0.h.\r\n$gdb_prompt $" {
448 fail "list list0.h:foo"
449 }
450 -re ".*$gdb_prompt $" { fail "list list0.h:foo" }
451 timeout { fail "list list0.h:foo (timeout)" }
452 }
453
454 # Ultrix gdb is the second case.
455 # a29k-amd-udi is the third case.
456 send_gdb "list list1.c:bar\n"
457 gdb_expect {
085dd6e6 458 -re "4\[ \t\]+void.*13\[ \t\]+\}\r\n$gdb_prompt $" {
c906108c
SS
459 incr testcnt
460 }
085dd6e6 461 -re "4\[ \t\]+void.*12\[ \t\]*long_line ..;\r\n$gdb_prompt $" {
c906108c
SS
462 incr testcnt
463 }
085dd6e6 464 -re "4\[ \t\]+void.*11\[ \t\]*\r\n$gdb_prompt $" {
c906108c
SS
465 incr testcnt
466 }
467 -re ".*$gdb_prompt $" { fail "list list1.c:bar" }
468 timeout { fail "list list1.c:bar (timeout)" }
469 }
470
471 # The i960 and a29k-amd-udi are the second case
472
473 # Not sure what the point of having this function be unused is.
474 # AIX is legitimately removing it.
475 setup_xfail "rs6000-*-aix*"
476 send_gdb "list list1.c:unused\n"
477 gdb_expect {
085dd6e6 478 -re "12\[ \t\]+long_line \[(\]\[)\];.*13\[ \t\]+\}\r\n.*$gdb_prompt $" {
c906108c
SS
479 incr testcnt
480 }
085dd6e6 481 -re "14.*19\[ \t\]+\}\r\n.*$gdb_prompt $" {
c906108c
SS
482 incr testcnt
483 }
484 -re ".*$gdb_prompt $" { fail "list list1.c:unused" }
485 timeout { fail "list list1.c:unused (timeout)" }
486 }
487 clear_xfail "rs6000-*-aix*"
488
489 pass "list filename:function ($testcnt tests)"
490
491 # Test some invalid specs
492 # The following test takes the FIXME result on most systems using
493 # DWARF. It fails to notice that main() is not in the file requested.
494
495 setup_xfail "*-*-*"
496
497# Does this actually work ANYWHERE? I believe not, as this is an `aspect' of
498# lookup_symbol(), where, when it is given a specific symtab which does not
499# contain the requested symbol, it will subsequently search all of the symtabs
500# for the requested symbol.
501
502 gdb_test "list list0.c:foo" "Function \"foo\" not defined in .*list0.c" "list filename:function; wrong filename rejected"
503
085dd6e6 504 gdb_test "list foobar.c:main" "No source file named foobar.c.|Location not found" "list filename:function; nonexistant file"
c906108c
SS
505
506 setup_xfail_format "DWARF 1"
085dd6e6 507 gdb_test "list list0.h:foobar" "Function \"foobar\" not defined.|Location not found" "list filename:function; nonexistant function"
c906108c
SS
508
509}
510
511proc test_forward_search {} {
512 global timeout
513
514 gdb_test "set listsize 4" ""
515 # On SunOS4, this gives us lines 19-22. On AIX, it gives us
516 # lines 20-23. This depends on whether the line number of a function
517 # is considered to be the openbrace or the first statement--either one
518 # is acceptable.
085dd6e6 519 gdb_test "list long_line" "24\[ \t\]+long_line .*"
c906108c
SS
520
521 gdb_test "search 4321" " not found"
522
085dd6e6 523 gdb_test "search 6789" "28\[ \t\]+oof .6789.;"
c906108c
SS
524
525 # Test that GDB won't crash if the line being searched is extremely long.
526
527 set oldtimeout $timeout
528 set timeout [expr "$timeout + 300"]
529 verbose "Timeout is now $timeout seconds" 2
530 gdb_test "search 1234" ".*1234.*" "search extremely long line (> 5000 chars)"
531 set timeout $oldtimeout
532 verbose "Timeout is now $timeout seconds" 2
533}
534
535# Start with a fresh gdb.
536
537gdb_exit
538gdb_start
539gdb_reinitialize_dir $srcdir/$subdir
540gdb_load ${binfile}
541
542if [target_info exists gdb_stub] {
543 gdb_step_for_stub;
544}
545
546gdb_test "set width 0" "" "set width 0"
547
548test_listsize
549get_debug_format
550if [ set_listsize 10 ] then {
551 test_list_include_file
552 test_list_filename_and_number
553 test_list_function
554 test_list_forward
555 test_list_backwards
a0b3c4fd 556 test_repeat_list_command
c906108c
SS
557 test_list_range
558 test_list_filename_and_function
559 test_forward_search
560}
085dd6e6
JM
561
562remote_exec build "rm -f list0.h"