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