1 # Copyright
2003, 2004 Free Software Foundation
, Inc.
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.
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.
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
15 # Foundation
, Inc.
, 59 Temple Place
- Suite
330, Boston
, MA
02111-1307, USA.
17 # This file was written by Elena Zannoni
(ezannoni@cygnus.com
)
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.
29 if [is_remote target] then {
35 # test running programs
40 set testfile "annota3"
41 set srcfile ${testfile}.c
42 set binfile ${objdir}/${subdir}/${testfile}
44 if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug nowarnings}] != "" } {
45 gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail."
51 gdb_reinitialize_dir $srcdir/$subdir
54 if [target_info exists gdb_stub] {
59 # the line at which break main will put the breakpoint
63 # The commands we test here produce many lines of output; disable "press
64 # <return> to continue" prompts.
65 send_gdb "set height 0\n"
66 gdb_expect -re "$gdb_prompt $"
71 gdb_test "break main" \
72 "Breakpoint.*at.* file .*$srcfile, line.*" \
76 # NOTE: this prompt is OK only when the annotation level is > 1
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.
83 set old_gdb_prompt $gdb_prompt
84 set gdb_prompt "\r\n\032\032pre-prompt\r\n$gdb_prompt \r\n\032\032prompt\r\n"
89 # set the annotation level to 3
91 # of course, this will test:
94 # annotate-post-prompt (in the next block)
96 send_gdb "set annotate 3\n"
97 gdb_expect_list "annotation set at level 3" "\r\n$gdb_prompt$" {
105 send_gdb "info break\n"
106 gdb_expect_list "breakpoint info" "$gdb_prompt$" {
107 "\r\n\032\032post-prompt\r\n"
108 "Num Type Disp Enb Address +What\r\n"
109 "1 breakpoint keep y 0x\[0-9a-zA-Z\]+ +in main at .*annota3.c:32\r\n"
114 # run to a break point will test:
118 gdb_expect_list "run until main breakpoint" "$gdb_prompt$" {
119 "\r\n\032\032post-prompt\r\n"
120 "Starting program: .*annota3 \r\n"
121 "\r\n\032\032starting\r\n"
122 "\r\n\032\032breakpoint 1\r\n"
124 "Breakpoint 1, main \\(\\) at .*annota3.c:32\r\n"
125 "\r\n\032\032source.*annota3.c:32:.*:beg:0x\[0-9a-z\]+\r\n"
126 "\r\n\032\032stopped\r\n"
132 # Let's
do a next
, to
get to a point where the array is initialized
133 # We don
't care about the annotated output for this operation, it is the same as
134 # the one produced by run above
137 gdb_expect_list "go after array init line" "$gdb_prompt$" {
138 "\r\n\032\032post-prompt\r\n"
139 "\r\n\032\032starting\r\n"
140 "\r\n\032\032source .*annota3.c:\[0-9\]+:\[0-9\]+:beg:0x\[0-9a-z\]+\r\n"
141 "\r\n\032\032stopped\r\n"
146 # printing the array:
148 send_gdb "print my_array\n"
149 gdb_expect_list "print array" "$gdb_prompt$" {
150 "\r\n\032\032post-prompt\r\n"
156 # this should generate an error message, so to test:
157 # annotate-error-begin
158 # FIXME: annotate-error not tested
162 send_gdb "print non_existent_value\n"
163 gdb_expect_list "print non_existent_value" "$gdb_prompt$" {
164 "\r\n\032\032post-prompt\r\n"
165 "\r\n\032\032error-begin\r\n"
166 "No symbol \"non_existent_value\" in current context.\r\n"
167 "\r\n\032\032error\r\n"
172 # break at signal handler
174 send_gdb "break handle_USR1\n"
175 gdb_expect_list "breakpoint handle_USR1" "$gdb_prompt$" {
176 "\r\n\032\032post-prompt\r\n"
177 "Breakpoint.*at 0x\[0-9a-z\]+: file.*annota3.c, line.*\r\n"
181 # break at printf. When we are stopped at printf, we can test
183 send_gdb "break printf\n"
184 gdb_expect_list "breakpoint printf" "$gdb_prompt$" {
185 "\r\n\032\032post-prompt\r\n"
186 "Breakpoint.*at 0x\[0-9a-z\]+.*"
192 send_gdb "continue\n"
193 gdb_expect_list "continue to printf" "$gdb_prompt$" {
194 "\r\n\032\032post-prompt\r\n"
196 "\r\n\032\032starting\r\n"
197 "\r\n\032\032breakpoint 3\r\n"
199 "Breakpoint 3, \[^\r\n\]*\r\n"
200 "\r\n\032\032stopped\r\n"
203 send_gdb "backtrace\n"
204 gdb_expect_list "backtrace from shlibrary" "$gdb_prompt$" {
205 "\r\n\032\032post-prompt\r\n"
206 "#0 .* printf \[^\r\n\]*\r\n"
207 "#1 .* main \[^\r\n\]*\r\n"
212 # test printing a frame with some arguments:
215 if [target_info exists gdb,nosignals] {
216 unsupported "send SIGUSR1"
217 unsupported "backtrace @ signal handler"
219 send_gdb "signal SIGUSR1\n"
220 gdb_expect_list "send SIGUSR1" "$gdb_prompt$" {
221 "\r\n\032\032post-prompt\r\n"
222 "Continuing with signal SIGUSR1.\r\n"
223 "\r\n\032\032starting\r\n"
224 "\r\n\032\032breakpoint 2\r\n"
225 "Breakpoint 2, handle_USR1 \\(sig=\[0-9\]+\\) at .*annota3.c:\[0-9\]+\r\n"
226 "\r\n\032\032source .*annota3.c:\[0-9\]+:\[0-9\]+:beg:0x\[0-9a-z\]+\r\n"
227 "\r\n\032\032stopped\r\n"
233 verbose "match_max local is: [match_max]"
234 verbose "match_max default is: [match_max -d]"
235 # This is necessary because a 2000 buffer is not enought to get everything
236 # up to the prompt ad the test gets a timeout.
238 verbose "match_max now is: [match_max]"
239 send_gdb "backtrace\n"
240 gdb_expect_list "backtrace @ signal handler" "$gdb_prompt$" {
241 "#0 +handle_USR1 \[^\r\n\]+\r\n"
242 "#1 +.signal handler called.\r\n"
243 "#2 .* printf \[^\r\n\]+\r\n"
244 "#3 .* main \[^\r\n\]+\r\n"
249 # delete all the breakpoints
251 send_gdb "delete 1\n"
252 gdb_expect_list "delete bp 1" "$gdb_prompt$" {
253 "\r\n\032\032post-prompt\r\n"
256 send_gdb "delete 2\n"
257 gdb_expect_list "delete bp 2" "$gdb_prompt$" {
258 "\r\n\032\032post-prompt\r\n"
261 send_gdb "delete 3\n"
262 gdb_expect_list "delete bp 3" "$gdb_prompt$" {
263 "\r\n\032\032post-prompt\r\n"
267 # break at main, after value is initialized. This is in preparation
268 # to test the annotate output for the display command.
270 send_gdb "break main\n"
271 gdb_expect_list "break at 28" "$gdb_prompt$" {
272 "\r\n\032\032post-prompt\r\n"
273 "Breakpoint 4 at 0x\[0-9a-z\]+: file .*annota3.c, line 32.\r\n"
279 send_gdb "display value\n"
280 gdb_expect_list "set up display" "$gdb_prompt$" {
281 "\r\n\032\032post-prompt\r\n"
286 # should ask query. Test annotate-query.
287 # we don't care about anything
else here
, only the query.
291 -re
"pre-query.*already.*\\(y or n\\).*query\r\n" {
294 -re
".*post-query.*$gdb_prompt$" \
296 -re
".*$gdb_prompt$" { fail "re-run" }
297 timeout
{ fail
"re-run (timeout)" }
300 -re
".*$gdb_prompt$" { fail "re-run" }
301 timeout
{ fail
"re-run (timeout)" }
305 # Test that breakpoints
-invalid is issued once and only once
for
306 # breakpoint ignore
count changes
, after annotation stopped.
307 # NOTE
: breakpoints
-invalid annotations have been removed from
308 # level
3 but keep these tests
for continuity and comparison
310 send_gdb
"break 46\n"
311 gdb_expect_list
"break at 46" "$gdb_prompt$" {
312 "\r\n\032\032post-prompt\r\n"
313 "Breakpoint 5 at 0x\[0-9a-z\]+: file .*annota3.c, line 46.\r\n"
316 send_gdb
"ignore 5 4\n"
317 gdb_expect_list
"ignore 5 4" "$gdb_prompt$" {
318 "\r\n\032\032post-prompt\r\n"
319 "Will ignore next 4 crossings of breakpoint 5"
323 send_gdb
"continue\n"
324 gdb_expect_list
"annotate ignore count change" "$gdb_prompt$" {
325 "\r\n\032\032post-prompt\r\n"
326 "\r\n\032\032breakpoint 5\r\n"
327 "Breakpoint 5, main \\(\\) at .*annota3.c:46\r\n"
328 "\r\n\032\032source .*annota3.c:46:\[0-9\]+:beg:0x\[0-9a-z\]+\r\n"
330 "\r\n\032\032stopped\r\n"
333 # check that ignore command is working
, or the above can provide
334 # misleading assurance ...
337 gdb_expect_list
"next to exit loop" "$gdb_prompt$" {
338 "\r\n\032\032post-prompt\r\n"
339 "\r\n\032\032starting\r\n"
340 "\r\n\032\032source.*annota3.c:\[0-9\]+:\[0-9\]+:beg:0x\[0-9a-z\]+\r\n"
342 "\r\n\032\032stopped\r\n"
346 gdb_expect_list
"breakpoint ignore count" "$gdb_prompt$" {
347 "\r\n\032\032post-prompt\r\n"
348 "\r\n\032\032starting\r\n"
349 "\r\n\032\032source.*annota3.c:49:\[0-9\]+:beg:0x\[0-9a-z\]+\r\n"
351 "\r\n\032\032stopped\r\n"
355 # Send a
signal that is not handled
357 # SIGTRAP signals are dropped before they
get to the inferior process
358 #
on hpux11. In theory
, this behaivor can be controlled by setting
359 # TTEO_NORM_SIGTRAP in the inferior
, but doing so did not cause
360 # the
signal to be properly delivered.
362 # It has been verified that other signals will be delivered. However
,
363 # rather than twiddle the test
, I choose to leave it as
-is as it
364 # exposes an interesting failure
on hpux11.
366 if [target_info
exists gdb
,nosignals
] {
367 unsupported
"signal sent"
369 setup_xfail hppa
*-*-hpux11
*
370 send_gdb
"signal SIGTRAP\n"
371 gdb_expect_list
"signal sent" "$gdb_prompt$" {
372 "\r\n\032\032post-prompt\r\n"
373 "Continuing with signal SIGTRAP.\r\n"
374 "\r\n\032\032starting\r\n"
375 "\r\n\032\032signalled\r\n"
376 "\r\nProgram terminated with signal SIGTRAP, Trace.breakpoint trap.\r\n"
377 "The program no longer exists.\r\n"
378 "\r\n\032\032stopped\r\n"
383 # Check
for production of a core file and remove it
!
385 set exec_output
[remote_exec build
"ls core"]
387 set test
"cleanup core file"
388 if [ regexp
"core not found" $exec_output] {
389 pass
"$test (not dumped)"
391 if [ regexp
"No such file or directory" $exec_output] {
392 pass
"$test (not dumped)"
394 remote_exec build
"rm -f core"
395 pass
"$test (removed)"
399 # restore the original prompt
for the rest of the testsuite
401 set gdb_prompt $old_gdb_prompt