]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - gdb/testsuite/gdb.cp/annota3.exp
Copyright updates for 2007.
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.cp / annota3.exp
CommitLineData
6aba47ca 1# Copyright 2003, 2004, 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
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
15# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
16
6009d884
AC
17# This file was written by Elena Zannoni (ezannoni@cygnus.com)
18
19if $tracelevel then {
20 strace $tracelevel
21}
22
23
24#
25# test running programs
26#
27set prms_id 0
28set bug_id 0
29
30if { [skip_cplus_tests] } { continue }
31
32set testfile "annota3"
33set srcfile ${testfile}.cc
34set binfile ${objdir}/${subdir}/${testfile}
35
fc91c6c2 36if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug c++ nowarnings}] != "" } {
b60f0898
JB
37 untested annota3.exp
38 return -1
6009d884
AC
39}
40
41# are we on a target board? If so, don't run these tests.
42# note: this is necessary because we cannot use runto_main (which would
43# work for remote targets too) because of the different prompt we get
44# when using annotation level 2.
45#
46if [is_remote target] then {
47 return 0
48}
49
50
51gdb_exit
52gdb_start
53gdb_reinitialize_dir $srcdir/$subdir
54gdb_load ${binfile}
55
56if [target_info exists gdb_stub] {
57 gdb_step_for_stub;
58}
59
60#
61# line number where we need to stop in main
62#
63set main_line 25
64
65# The commands we test here produce many lines of output; disable "press
66# <return> to continue" prompts.
67send_gdb "set height 0\n"
68gdb_expect -re "$gdb_prompt $"
69
70#
71# break at main
72#
73gdb_test "break 25" \
74 "Breakpoint.*at.* file .*$srcfile, line.*" \
75 "breakpoint main"
76
77
78#
79# NOTE: this prompt is OK only when the annotation level is > 1
80# NOTE: When this prompt is in use the gdb_test procedure cannot be used because
81# it assumes that the last char of the gdb_prompt is a white space. This is not
82# true with this annotated prompt. So we must use send_gdb and gdb_expect.
83#
84
85set old_gdb_prompt $gdb_prompt
86set gdb_prompt "\r\n\032\032pre-prompt\r\n$gdb_prompt \r\n\032\032prompt\r\n"
87
88send_gdb "set annotate 3\n"
89gdb_expect_list "annotation set at level 3" "\r\n$gdb_prompt$" {
90 "set annotate 3"
91}
92
93send_gdb "run\n"
94gdb_expect_list "first run until main breakpoint" "$gdb_prompt$" {
95 "\r\n\032\032post-prompt\r\n"
96 "Starting program: .*annota3 \r\n"
6009d884 97 "\r\n\032\032starting\r\n"
6009d884
AC
98 "\r\n\032\032breakpoint 1\r\n"
99 "\r\n"
616f635d
NR
100 "Breakpoint 1, "
101 "\r\n\032\032frame-begin 0 0x\[0-9a-z\]+\r\n"
102 "main \\(\\) at .*annota3.cc:25\r\n"
6009d884
AC
103 "\r\n\032\032source.*annota3.cc:25:.*:beg:0x\[0-9a-z\]+\r\n"
104 "\r\n\032\032stopped\r\n"
105}
106
107#
108# print class 'a' with public fields.
109#
110send_gdb "print a\n"
111gdb_expect_list "print class" "$gdb_prompt$" {
112 "\r\n\032\032post-prompt\r\n"
113 ".*= \\{x = 1, y = 2\\}\r\n"
114}
115
116#
117# continue until exit
118# this will test:
119# annotate-exited
120#
121send_gdb "continue\n"
122gdb_expect_list "continue to exit" "$gdb_prompt$" {
123 "\r\n\032\032post-prompt\r\n"
124 "Continuing.\r\n"
125 "\r\n\032\032starting\r\n"
6009d884 126 "a.x is 1\r\n"
6009d884
AC
127 "\r\n\032\032exited 0\r\n"
128 "\r\n"
129 "Program exited normally.\r\n"
6009d884
AC
130 "\r\n\032\032stopped\r\n"
131}
132
133#
134# delete all breakpoints
135#
136send_gdb "delete\n"
137gdb_expect {
138 -re ".*Delete all breakpoints. \\(y or n\\) \r\n\032\032query.*$" {
139 send_gdb "y\n"
140 gdb_expect {
141 -re "\r\n\032\032post-query\r\n$gdb_prompt$" { pass "delete bps" }
142 -re ".*$gdb_prompt$" { fail "delete bps" }
143 timeout { fail "delete bps (timeout)" }
144 }
145 }
146 -re ".*$gdb_prompt$" { fail "delete bps" }
147 timeout { fail "delete bps (timeout)" }
148}
149
150#
151# break at first line of main.
152#
153send_gdb "break 22\n"
154gdb_expect_list "break at main" "$gdb_prompt$" {
155 "\r\n\032\032post-prompt\r\n"
6009d884
AC
156 "Breakpoint.*at 0x\[a-z0-9\]+: file.*annota3.cc, line 22.\r\n"
157}
158
159#
160# run program up to breakpoint.
161#
162
163
164send_gdb "run\n"
165gdb_expect_list "second run until main breakpoint" "$gdb_prompt$" {
166 "\r\n\032\032post-prompt\r\n"
6009d884 167 "\r\n\032\032starting\r\n"
6009d884
AC
168 "\r\n\032\032breakpoint 2\r\n"
169 "\r\n"
616f635d
NR
170 "Breakpoint 2, "
171 "\r\n\032\032frame-begin 0 0x\[0-9a-z\]+\r\n"
172 "main \\(\\) at .*annota3.cc:22\r\n"
6009d884
AC
173 "\r\n\032\032source.*annota3.cc:22:.*:beg:0x\[0-9a-z\]+\r\n"
174 "\r\n\032\032stopped\r\n"
175}
176
177#
178# set up a watch point on a.x
179#
180send_gdb "watch a.x\n"
181gdb_expect_list "set watch on a.x" "$gdb_prompt$" {
182 "\r\n\032\032post-prompt\r\n"
6009d884
AC
183 ".*atchpoint 3: a.x\r\n" \
184}
185
186#
187# do a next, so that the watchpoint triggers. This will test:
188# annotate-watchpoint
189#
190send_gdb "next\n"
191gdb_expect {
3ca42dbe 192 -re "\r\n\032\032post-prompt\r\n\r\n\032\032starting\r\n\r\n\032\032watchpoint 3\r\n.*atchpoint 3: a.x\r\n\r\nOld value = 0\r\nNew value = 1\r\nmain \\(\\) at .*$srcfile:$decimal\r\n\r\n\032\032source .*$srcfile.*beg:$hex\r\n\r\n\032\032stopped\r\n.*$gdb_prompt$" {
6009d884
AC
193 pass "watch triggered on a.x"
194 }
3ca42dbe 195 -re "\r\n\032\032post-prompt\r\n\r\n\032\032starting\r\n\r\n\032\032source .*$srcfile.*beg:$hex\r\n\r\n\032\032stopped\r\n$gdb_prompt$" {
6009d884
AC
196 kfail "gdb/38" "watch triggered on a.x"
197 }
198 -re ".*$gdb_prompt$" {
199 fail "watch triggered on a.x"
200 }
201 timeout {
202 fail "watch triggered on a.x (timeout)"
203 }
204}
205
206#
207# send ^C to gdb, so that the quit() function gets called
208# and annotate-quit is tested
209# test:
210# annotate-quit
211#
212# This test sometimes fails, but not reproducibly. See gdb/544.
213#
214send_gdb "\003"
215gdb_expect_list "annotate-quit" "$gdb_prompt$" {
216 "\r\n\032\032error-begin\r\n"
217 "Quit\r\n"
218 "\r\n\032\032quit\r\n"
219}
220
221#
222# FIXME: the testsuite does not currently have tests for
223# annotate_catchpoints and annotate_function_call
224# and a few variants of the annotations that are
225# tested (marked by FIXME on the annot?.exp files)
226#
227
228# reinstall the old prompt for the rest of the testsuite.
229
230set gdb_prompt $old_gdb_prompt
231