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