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