Commit | Line | Data |
---|---|---|
0fb0cc75 JB |
1 | # Copyright 2003, 2004, 2005, 2006, 2007, 2008, 2009 |
2 | # Free Software Foundation, Inc. | |
6009d884 AC |
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 |
6009d884 | 7 | # (at your option) any later version. |
e22f8b7c | 8 | # |
6009d884 AC |
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 | # |
6009d884 | 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/>. |
6009d884 | 16 | |
6009d884 AC |
17 | # This file was written by Elena Zannoni (ezannoni@cygnus.com) |
18 | ||
19 | if $tracelevel then { | |
20 | strace $tracelevel | |
21 | } | |
22 | ||
23 | ||
24 | # are we on a target board? If so, don't run these tests. | |
25 | # note: this is necessary because we cannot use runto_main (which would | |
26 | # work for remote targets too) because of the different prompt we get | |
27 | # when using annotation level 2. | |
28 | # | |
29 | if [is_remote target] then { | |
30 | return 0 | |
31 | } | |
32 | ||
33 | ||
34 | # | |
35 | # test running programs | |
36 | # | |
37 | set prms_id 0 | |
38 | set bug_id 0 | |
39 | ||
40 | set testfile "annota3" | |
41 | set srcfile ${testfile}.c | |
1b572db9 | 42 | set binfile ${objdir}/${subdir}/${testfile}$EXEEXT |
6009d884 | 43 | |
fc91c6c2 | 44 | if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug nowarnings}] != "" } { |
b60f0898 JB |
45 | untested annota3.exp |
46 | return -1 | |
6009d884 AC |
47 | } |
48 | ||
49 | ||
50 | gdb_exit | |
51 | gdb_start | |
52 | gdb_reinitialize_dir $srcdir/$subdir | |
53 | gdb_load ${binfile} | |
54 | ||
55 | if [target_info exists gdb_stub] { | |
56 | gdb_step_for_stub; | |
57 | } | |
58 | ||
59 | # | |
60 | # the line at which break main will put the breakpoint | |
61 | # | |
62 | set main_line 32 | |
63 | ||
64 | # The commands we test here produce many lines of output; disable "press | |
65 | # <return> to continue" prompts. | |
66 | send_gdb "set height 0\n" | |
67 | gdb_expect -re "$gdb_prompt $" | |
68 | ||
69 | # | |
70 | # break at main | |
71 | # | |
72 | gdb_test "break main" \ | |
73 | "Breakpoint.*at.* file .*$srcfile, line.*" \ | |
74 | "breakpoint main" | |
75 | ||
76 | ||
77 | # NOTE: this prompt is OK only when the annotation level is > 1 | |
78 | ||
79 | # NOTE: When this prompt is in use the gdb_test procedure cannot be | |
80 | # used because it assumes that the last char after the gdb_prompt is a | |
81 | # white space. This is not true with this annotated prompt. So we must | |
82 | # use send_gdb and gdb_expect or gdb_expect_list. | |
83 | ||
84 | set old_gdb_prompt $gdb_prompt | |
85 | set gdb_prompt "\r\n\032\032pre-prompt\r\n$gdb_prompt \r\n\032\032prompt\r\n" | |
86 | ||
87 | ||
88 | ||
89 | # | |
90 | # set the annotation level to 3 | |
91 | # | |
92 | # of course, this will test: | |
93 | # annotate-pre-prompt | |
94 | # annotate-prompt | |
95 | # annotate-post-prompt (in the next block) | |
96 | # | |
97 | send_gdb "set annotate 3\n" | |
98 | gdb_expect_list "annotation set at level 3" "\r\n$gdb_prompt$" { | |
99 | "set annotate 3" | |
100 | } | |
101 | ||
1b05479a DJ |
102 | # |
103 | # if construct: | |
104 | # | |
105 | send_gdb "if 1\n" | |
106 | gdb_expect { | |
107 | -re "^if 1\r\n\r\n\032\032post-prompt\r\n\r\n\032\032pre-commands\r\n >\r\n\032\032commands\r\n$" { | |
108 | pass "start if construct" | |
109 | } | |
110 | -re ".*\032\032commands\r\n" { | |
111 | fail "start if construct" | |
112 | } | |
113 | timeout { fail "start if construct (timeout)" } | |
114 | } | |
115 | send_gdb "end\n" | |
116 | gdb_expect { | |
117 | -re "^end\r\n\r\n\032\032post-commands\r\n$gdb_prompt$" { | |
118 | pass "end if construct" | |
119 | } | |
120 | -re ".*$gdb_prompt$" { | |
121 | fail "end if construct" | |
122 | } | |
123 | timeout { fail "end if construct (timeout)" } | |
124 | } | |
6009d884 AC |
125 | # |
126 | # info break: | |
127 | # | |
128 | send_gdb "info break\n" | |
129 | gdb_expect_list "breakpoint info" "$gdb_prompt$" { | |
130 | "\r\n\032\032post-prompt\r\n" | |
54e52265 VP |
131 | "Num Type Disp Enb Address +What\r\n" |
132 | "1 breakpoint keep y 0x\[0-9a-zA-Z\]+ +in main at .*annota3.c:32\r\n" | |
6009d884 AC |
133 | } |
134 | ||
135 | ||
136 | # | |
137 | # run to a break point will test: | |
138 | # | |
139 | #exp_internal 1 | |
140 | send_gdb "run\n" | |
141 | gdb_expect_list "run until main breakpoint" "$gdb_prompt$" { | |
142 | "\r\n\032\032post-prompt\r\n" | |
1b572db9 | 143 | "Starting program: .*annota3(|\.exe) \r\n" |
6009d884 | 144 | "\r\n\032\032starting\r\n" |
6009d884 AC |
145 | "\r\n\032\032breakpoint 1\r\n" |
146 | "\r\n" | |
616f635d NR |
147 | "Breakpoint 1, " |
148 | "\r\n\032\032frame-begin 0 0x\[0-9a-z\]+\r\n" | |
149 | "main \\(\\) at .*annota3.c:32\r\n" | |
6009d884 AC |
150 | "\r\n\032\032source.*annota3.c:32:.*:beg:0x\[0-9a-z\]+\r\n" |
151 | "\r\n\032\032stopped\r\n" | |
152 | } | |
153 | #exp_internal 0 | |
154 | #exit 0 | |
155 | ||
156 | # | |
157 | # Let's do a next, to get to a point where the array is initialized | |
158 | # We don't care about the annotated output for this operation, it is the same as | |
159 | # the one produced by run above | |
160 | # | |
161 | send_gdb "next\n" | |
162 | gdb_expect_list "go after array init line" "$gdb_prompt$" { | |
163 | "\r\n\032\032post-prompt\r\n" | |
164 | "\r\n\032\032starting\r\n" | |
6009d884 AC |
165 | "\r\n\032\032source .*annota3.c:\[0-9\]+:\[0-9\]+:beg:0x\[0-9a-z\]+\r\n" |
166 | "\r\n\032\032stopped\r\n" | |
167 | } | |
168 | ||
169 | ||
170 | # | |
171 | # printing the array: | |
172 | # | |
173 | send_gdb "print my_array\n" | |
174 | gdb_expect_list "print array" "$gdb_prompt$" { | |
175 | "\r\n\032\032post-prompt\r\n" | |
176 | ".*= .1, 2, 3.\r\n" | |
177 | } | |
178 | ||
179 | ||
180 | # | |
181 | # this should generate an error message, so to test: | |
182 | # annotate-error-begin | |
183 | # FIXME: annotate-error not tested | |
184 | # | |
185 | ||
186 | #exp_internal 1 | |
187 | send_gdb "print non_existent_value\n" | |
188 | gdb_expect_list "print non_existent_value" "$gdb_prompt$" { | |
189 | "\r\n\032\032post-prompt\r\n" | |
190 | "\r\n\032\032error-begin\r\n" | |
191 | "No symbol \"non_existent_value\" in current context.\r\n" | |
192 | "\r\n\032\032error\r\n" | |
193 | } | |
194 | ||
195 | ||
196 | # | |
197 | # break at signal handler | |
198 | # | |
199 | send_gdb "break handle_USR1\n" | |
200 | gdb_expect_list "breakpoint handle_USR1" "$gdb_prompt$" { | |
201 | "\r\n\032\032post-prompt\r\n" | |
6009d884 AC |
202 | "Breakpoint.*at 0x\[0-9a-z\]+: file.*annota3.c, line.*\r\n" |
203 | } | |
204 | ||
205 | # | |
206 | # break at printf. When we are stopped at printf, we can test | |
207 | # | |
208 | send_gdb "break printf\n" | |
209 | gdb_expect_list "breakpoint printf" "$gdb_prompt$" { | |
210 | "\r\n\032\032post-prompt\r\n" | |
6009d884 AC |
211 | "Breakpoint.*at 0x\[0-9a-z\]+.*" |
212 | } | |
213 | ||
214 | # | |
215 | # get to printf | |
216 | # | |
217 | send_gdb "continue\n" | |
218 | gdb_expect_list "continue to printf" "$gdb_prompt$" { | |
219 | "\r\n\032\032post-prompt\r\n" | |
220 | "Continuing.\r\n" | |
221 | "\r\n\032\032starting\r\n" | |
6009d884 AC |
222 | "\r\n\032\032breakpoint 3\r\n" |
223 | "\r\n" | |
224 | "Breakpoint 3, \[^\r\n\]*\r\n" | |
225 | "\r\n\032\032stopped\r\n" | |
226 | } | |
227 | ||
228 | send_gdb "backtrace\n" | |
229 | gdb_expect_list "backtrace from shlibrary" "$gdb_prompt$" { | |
230 | "\r\n\032\032post-prompt\r\n" | |
e8f97270 | 231 | "#0 .* .*printf(@\[^ ]*)? \[^\r\n\]*\r\n" |
6009d884 AC |
232 | "#1 .* main \[^\r\n\]*\r\n" |
233 | } | |
234 | ||
235 | ||
236 | # | |
237 | # test printing a frame with some arguments: | |
238 | # | |
6009d884 | 239 | |
ab618a02 MC |
240 | if [target_info exists gdb,nosignals] { |
241 | unsupported "send SIGUSR1" | |
242 | unsupported "backtrace @ signal handler" | |
243 | } else { | |
244 | send_gdb "signal SIGUSR1\n" | |
245 | gdb_expect_list "send SIGUSR1" "$gdb_prompt$" { | |
246 | "\r\n\032\032post-prompt\r\n" | |
247 | "Continuing with signal SIGUSR1.\r\n" | |
248 | "\r\n\032\032starting\r\n" | |
ab618a02 | 249 | "\r\n\032\032breakpoint 2\r\n" |
616f635d NR |
250 | "\r\n" |
251 | "Breakpoint 2, " | |
252 | "\r\n\032\032frame-begin 0 0x\[0-9a-z\]+\r\n" | |
253 | "handle_USR1 \\(sig=\[0-9\]+\\) at .*annota3.c:\[0-9\]+\r\n" | |
ab618a02 MC |
254 | "\r\n\032\032source .*annota3.c:\[0-9\]+:\[0-9\]+:beg:0x\[0-9a-z\]+\r\n" |
255 | "\r\n\032\032stopped\r\n" | |
256 | } | |
6009d884 | 257 | |
ab618a02 MC |
258 | # |
259 | # test: | |
260 | # | |
261 | verbose "match_max local is: [match_max]" | |
262 | verbose "match_max default is: [match_max -d]" | |
263 | # This is necessary because a 2000 buffer is not enought to get everything | |
264 | # up to the prompt ad the test gets a timeout. | |
265 | match_max 3000 | |
266 | verbose "match_max now is: [match_max]" | |
267 | send_gdb "backtrace\n" | |
268 | gdb_expect_list "backtrace @ signal handler" "$gdb_prompt$" { | |
269 | "#0 +handle_USR1 \[^\r\n\]+\r\n" | |
270 | "#1 +.signal handler called.\r\n" | |
e8f97270 | 271 | "#2 .* .*printf(@\[^ \]*)? \[^\r\n\]+\r\n" |
ab618a02 MC |
272 | "#3 .* main \[^\r\n\]+\r\n" |
273 | } | |
6009d884 AC |
274 | } |
275 | ||
276 | # | |
277 | # delete all the breakpoints | |
278 | # | |
279 | send_gdb "delete 1\n" | |
280 | gdb_expect_list "delete bp 1" "$gdb_prompt$" { | |
281 | "\r\n\032\032post-prompt\r\n" | |
282 | } | |
283 | ||
284 | send_gdb "delete 2\n" | |
285 | gdb_expect_list "delete bp 2" "$gdb_prompt$" { | |
286 | "\r\n\032\032post-prompt\r\n" | |
287 | } | |
288 | ||
289 | send_gdb "delete 3\n" | |
290 | gdb_expect_list "delete bp 3" "$gdb_prompt$" { | |
291 | "\r\n\032\032post-prompt\r\n" | |
292 | } | |
293 | ||
294 | # | |
295 | # break at main, after value is initialized. This is in preparation | |
296 | # to test the annotate output for the display command. | |
297 | # | |
298 | send_gdb "break main\n" | |
299 | gdb_expect_list "break at 28" "$gdb_prompt$" { | |
300 | "\r\n\032\032post-prompt\r\n" | |
6009d884 AC |
301 | "Breakpoint 4 at 0x\[0-9a-z\]+: file .*annota3.c, line 32.\r\n" |
302 | } | |
303 | ||
304 | # | |
305 | # display the value | |
306 | # | |
307 | send_gdb "display value\n" | |
308 | gdb_expect_list "set up display" "$gdb_prompt$" { | |
309 | "\r\n\032\032post-prompt\r\n" | |
310 | "1: value = 7\r\n" | |
311 | } | |
312 | ||
313 | ||
314 | # should ask query. Test annotate-query. | |
315 | # we don't care about anything else here, only the query. | |
316 | ||
317 | send_gdb "run\n" | |
318 | gdb_expect { | |
319 | -re "pre-query.*already.*\\(y or n\\).*query\r\n" { | |
320 | send_gdb "y\n" | |
321 | gdb_expect { | |
322 | -re ".*post-query.*$gdb_prompt$" \ | |
323 | { pass "re-run" } | |
324 | -re ".*$gdb_prompt$" { fail "re-run" } | |
325 | timeout { fail "re-run (timeout)" } | |
326 | } | |
327 | } | |
328 | -re ".*$gdb_prompt$" { fail "re-run" } | |
329 | timeout { fail "re-run (timeout)" } | |
330 | } | |
331 | ||
332 | # | |
333 | # Test that breakpoints-invalid is issued once and only once for | |
334 | # breakpoint ignore count changes, after annotation stopped. | |
3ca42dbe NR |
335 | # NOTE: breakpoints-invalid annotations have been removed from |
336 | # level 3 but keep these tests for continuity and comparison | |
337 | # with annota1.exp. | |
6009d884 AC |
338 | send_gdb "break 46\n" |
339 | gdb_expect_list "break at 46" "$gdb_prompt$" { | |
340 | "\r\n\032\032post-prompt\r\n" | |
6009d884 AC |
341 | "Breakpoint 5 at 0x\[0-9a-z\]+: file .*annota3.c, line 46.\r\n" |
342 | } | |
343 | ||
344 | send_gdb "ignore 5 4\n" | |
345 | gdb_expect_list "ignore 5 4" "$gdb_prompt$" { | |
346 | "\r\n\032\032post-prompt\r\n" | |
347 | "Will ignore next 4 crossings of breakpoint 5" | |
6009d884 AC |
348 | "\r\n" |
349 | } | |
350 | ||
351 | send_gdb "continue\n" | |
352 | gdb_expect_list "annotate ignore count change" "$gdb_prompt$" { | |
353 | "\r\n\032\032post-prompt\r\n" | |
6009d884 | 354 | "\r\n\032\032breakpoint 5\r\n" |
616f635d NR |
355 | "\r\n" |
356 | "Breakpoint 5, " | |
357 | "\r\n\032\032frame-begin 0 0x\[0-9a-z\]+\r\n" | |
358 | "main \\(\\) at .*annota3.c:46\r\n" | |
6009d884 AC |
359 | "\r\n\032\032source .*annota3.c:46:\[0-9\]+:beg:0x\[0-9a-z\]+\r\n" |
360 | "1: value = 11\r\n" | |
361 | "\r\n\032\032stopped\r\n" | |
6009d884 AC |
362 | } |
363 | ||
364 | # check that ignore command is working, or the above can provide | |
365 | # misleading assurance ... | |
366 | ||
367 | send_gdb "next\n" | |
368 | gdb_expect_list "next to exit loop" "$gdb_prompt$" { | |
369 | "\r\n\032\032post-prompt\r\n" | |
370 | "\r\n\032\032starting\r\n" | |
6009d884 AC |
371 | "\r\n\032\032source.*annota3.c:\[0-9\]+:\[0-9\]+:beg:0x\[0-9a-z\]+\r\n" |
372 | "1: value = 12\r\n" | |
373 | "\r\n\032\032stopped\r\n" | |
374 | } | |
375 | ||
376 | send_gdb "next\n" | |
377 | gdb_expect_list "breakpoint ignore count" "$gdb_prompt$" { | |
378 | "\r\n\032\032post-prompt\r\n" | |
379 | "\r\n\032\032starting\r\n" | |
6009d884 AC |
380 | "\r\n\032\032source.*annota3.c:49:\[0-9\]+:beg:0x\[0-9a-z\]+\r\n" |
381 | "1: value = 12\r\n" | |
382 | "\r\n\032\032stopped\r\n" | |
383 | } | |
384 | ||
385 | # | |
386 | # Send a signal that is not handled | |
387 | # | |
388 | # SIGTRAP signals are dropped before they get to the inferior process | |
389 | # on hpux11. In theory, this behaivor can be controlled by setting | |
390 | # TTEO_NORM_SIGTRAP in the inferior, but doing so did not cause | |
391 | # the signal to be properly delivered. | |
392 | # | |
393 | # It has been verified that other signals will be delivered. However, | |
394 | # rather than twiddle the test, I choose to leave it as-is as it | |
395 | # exposes an interesting failure on hpux11. | |
ab618a02 MC |
396 | |
397 | if [target_info exists gdb,nosignals] { | |
398 | unsupported "signal sent" | |
399 | } else { | |
400 | setup_xfail hppa*-*-hpux11* | |
401 | send_gdb "signal SIGTRAP\n" | |
402 | gdb_expect_list "signal sent" "$gdb_prompt$" { | |
403 | "\r\n\032\032post-prompt\r\n" | |
404 | "Continuing with signal SIGTRAP.\r\n" | |
405 | "\r\n\032\032starting\r\n" | |
ab618a02 MC |
406 | "\r\n\032\032signalled\r\n" |
407 | "\r\nProgram terminated with signal SIGTRAP, Trace.breakpoint trap.\r\n" | |
408 | "The program no longer exists.\r\n" | |
409 | "\r\n\032\032stopped\r\n" | |
410 | } | |
6009d884 AC |
411 | } |
412 | ||
413 | ||
419e626b | 414 | # Check for production of a core file and remove it! |
6009d884 AC |
415 | |
416 | set exec_output [remote_exec build "ls core"] | |
417 | ||
419e626b | 418 | set test "cleanup core file" |
6009d884 | 419 | if [ regexp "core not found" $exec_output] { |
419e626b | 420 | pass "$test (not dumped)" |
6009d884 | 421 | } else { |
419e626b AC |
422 | if [ regexp "No such file or directory" $exec_output] { |
423 | pass "$test (not dumped)" | |
424 | } else { | |
425 | remote_exec build "rm -f core" | |
426 | pass "$test (removed)" | |
427 | } | |
6009d884 AC |
428 | } |
429 | ||
430 | # restore the original prompt for the rest of the testsuite | |
431 | ||
432 | set gdb_prompt $old_gdb_prompt |