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