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