Commit | Line | Data |
---|---|---|
9b254dd1 | 1 | # Copyright 1992, 1994, 1995, 1996, 1997, 1998, 1999, 2002, 2003, 2007, 2008 |
b6ba6518 | 2 | # Free Software Foundation, Inc. |
c906108c SS |
3 | |
4 | # This program is free software; you can redistribute it and/or modify | |
5 | # it under the terms of the GNU General Public License as published by | |
e22f8b7c | 6 | # the Free Software Foundation; either version 3 of the License, or |
c906108c | 7 | # (at your option) any later version. |
e22f8b7c | 8 | # |
c906108c SS |
9 | # This program is distributed in the hope that it will be useful, |
10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
12 | # GNU General Public License for more details. | |
e22f8b7c | 13 | # |
c906108c | 14 | # You should have received a copy of the GNU General Public License |
e22f8b7c | 15 | # along with this program. If not, see <http://www.gnu.org/licenses/>. |
c906108c | 16 | |
c906108c SS |
17 | # This file was written by Fred Fish. (fnf@cygnus.com) |
18 | ||
19 | if $tracelevel then { | |
20 | strace $tracelevel | |
21 | } | |
22 | ||
23 | set prms_id 0 | |
24 | set bug_id 0 | |
25 | ||
26 | set testfile "list" | |
27 | set binfile ${objdir}/${subdir}/${testfile} | |
28 | ||
29 | # Need to download the header to the host. | |
30 | remote_download host ${srcdir}/${subdir}/list0.h list0.h | |
31 | ||
32 | ||
33 | if { [gdb_compile "${srcdir}/${subdir}/list0.c" "${binfile}0.o" object {debug}] != "" } { | |
b60f0898 JB |
34 | untested list.exp |
35 | return -1 | |
c906108c SS |
36 | } |
37 | ||
38 | if { [gdb_compile "${srcdir}/${subdir}/list1.c" "${binfile}1.o" object {debug}] != "" } { | |
b60f0898 JB |
39 | untested list.exp |
40 | return -1 | |
c906108c SS |
41 | } |
42 | ||
43 | if { [gdb_compile "${binfile}0.o ${binfile}1.o" ${binfile} executable {debug}] != "" } { | |
b60f0898 JB |
44 | untested list.exp |
45 | return -1 | |
c906108c SS |
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 | |
d7679631 FF |
95 | # Note that remote targets that have debugging info for _start available will |
96 | # list the lines there instead of main, so we skip this test for remote targets. | |
c906108c SS |
97 | # The second case is for optimized code, it is still correct. |
98 | ||
d7679631 FF |
99 | if [is_remote target] { |
100 | runto_main; | |
101 | unsupported "list default lines around main"; | |
102 | } else { | |
103 | gdb_test "list" "(1\[ \t\]+#include \"list0.h\".*10\[ \t\]+x = 0;|2.*11\[ \t\]+foo .x\[+)\]+;)" "list default lines around main" | |
104 | } | |
c906108c SS |
105 | |
106 | # Ensure we can limit printouts to one line | |
107 | ||
085dd6e6 | 108 | if [set_listsize 1] { |
c906108c | 109 | gdb_test "list 1" "1\[ \t\]+#include \"list0.h\"" "list line 1 with listsize 1" |
c906108c SS |
110 | gdb_test "list 2" "2\[ \t\]+" "list line 2 with listsize 1" |
111 | } | |
112 | ||
113 | # Try just two lines | |
114 | ||
115 | if [ set_listsize 2 ] { | |
d4f3574e | 116 | gdb_test "list 1" "1\[ \t\]+#include \"list0.h\"\r\n2\[ \t\]+" "list line 1 with listsize 2" |
c906108c | 117 | gdb_test "list 2" "1\[ \t\]+#include \"list0.h\"\r\n2\[ \t\]+" "list line 2 with listsize 2" |
085dd6e6 | 118 | gdb_test "list 3" "2\[ \t\]+\r\n3\[ \t\]+int main \[)(\]+" "list line 3 with listsize 2" |
c906108c SS |
119 | } |
120 | ||
121 | # Try small listsize > 1 that is an odd number | |
122 | ||
123 | if [ set_listsize 3 ] { | |
d4f3574e | 124 | gdb_test "list 1" "1\[ \t\]+#include \"list0.h\".*3\[ \t\]+int main \[)(\]+" "list line 1 with listsize 3" |
085dd6e6 | 125 | gdb_test "list 2" "1\[ \t\]+#include \"list0.h\".*3\[ \t\]+int main \[)(\]+" "list line 2 with listsize 3" |
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 { | |
d4f3574e SS |
132 | gdb_test "list 1" "1\[ \t\]+#include \"list0.h\".*4\[ \t\]+\{" "list line 1 with listsize 4" |
133 | gdb_test "list 2" "1\[ \t\]+#include \"list0.h\".*4\[ \t\]+\{" "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 | ||
c906108c | 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 | 168 | |
c906108c | 169 | setup_xfail_format "COFF" |
085dd6e6 | 170 | 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 |
171 | } |
172 | ||
173 | # | |
174 | # Test "list filename:number" for C source file | |
175 | # | |
176 | ||
177 | proc test_list_filename_and_number {} { | |
178 | global gdb_prompt | |
179 | ||
180 | set testcnt 0 | |
181 | ||
182 | send_gdb "list list0.c:1\n" | |
183 | gdb_expect { | |
d4f3574e | 184 | -re "1\[ \t\]+#include \"list0.h\".*10\[ \t]+x = 0;\r\n$gdb_prompt $" { |
c906108c SS |
185 | incr testcnt |
186 | } | |
187 | -re ".*$gdb_prompt $" { fail "list list0.c:1" ; gdb_suppress_tests } | |
188 | timeout { fail "list list0.c:1 (timeout)" ; gdb_suppress_tests } | |
189 | } | |
190 | send_gdb "list list0.c:10\n" | |
191 | gdb_expect { | |
192 | -re "5\[ \t\]+int x;.*14\[ \t\]+foo .x\[+)\]+;\r\n$gdb_prompt $" { | |
193 | incr testcnt | |
194 | } | |
195 | -re ".*$gdb_prompt $" { fail "list list.c:10" ; gdb_suppress_tests } | |
196 | timeout { fail "list list.c:10 (timeout)" ; gdb_suppress_tests } | |
197 | } | |
198 | send_gdb "list list1.c:1\n" | |
199 | gdb_expect { | |
085dd6e6 | 200 | -re "1\[ \t\]+\#include.*4\[ \t\]+.*int oof\[ \t\]*\(.*\);\r\n.*$gdb_prompt $" { |
c906108c SS |
201 | incr testcnt |
202 | } | |
203 | -re ".*$gdb_prompt $" { fail "list list1.c:1" ; gdb_suppress_tests } | |
204 | timeout { fail "list list1.c:1 (timeout)" ; gdb_suppress_tests } | |
205 | } | |
206 | send_gdb "list list1.c:12\n" | |
207 | gdb_expect { | |
085dd6e6 | 208 | -re "12\[ \t\]+long_line \[(\]+.*\[)\]+;.*13\[ \t\]+\}\r\n.*$gdb_prompt $" { |
c906108c SS |
209 | incr testcnt |
210 | } | |
211 | -re ".*$gdb_prompt $" { fail "list list1.c:12" ; gdb_suppress_tests } | |
212 | timeout { fail "list list1.c:12 (timeout)" ; gdb_suppress_tests } | |
213 | } | |
214 | pass "list filename:number ($testcnt tests)" | |
215 | gdb_stop_suppressing_tests; | |
216 | } | |
217 | ||
218 | # | |
219 | # Test "list function" for C source file | |
220 | # | |
221 | ||
222 | proc test_list_function {} { | |
223 | global gdb_prompt | |
c906108c SS |
224 | |
225 | # gcc appears to generate incorrect debugging information for code | |
226 | # in include files, which breaks this test. | |
227 | # SunPRO cc is the second case below, it's also correct. | |
d4f3574e | 228 | 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 |
229 | |
230 | # Ultrix gdb takes the second case below; it's also correct. | |
231 | # SunPRO cc is the third case. | |
085dd6e6 | 232 | 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 |
233 | |
234 | # Test "list function" for C include file | |
235 | # Ultrix gdb is the second case, still correct. | |
236 | # SunPRO cc is the third case. | |
c906108c SS |
237 | 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" |
238 | } | |
239 | ||
240 | proc test_list_forward {} { | |
241 | global gdb_prompt | |
242 | ||
243 | set testcnt 0 | |
244 | ||
245 | send_gdb "list list0.c:10\n" | |
246 | gdb_expect { | |
247 | -re "5\[ \t\]+int x;.*14\[ \t\]+foo \[(\]+.*\[)\]+;\r\n$gdb_prompt $" { incr testcnt } | |
248 | -re ".*$gdb_prompt $" { fail "list list0.c:10" ; gdb_suppress_tests } | |
249 | timeout { fail "list list0.c:10 (timeout)" ; gdb_suppress_tests } | |
250 | } | |
251 | ||
252 | send_gdb "list\n" | |
253 | gdb_expect { | |
254 | -re "15\[ \t\]+foo \[(\]+.*\[)\]+;.*24\[ \t\]+foo \[(\]+.*\[)\]+;\r\n$gdb_prompt $" { incr testcnt } | |
255 | -re ".*$gdb_prompt $" { fail "list 15-24" ; gdb_suppress_tests } | |
256 | timeout { fail "list 15-24 (timeout)" ; gdb_suppress_tests } | |
257 | } | |
258 | ||
259 | send_gdb "list\n" | |
260 | gdb_expect { | |
261 | -re "25\[ \t\]+foo \[(\]+.*\[)\]+;.*34\[ \t\]+foo \[(\]+.*\[)\]+;\r\n$gdb_prompt $" { incr testcnt } | |
262 | -re ".*$gdb_prompt $" { fail "list 25-34" ; gdb_suppress_tests } | |
263 | timeout { fail "list 25-34 (timeout)" ; gdb_suppress_tests } | |
264 | } | |
265 | ||
266 | send_gdb "list\n" | |
267 | gdb_expect { | |
085dd6e6 | 268 | -re "35\[ \t\]+foo \\(.*\\);.*42\[ \t\]+.*\}\r\n$gdb_prompt $" { incr testcnt } |
c906108c SS |
269 | -re ".*$gdb_prompt $" { fail "list 35-42" ; gdb_suppress_tests } |
270 | timeout { fail "list 35-42 (timeout)" ; gdb_suppress_tests } | |
271 | } | |
272 | ||
273 | pass "successive list commands to page forward ($testcnt tests)" | |
274 | gdb_stop_suppressing_tests; | |
275 | } | |
276 | ||
a0b3c4fd JM |
277 | # Test that repeating the list linenum command doesn't print the same |
278 | # lines over again. Note that this test makes sure that the argument | |
279 | # linenum is dropped, when we repeat the previous command. 'x/5i $pc' | |
280 | # works the same way. | |
281 | ||
282 | proc test_repeat_list_command {} { | |
283 | global gdb_prompt | |
284 | ||
285 | set testcnt 0 | |
286 | ||
287 | send_gdb "list list0.c:10\n" | |
288 | gdb_expect { | |
289 | -re "5\[ \t\]+int x;.*14\[ \t\]+foo \[(\]+.*\[)\]+;\r\n$gdb_prompt $" { incr testcnt } | |
290 | -re ".*$gdb_prompt $" { fail "list list0.c:10" ; gdb_suppress_tests } | |
291 | timeout { fail "list list0.c:10 (timeout)" ; gdb_suppress_tests } | |
292 | } | |
293 | ||
294 | send_gdb "\n" | |
295 | gdb_expect { | |
296 | -re "15\[ \t\]+foo \[(\]+.*\[)\]+;.*24\[ \t\]+foo \[(\]+.*\[)\]+;\r\n$gdb_prompt $" { incr testcnt } | |
297 | -re ".*$gdb_prompt $" { fail "list 15-24" ; gdb_suppress_tests } | |
298 | timeout { fail "list 15-24 (timeout)" ; gdb_suppress_tests } | |
299 | } | |
300 | ||
301 | send_gdb "\n" | |
302 | gdb_expect { | |
303 | -re "25\[ \t\]+foo \[(\]+.*\[)\]+;.*34\[ \t\]+foo \[(\]+.*\[)\]+;\r\n$gdb_prompt $" { incr testcnt } | |
304 | -re ".*$gdb_prompt $" { fail "list 25-34" ; gdb_suppress_tests } | |
305 | timeout { fail "list 25-34 (timeout)" ; gdb_suppress_tests } | |
306 | } | |
307 | ||
308 | send_gdb "\n" | |
309 | gdb_expect { | |
310 | -re "35\[ \t\]+foo \\(.*\\);.*42\[ \t\]+.*\}\r\n$gdb_prompt $" { incr testcnt } | |
311 | -re ".*$gdb_prompt $" { fail "list 35-42" ; gdb_suppress_tests } | |
312 | timeout { fail "list 35-42 (timeout)" ; gdb_suppress_tests } | |
313 | } | |
314 | ||
315 | pass "repeat list commands to page forward using 'return' ($testcnt tests)" | |
316 | gdb_stop_suppressing_tests; | |
317 | } | |
318 | ||
c906108c SS |
319 | proc test_list_backwards {} { |
320 | global gdb_prompt | |
321 | ||
322 | set testcnt 0 | |
323 | ||
324 | send_gdb "list list0.c:33\n" | |
325 | gdb_expect { | |
085dd6e6 | 326 | -re "28\[ \t\]+foo \\(.*\\);.*37\[ \t\]+\}\r\n$gdb_prompt $" { incr testcnt } |
c906108c SS |
327 | -re ".*$gdb_prompt $" { fail "list list0.c:33" ; gdb_suppress_tests } |
328 | timeout { fail "list list0.c:33 (timeout)" ; gdb_suppress_tests } | |
329 | } | |
330 | ||
331 | send_gdb "list -\n" | |
332 | gdb_expect { | |
333 | -re "18\[ \t\]+foo \[(\]+.*\[)\]+;.*27\[ \t\]+foo \[(\]+.*\[)\]+;\r\n$gdb_prompt $" { incr testcnt } | |
334 | -re ".*$gdb_prompt $" { fail "list 18-27" ; gdb_suppress_tests } | |
335 | timeout { fail "list 18-27 (timeout)" ; gdb_suppress_tests } | |
336 | } | |
337 | ||
338 | send_gdb "list -\n" | |
339 | gdb_expect { | |
340 | -re "8\[ \t\]+breakpoint\[(\]\[)\];.*17\[ \t\]+foo \[(\]+.*\[)\]+;\r\n$gdb_prompt $" { incr testcnt } | |
341 | -re ".*$gdb_prompt $" { fail "list 8-17" ; gdb_suppress_tests } | |
342 | timeout { fail "list 8-17 (timeout)" ; gdb_suppress_tests } | |
343 | } | |
344 | ||
345 | send_gdb "list -\n" | |
346 | gdb_expect { | |
347 | -re "1\[ \t\]+#include .*7\[ \t\]+set_debug_traps\[(\]\[)\]+;\r\n$gdb_prompt $" { incr testcnt } | |
348 | -re ".*$gdb_prompt $" { fail "list 1-7" ; gdb_suppress_tests } | |
349 | timeout { fail "list 1-7 (timeout)" ; gdb_suppress_tests } | |
350 | } | |
351 | ||
352 | pass "$testcnt successive \"list -\" commands to page backwards" | |
353 | gdb_stop_suppressing_tests; | |
354 | } | |
355 | ||
356 | # | |
357 | # Test "list first,last" | |
358 | # | |
359 | ||
360 | proc test_list_range {} { | |
361 | global gdb_prompt | |
362 | ||
085dd6e6 | 363 | 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 | 364 | |
085dd6e6 | 365 | gdb_test "list 2,5" "2\[ \t\]+\r\n3\[ \t\]+int main \[)(\]+.*5\[ \t\]+int x;" "list range; line1,line2" |
c906108c SS |
366 | |
367 | # gdb_test "list -1,6" "Line number 0 out of range; .*list0.c has 39 lines." "list range; lower bound negative" | |
368 | ||
369 | # gdb_test "list -100,-40" "Line number -60 out of range; .*list0.c has 39 lines." "list range; both bounds negative" | |
370 | ||
085dd6e6 | 371 | gdb_test "list 30,45" "30\[ \t\]+foo \(.*\);.*43\[ \t\]+\}" "list range; upper bound past EOF" |
c906108c | 372 | |
085dd6e6 | 373 | gdb_test "list 45,100" "Line number 45 out of range; .*list0.c has 43 lines." "list range; both bounds past EOF" |
c906108c SS |
374 | |
375 | gdb_test "list list0.c:2,list1.c:17" "Specified start and end are in different files." "list range, must be same files" | |
376 | } | |
377 | ||
378 | # | |
379 | # Test "list filename:function" | |
380 | # | |
381 | ||
382 | proc test_list_filename_and_function {} { | |
383 | global gdb_prompt | |
384 | ||
385 | set testcnt 0 | |
386 | ||
387 | # gcc appears to generate incorrect debugging information for code | |
388 | # in include files, which breaks this test. | |
389 | # SunPRO cc is the second case below, it's also correct. | |
c906108c SS |
390 | send_gdb "list list0.c:main\n" |
391 | gdb_expect { | |
d4f3574e | 392 | -re "1\[ \t\]+#include .*10\[ \t\]+x = 0;\r\n$gdb_prompt $" { |
c906108c SS |
393 | incr testcnt |
394 | } | |
395 | -re "5\[ \t\]+int x;.*14\[ \t\]+foo \[(\]+.*\[)\]+;\r\n$gdb_prompt $" { | |
396 | pass "list function in source file 1" | |
397 | } | |
398 | -re ".*$gdb_prompt $" { fail "list list0.c:main" } | |
399 | timeout { fail "list list0.c:main (timeout)" } | |
400 | } | |
401 | ||
c906108c SS |
402 | # Not sure what the point of having this function be unused is. |
403 | # AIX is legitimately removing it. | |
404 | setup_xfail "rs6000-*-aix*" | |
405 | send_gdb "list list0.c:unused\n" | |
406 | gdb_expect { | |
085dd6e6 | 407 | -re "40\[ \t\]+unused.*43\[ \t\]+\}\r\n$gdb_prompt $" { |
c906108c SS |
408 | incr testcnt |
409 | } | |
410 | -re "37.*42\[ \t\]+\}\r\n$gdb_prompt $" { | |
411 | incr testcnt | |
412 | } | |
413 | -re ".*$gdb_prompt $" { fail "list list0.c:unused" } | |
414 | timeout { fail "list list0.c:unused (timeout)" } | |
415 | } | |
416 | clear_xfail "rs6000-*-aix*" | |
417 | ||
418 | # gcc appears to generate incorrect debugging information for code | |
419 | # in include files, which breaks this test. | |
420 | # Ultrix gdb is the second case, one line different but still correct. | |
421 | # SunPRO cc is the third case. | |
422 | setup_xfail "rs6000-*-*" 1804 | |
c906108c SS |
423 | setup_xfail_format "COFF" |
424 | send_gdb "list list0.h:foo\n" | |
425 | gdb_expect { | |
426 | -re "2\[ \t\]+including file. This.*11\[ \t\]+bar \[(\]+.*\[)\]+;\r\n$gdb_prompt $" { | |
427 | incr testcnt | |
428 | } | |
429 | -re "1\[ \t\]+/. An include file.*10\[ \t\]+bar \[(\]+.*\[)\]+;\r\n$gdb_prompt $" { | |
430 | incr testcnt | |
431 | } | |
432 | -re "3\[ \t\]+.*12\[ \t\]+bar \[(\]+.*\[)\]+;\r\n$gdb_prompt $" { | |
433 | incr testcnt | |
434 | } | |
435 | -re "No source file named list0.h.\r\n$gdb_prompt $" { | |
436 | fail "list list0.h:foo" | |
437 | } | |
438 | -re ".*$gdb_prompt $" { fail "list list0.h:foo" } | |
439 | timeout { fail "list list0.h:foo (timeout)" } | |
440 | } | |
441 | ||
442 | # Ultrix gdb is the second case. | |
c906108c SS |
443 | send_gdb "list list1.c:bar\n" |
444 | gdb_expect { | |
085dd6e6 | 445 | -re "4\[ \t\]+void.*13\[ \t\]+\}\r\n$gdb_prompt $" { |
c906108c SS |
446 | incr testcnt |
447 | } | |
085dd6e6 | 448 | -re "4\[ \t\]+void.*12\[ \t\]*long_line ..;\r\n$gdb_prompt $" { |
c906108c SS |
449 | incr testcnt |
450 | } | |
085dd6e6 | 451 | -re "4\[ \t\]+void.*11\[ \t\]*\r\n$gdb_prompt $" { |
c906108c SS |
452 | incr testcnt |
453 | } | |
454 | -re ".*$gdb_prompt $" { fail "list list1.c:bar" } | |
455 | timeout { fail "list list1.c:bar (timeout)" } | |
456 | } | |
457 | ||
c906108c SS |
458 | # Not sure what the point of having this function be unused is. |
459 | # AIX is legitimately removing it. | |
460 | setup_xfail "rs6000-*-aix*" | |
461 | send_gdb "list list1.c:unused\n" | |
462 | gdb_expect { | |
085dd6e6 | 463 | -re "12\[ \t\]+long_line \[(\]\[)\];.*13\[ \t\]+\}\r\n.*$gdb_prompt $" { |
c906108c SS |
464 | incr testcnt |
465 | } | |
085dd6e6 | 466 | -re "14.*19\[ \t\]+\}\r\n.*$gdb_prompt $" { |
c906108c SS |
467 | incr testcnt |
468 | } | |
469 | -re ".*$gdb_prompt $" { fail "list list1.c:unused" } | |
470 | timeout { fail "list list1.c:unused (timeout)" } | |
471 | } | |
472 | clear_xfail "rs6000-*-aix*" | |
473 | ||
474 | pass "list filename:function ($testcnt tests)" | |
475 | ||
476 | # Test some invalid specs | |
477 | # The following test takes the FIXME result on most systems using | |
478 | # DWARF. It fails to notice that main() is not in the file requested. | |
479 | ||
480 | setup_xfail "*-*-*" | |
481 | ||
482 | # Does this actually work ANYWHERE? I believe not, as this is an `aspect' of | |
483 | # lookup_symbol(), where, when it is given a specific symtab which does not | |
484 | # contain the requested symbol, it will subsequently search all of the symtabs | |
485 | # for the requested symbol. | |
486 | ||
487 | gdb_test "list list0.c:foo" "Function \"foo\" not defined in .*list0.c" "list filename:function; wrong filename rejected" | |
488 | ||
085dd6e6 | 489 | gdb_test "list foobar.c:main" "No source file named foobar.c.|Location not found" "list filename:function; nonexistant file" |
c906108c | 490 | |
085dd6e6 | 491 | gdb_test "list list0.h:foobar" "Function \"foobar\" not defined.|Location not found" "list filename:function; nonexistant function" |
c906108c SS |
492 | |
493 | } | |
494 | ||
495 | proc test_forward_search {} { | |
496 | global timeout | |
497 | ||
498 | gdb_test "set listsize 4" "" | |
499 | # On SunOS4, this gives us lines 19-22. On AIX, it gives us | |
500 | # lines 20-23. This depends on whether the line number of a function | |
501 | # is considered to be the openbrace or the first statement--either one | |
502 | # is acceptable. | |
085dd6e6 | 503 | gdb_test "list long_line" "24\[ \t\]+long_line .*" |
c906108c SS |
504 | |
505 | gdb_test "search 4321" " not found" | |
506 | ||
085dd6e6 | 507 | gdb_test "search 6789" "28\[ \t\]+oof .6789.;" |
c906108c SS |
508 | |
509 | # Test that GDB won't crash if the line being searched is extremely long. | |
510 | ||
511 | set oldtimeout $timeout | |
512 | set timeout [expr "$timeout + 300"] | |
513 | verbose "Timeout is now $timeout seconds" 2 | |
514 | gdb_test "search 1234" ".*1234.*" "search extremely long line (> 5000 chars)" | |
515 | set timeout $oldtimeout | |
516 | verbose "Timeout is now $timeout seconds" 2 | |
517 | } | |
518 | ||
519 | # Start with a fresh gdb. | |
520 | ||
521 | gdb_exit | |
522 | gdb_start | |
523 | gdb_reinitialize_dir $srcdir/$subdir | |
524 | gdb_load ${binfile} | |
525 | ||
526 | if [target_info exists gdb_stub] { | |
527 | gdb_step_for_stub; | |
528 | } | |
529 | ||
530 | gdb_test "set width 0" "" "set width 0" | |
531 | ||
532 | test_listsize | |
533 | get_debug_format | |
534 | if [ set_listsize 10 ] then { | |
535 | test_list_include_file | |
536 | test_list_filename_and_number | |
537 | test_list_function | |
538 | test_list_forward | |
539 | test_list_backwards | |
a0b3c4fd | 540 | test_repeat_list_command |
c906108c SS |
541 | test_list_range |
542 | test_list_filename_and_function | |
543 | test_forward_search | |
544 | } | |
085dd6e6 JM |
545 | |
546 | remote_exec build "rm -f list0.h" |