Commit | Line | Data |
---|---|---|
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 | ||
22 | if $tracelevel then { | |
23 | strace $tracelevel | |
24 | } | |
25 | ||
26 | set prms_id 0 | |
27 | set bug_id 0 | |
28 | ||
29 | set testfile "list" | |
30 | set binfile ${objdir}/${subdir}/${testfile} | |
31 | ||
32 | # Need to download the header to the host. | |
33 | remote_download host ${srcdir}/${subdir}/list0.h list0.h | |
34 | ||
35 | ||
36 | if { [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 | ||
40 | if { [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 | ||
44 | if { [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. | |
52 | if [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 | ||
61 | set set_listsize_count 0; | |
62 | ||
63 | proc 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 | ||
85 | proc 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 ] { | |
114 | gdb_test "list 1" "1\[ \t\]+#include \"list0.h\"" "list line 1 with listsize 2" | |
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 ] { | |
122 | setup_xfail "*-*-*" | |
123 | gdb_test "list 1" "1\[ \t\]+#include \"list0.h\"2\[ \t\]+" "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" |
c906108c | 125 | |
085dd6e6 | 126 | gdb_test "list 3" "2\[ \t\]+\r\n3\[ \t\]+int main \[(\]+\[)\]+\r\n4\[ \t\]+\{" "list line 3 with listsize 3" |
c906108c SS |
127 | } |
128 | ||
129 | # Try small listsize > 2 that is an even number. | |
130 | ||
131 | if [ set_listsize 4 ] then { | |
132 | gdb_test "list 1" "1\[ \t\]+#include \"list0.h\"\r\n2\[ \t\]+" "list line 1 with listsize 4" | |
085dd6e6 | 133 | gdb_test "list 2" "1\[ \t\]+#include \"list0.h\".*3\[ \t\]+int main \[)(\]+" "list line 2 with listsize 4" |
c906108c SS |
134 | |
135 | gdb_test "list 3" "1\[ \t\]+#include \"list0.h\".*4\[ \t\]+\{" "list line 3 with listsize 4" | |
136 | gdb_test "list 4" "2\[ \t\]+\r\n.*5\[ \t\]+int x;.*" "list line 4 with listsize 4" | |
137 | } | |
138 | ||
139 | # Try a size larger than the entire file. | |
140 | ||
141 | if [ set_listsize 100 ] then { | |
085dd6e6 | 142 | gdb_test "list 1" "1\[ \t\]+#include \"list0.h\".*\r\n4\[23\]\[ \t\]+\}" "list line 1 with listsize 100" |
c906108c | 143 | |
085dd6e6 | 144 | gdb_test "list 10" "1\[ \t\]+#include \"list0.h\".*\r\n4\[23\]\[ \t\]+\}" "list line 10 with listsize 100" |
c906108c SS |
145 | } |
146 | ||
147 | # Try listsize of 0 which suppresses printing. | |
148 | ||
149 | set_listsize 0 | |
150 | gdb_test "list 1" "" "listsize of 0 suppresses output" | |
151 | ||
152 | # Try listsize of -1 which is special, and means unlimited. | |
153 | ||
154 | set_listsize -1 | |
155 | setup_xfail "*-*-*" | |
156 | gdb_test "list 1" "1\[ \t\]+#include .*\r\n39\[ \t\]+\}" "list line 1 with unlimited listsize" | |
157 | } | |
158 | ||
159 | # | |
160 | # Test "list filename:number" for C include file | |
161 | # | |
162 | ||
163 | proc test_list_include_file {} { | |
164 | global gdb_prompt | |
165 | ||
166 | setup_xfail "a29k-*-udi" | |
167 | setup_xfail_format "DWARF 1" | |
168 | setup_xfail_format "COFF" | |
085dd6e6 | 169 | gdb_test "list list0.h:1" "1\[ \t\]+/\[*\]+ An include file .*4\[ \t\]+.*foo \(.*x.*\).*" "list line 1 in include file" |
c906108c SS |
170 | |
171 | setup_xfail "a29k-*-udi" | |
172 | setup_xfail_format "DWARF 1" | |
173 | setup_xfail_format "COFF" | |
085dd6e6 | 174 | 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 |
175 | } |
176 | ||
177 | # | |
178 | # Test "list filename:number" for C source file | |
179 | # | |
180 | ||
181 | proc test_list_filename_and_number {} { | |
182 | global gdb_prompt | |
183 | ||
184 | set testcnt 0 | |
185 | ||
186 | send_gdb "list list0.c:1\n" | |
187 | gdb_expect { | |
188 | -re "1\[ \t\]+#include \"list0.h\".*5\[ \t\]+int x;\r\n$gdb_prompt $" { | |
189 | incr testcnt | |
190 | } | |
191 | -re ".*$gdb_prompt $" { fail "list list0.c:1" ; gdb_suppress_tests } | |
192 | timeout { fail "list list0.c:1 (timeout)" ; gdb_suppress_tests } | |
193 | } | |
194 | send_gdb "list list0.c:10\n" | |
195 | gdb_expect { | |
196 | -re "5\[ \t\]+int x;.*14\[ \t\]+foo .x\[+)\]+;\r\n$gdb_prompt $" { | |
197 | incr testcnt | |
198 | } | |
199 | -re ".*$gdb_prompt $" { fail "list list.c:10" ; gdb_suppress_tests } | |
200 | timeout { fail "list list.c:10 (timeout)" ; gdb_suppress_tests } | |
201 | } | |
202 | send_gdb "list list1.c:1\n" | |
203 | gdb_expect { | |
085dd6e6 | 204 | -re "1\[ \t\]+\#include.*4\[ \t\]+.*int oof\[ \t\]*\(.*\);\r\n.*$gdb_prompt $" { |
c906108c SS |
205 | incr testcnt |
206 | } | |
207 | -re ".*$gdb_prompt $" { fail "list list1.c:1" ; gdb_suppress_tests } | |
208 | timeout { fail "list list1.c:1 (timeout)" ; gdb_suppress_tests } | |
209 | } | |
210 | send_gdb "list list1.c:12\n" | |
211 | gdb_expect { | |
085dd6e6 | 212 | -re "12\[ \t\]+long_line \[(\]+.*\[)\]+;.*13\[ \t\]+\}\r\n.*$gdb_prompt $" { |
c906108c SS |
213 | incr testcnt |
214 | } | |
215 | -re ".*$gdb_prompt $" { fail "list list1.c:12" ; gdb_suppress_tests } | |
216 | timeout { fail "list list1.c:12 (timeout)" ; gdb_suppress_tests } | |
217 | } | |
218 | pass "list filename:number ($testcnt tests)" | |
219 | gdb_stop_suppressing_tests; | |
220 | } | |
221 | ||
222 | # | |
223 | # Test "list function" for C source file | |
224 | # | |
225 | ||
226 | proc test_list_function {} { | |
227 | global gdb_prompt | |
228 | global gcc_compiled | |
229 | ||
230 | # gcc appears to generate incorrect debugging information for code | |
231 | # in include files, which breaks this test. | |
232 | # SunPRO cc is the second case below, it's also correct. | |
233 | setup_xfail "a29k-*-udi" | |
234 | gdb_test "list main" "(5\[ \t\]+int x;.*14\[ \t\]+foo \[(\]+.*\[)\]+;|1\[ \t\]+#include .*8\[ \t\]+breakpoint\[(\]\[)\]+;)" "list function in source file 1" | |
235 | ||
236 | # Ultrix gdb takes the second case below; it's also correct. | |
237 | # SunPRO cc is the third case. | |
085dd6e6 | 238 | 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 |
239 | |
240 | # Test "list function" for C include file | |
241 | # Ultrix gdb is the second case, still correct. | |
242 | # SunPRO cc is the third case. | |
243 | setup_xfail "powerpc-*-*" | |
244 | setup_xfail_format "DWARF 1" | |
245 | 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" | |
246 | } | |
247 | ||
248 | proc test_list_forward {} { | |
249 | global gdb_prompt | |
250 | ||
251 | set testcnt 0 | |
252 | ||
253 | send_gdb "list list0.c:10\n" | |
254 | gdb_expect { | |
255 | -re "5\[ \t\]+int x;.*14\[ \t\]+foo \[(\]+.*\[)\]+;\r\n$gdb_prompt $" { incr testcnt } | |
256 | -re ".*$gdb_prompt $" { fail "list list0.c:10" ; gdb_suppress_tests } | |
257 | timeout { fail "list list0.c:10 (timeout)" ; gdb_suppress_tests } | |
258 | } | |
259 | ||
260 | send_gdb "list\n" | |
261 | gdb_expect { | |
262 | -re "15\[ \t\]+foo \[(\]+.*\[)\]+;.*24\[ \t\]+foo \[(\]+.*\[)\]+;\r\n$gdb_prompt $" { incr testcnt } | |
263 | -re ".*$gdb_prompt $" { fail "list 15-24" ; gdb_suppress_tests } | |
264 | timeout { fail "list 15-24 (timeout)" ; gdb_suppress_tests } | |
265 | } | |
266 | ||
267 | send_gdb "list\n" | |
268 | gdb_expect { | |
269 | -re "25\[ \t\]+foo \[(\]+.*\[)\]+;.*34\[ \t\]+foo \[(\]+.*\[)\]+;\r\n$gdb_prompt $" { incr testcnt } | |
270 | -re ".*$gdb_prompt $" { fail "list 25-34" ; gdb_suppress_tests } | |
271 | timeout { fail "list 25-34 (timeout)" ; gdb_suppress_tests } | |
272 | } | |
273 | ||
274 | send_gdb "list\n" | |
275 | gdb_expect { | |
085dd6e6 | 276 | -re "35\[ \t\]+foo \\(.*\\);.*42\[ \t\]+.*\}\r\n$gdb_prompt $" { incr testcnt } |
c906108c SS |
277 | -re ".*$gdb_prompt $" { fail "list 35-42" ; gdb_suppress_tests } |
278 | timeout { fail "list 35-42 (timeout)" ; gdb_suppress_tests } | |
279 | } | |
280 | ||
281 | pass "successive list commands to page forward ($testcnt tests)" | |
282 | gdb_stop_suppressing_tests; | |
283 | } | |
284 | ||
a0b3c4fd JM |
285 | # Test that repeating the list linenum command doesn't print the same |
286 | # lines over again. Note that this test makes sure that the argument | |
287 | # linenum is dropped, when we repeat the previous command. 'x/5i $pc' | |
288 | # works the same way. | |
289 | ||
290 | proc test_repeat_list_command {} { | |
291 | global gdb_prompt | |
292 | ||
293 | set testcnt 0 | |
294 | ||
295 | send_gdb "list list0.c:10\n" | |
296 | gdb_expect { | |
297 | -re "5\[ \t\]+int x;.*14\[ \t\]+foo \[(\]+.*\[)\]+;\r\n$gdb_prompt $" { incr testcnt } | |
298 | -re ".*$gdb_prompt $" { fail "list list0.c:10" ; gdb_suppress_tests } | |
299 | timeout { fail "list list0.c:10 (timeout)" ; gdb_suppress_tests } | |
300 | } | |
301 | ||
302 | send_gdb "\n" | |
303 | gdb_expect { | |
304 | -re "15\[ \t\]+foo \[(\]+.*\[)\]+;.*24\[ \t\]+foo \[(\]+.*\[)\]+;\r\n$gdb_prompt $" { incr testcnt } | |
305 | -re ".*$gdb_prompt $" { fail "list 15-24" ; gdb_suppress_tests } | |
306 | timeout { fail "list 15-24 (timeout)" ; gdb_suppress_tests } | |
307 | } | |
308 | ||
309 | send_gdb "\n" | |
310 | gdb_expect { | |
311 | -re "25\[ \t\]+foo \[(\]+.*\[)\]+;.*34\[ \t\]+foo \[(\]+.*\[)\]+;\r\n$gdb_prompt $" { incr testcnt } | |
312 | -re ".*$gdb_prompt $" { fail "list 25-34" ; gdb_suppress_tests } | |
313 | timeout { fail "list 25-34 (timeout)" ; gdb_suppress_tests } | |
314 | } | |
315 | ||
316 | send_gdb "\n" | |
317 | gdb_expect { | |
318 | -re "35\[ \t\]+foo \\(.*\\);.*42\[ \t\]+.*\}\r\n$gdb_prompt $" { incr testcnt } | |
319 | -re ".*$gdb_prompt $" { fail "list 35-42" ; gdb_suppress_tests } | |
320 | timeout { fail "list 35-42 (timeout)" ; gdb_suppress_tests } | |
321 | } | |
322 | ||
323 | pass "repeat list commands to page forward using 'return' ($testcnt tests)" | |
324 | gdb_stop_suppressing_tests; | |
325 | } | |
326 | ||
c906108c SS |
327 | proc test_list_backwards {} { |
328 | global gdb_prompt | |
329 | ||
330 | set testcnt 0 | |
331 | ||
332 | send_gdb "list list0.c:33\n" | |
333 | gdb_expect { | |
085dd6e6 | 334 | -re "28\[ \t\]+foo \\(.*\\);.*37\[ \t\]+\}\r\n$gdb_prompt $" { incr testcnt } |
c906108c SS |
335 | -re ".*$gdb_prompt $" { fail "list list0.c:33" ; gdb_suppress_tests } |
336 | timeout { fail "list list0.c:33 (timeout)" ; gdb_suppress_tests } | |
337 | } | |
338 | ||
339 | send_gdb "list -\n" | |
340 | gdb_expect { | |
341 | -re "18\[ \t\]+foo \[(\]+.*\[)\]+;.*27\[ \t\]+foo \[(\]+.*\[)\]+;\r\n$gdb_prompt $" { incr testcnt } | |
342 | -re ".*$gdb_prompt $" { fail "list 18-27" ; gdb_suppress_tests } | |
343 | timeout { fail "list 18-27 (timeout)" ; gdb_suppress_tests } | |
344 | } | |
345 | ||
346 | send_gdb "list -\n" | |
347 | gdb_expect { | |
348 | -re "8\[ \t\]+breakpoint\[(\]\[)\];.*17\[ \t\]+foo \[(\]+.*\[)\]+;\r\n$gdb_prompt $" { incr testcnt } | |
349 | -re ".*$gdb_prompt $" { fail "list 8-17" ; gdb_suppress_tests } | |
350 | timeout { fail "list 8-17 (timeout)" ; gdb_suppress_tests } | |
351 | } | |
352 | ||
353 | send_gdb "list -\n" | |
354 | gdb_expect { | |
355 | -re "1\[ \t\]+#include .*7\[ \t\]+set_debug_traps\[(\]\[)\]+;\r\n$gdb_prompt $" { incr testcnt } | |
356 | -re ".*$gdb_prompt $" { fail "list 1-7" ; gdb_suppress_tests } | |
357 | timeout { fail "list 1-7 (timeout)" ; gdb_suppress_tests } | |
358 | } | |
359 | ||
360 | pass "$testcnt successive \"list -\" commands to page backwards" | |
361 | gdb_stop_suppressing_tests; | |
362 | } | |
363 | ||
364 | # | |
365 | # Test "list first,last" | |
366 | # | |
367 | ||
368 | proc test_list_range {} { | |
369 | global gdb_prompt | |
370 | ||
085dd6e6 | 371 | 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 | 372 | |
085dd6e6 | 373 | gdb_test "list 2,5" "2\[ \t\]+\r\n3\[ \t\]+int main \[)(\]+.*5\[ \t\]+int x;" "list range; line1,line2" |
c906108c SS |
374 | |
375 | # gdb_test "list -1,6" "Line number 0 out of range; .*list0.c has 39 lines." "list range; lower bound negative" | |
376 | ||
377 | # gdb_test "list -100,-40" "Line number -60 out of range; .*list0.c has 39 lines." "list range; both bounds negative" | |
378 | ||
085dd6e6 | 379 | gdb_test "list 30,45" "30\[ \t\]+foo \(.*\);.*43\[ \t\]+\}" "list range; upper bound past EOF" |
c906108c | 380 | |
085dd6e6 | 381 | gdb_test "list 45,100" "Line number 45 out of range; .*list0.c has 43 lines." "list range; both bounds past EOF" |
c906108c SS |
382 | |
383 | gdb_test "list list0.c:2,list1.c:17" "Specified start and end are in different files." "list range, must be same files" | |
384 | } | |
385 | ||
386 | # | |
387 | # Test "list filename:function" | |
388 | # | |
389 | ||
390 | proc test_list_filename_and_function {} { | |
391 | global gdb_prompt | |
392 | ||
393 | set testcnt 0 | |
394 | ||
395 | # gcc appears to generate incorrect debugging information for code | |
396 | # in include files, which breaks this test. | |
397 | # SunPRO cc is the second case below, it's also correct. | |
398 | setup_xfail "a29k-*-udi" | |
399 | send_gdb "list list0.c:main\n" | |
400 | gdb_expect { | |
401 | -re "1\[ \t\]+#include .*8\[ \t\]+breakpoint\[(\]\[)\]+;\r\n$gdb_prompt $" { | |
402 | incr testcnt | |
403 | } | |
404 | -re "5\[ \t\]+int x;.*14\[ \t\]+foo \[(\]+.*\[)\]+;\r\n$gdb_prompt $" { | |
405 | pass "list function in source file 1" | |
406 | } | |
407 | -re ".*$gdb_prompt $" { fail "list list0.c:main" } | |
408 | timeout { fail "list list0.c:main (timeout)" } | |
409 | } | |
410 | ||
411 | # The i960 and a29k-amd-udi are the second case | |
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 | |
435 | setup_xfail "a29k-*-udi" | |
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. | |
457 | # a29k-amd-udi is the third case. | |
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 | ||
473 | # The i960 and a29k-amd-udi are the second case | |
474 | ||
475 | # Not sure what the point of having this function be unused is. | |
476 | # AIX is legitimately removing it. | |
477 | setup_xfail "rs6000-*-aix*" | |
478 | send_gdb "list list1.c:unused\n" | |
479 | gdb_expect { | |
085dd6e6 | 480 | -re "12\[ \t\]+long_line \[(\]\[)\];.*13\[ \t\]+\}\r\n.*$gdb_prompt $" { |
c906108c SS |
481 | incr testcnt |
482 | } | |
085dd6e6 | 483 | -re "14.*19\[ \t\]+\}\r\n.*$gdb_prompt $" { |
c906108c SS |
484 | incr testcnt |
485 | } | |
486 | -re ".*$gdb_prompt $" { fail "list list1.c:unused" } | |
487 | timeout { fail "list list1.c:unused (timeout)" } | |
488 | } | |
489 | clear_xfail "rs6000-*-aix*" | |
490 | ||
491 | pass "list filename:function ($testcnt tests)" | |
492 | ||
493 | # Test some invalid specs | |
494 | # The following test takes the FIXME result on most systems using | |
495 | # DWARF. It fails to notice that main() is not in the file requested. | |
496 | ||
497 | setup_xfail "*-*-*" | |
498 | ||
499 | # Does this actually work ANYWHERE? I believe not, as this is an `aspect' of | |
500 | # lookup_symbol(), where, when it is given a specific symtab which does not | |
501 | # contain the requested symbol, it will subsequently search all of the symtabs | |
502 | # for the requested symbol. | |
503 | ||
504 | gdb_test "list list0.c:foo" "Function \"foo\" not defined in .*list0.c" "list filename:function; wrong filename rejected" | |
505 | ||
085dd6e6 | 506 | gdb_test "list foobar.c:main" "No source file named foobar.c.|Location not found" "list filename:function; nonexistant file" |
c906108c SS |
507 | |
508 | setup_xfail_format "DWARF 1" | |
085dd6e6 | 509 | gdb_test "list list0.h:foobar" "Function \"foobar\" not defined.|Location not found" "list filename:function; nonexistant function" |
c906108c SS |
510 | |
511 | } | |
512 | ||
513 | proc test_forward_search {} { | |
514 | global timeout | |
515 | ||
516 | gdb_test "set listsize 4" "" | |
517 | # On SunOS4, this gives us lines 19-22. On AIX, it gives us | |
518 | # lines 20-23. This depends on whether the line number of a function | |
519 | # is considered to be the openbrace or the first statement--either one | |
520 | # is acceptable. | |
085dd6e6 | 521 | gdb_test "list long_line" "24\[ \t\]+long_line .*" |
c906108c SS |
522 | |
523 | gdb_test "search 4321" " not found" | |
524 | ||
085dd6e6 | 525 | gdb_test "search 6789" "28\[ \t\]+oof .6789.;" |
c906108c SS |
526 | |
527 | # Test that GDB won't crash if the line being searched is extremely long. | |
528 | ||
529 | set oldtimeout $timeout | |
530 | set timeout [expr "$timeout + 300"] | |
531 | verbose "Timeout is now $timeout seconds" 2 | |
532 | gdb_test "search 1234" ".*1234.*" "search extremely long line (> 5000 chars)" | |
533 | set timeout $oldtimeout | |
534 | verbose "Timeout is now $timeout seconds" 2 | |
535 | } | |
536 | ||
537 | # Start with a fresh gdb. | |
538 | ||
539 | gdb_exit | |
540 | gdb_start | |
541 | gdb_reinitialize_dir $srcdir/$subdir | |
542 | gdb_load ${binfile} | |
543 | ||
544 | if [target_info exists gdb_stub] { | |
545 | gdb_step_for_stub; | |
546 | } | |
547 | ||
548 | gdb_test "set width 0" "" "set width 0" | |
549 | ||
550 | test_listsize | |
551 | get_debug_format | |
552 | if [ set_listsize 10 ] then { | |
553 | test_list_include_file | |
554 | test_list_filename_and_number | |
555 | test_list_function | |
556 | test_list_forward | |
557 | test_list_backwards | |
a0b3c4fd | 558 | test_repeat_list_command |
c906108c SS |
559 | test_list_range |
560 | test_list_filename_and_function | |
561 | test_forward_search | |
562 | } | |
085dd6e6 JM |
563 | |
564 | remote_exec build "rm -f list0.h" |