]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blob - gdb/testsuite/gdb.c++/ref-types.exp
Initial creation of sourceware repository
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.c++ / ref-types.exp
1 # Copyright (C) 1998 Free Software Foundation, Inc.
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
17 # Please email any bugs, comments, and/or additions to this file to:
18 # bug-gdb@prep.ai.mit.edu
19
20 # written by Elena Zannoni (ezannoni@cygnus.com)
21
22 # This file is part of the gdb testsuite
23 #
24 # tests for reference types
25 # with short type variables.
26 #
27
28 if $tracelevel then {
29 strace $tracelevel
30 }
31
32 #
33 # test running programs
34 #
35 set prms_id 0
36 set bug_id 0
37
38 set testfile "ref-types"
39 set srcfile ${testfile}.cc
40 set binfile ${objdir}/${subdir}/${testfile}
41
42 if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug c++}] != "" } {
43 gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail."
44 }
45
46 gdb_exit
47 gdb_start
48 gdb_reinitialize_dir $srcdir/$subdir
49 gdb_load ${binfile}
50
51
52 #
53 # set it up at a breakpoint so we can play with the variable values
54 #
55 if ![runto_main] then {
56 perror "couldn't run to breakpoint"
57 continue
58 }
59
60 send_gdb "break marker1\n" ; gdb_expect -re ".*$gdb_prompt $"
61
62 send_gdb "cont\n"
63 gdb_expect {
64 -re "Break.* marker1 \\(\\) at .*:$decimal.*$gdb_prompt $" {
65 send_gdb "up\n"
66 gdb_expect {
67 -re ".*$gdb_prompt $" {}
68 timeout { fail "up from marker1" }
69 }
70 }
71 -re "$gdb_prompt $" { fail "continue to marker1" }
72 timeout { fail "(timeout) continue to marker1" }
73 }
74
75
76 proc gdb_start_again {} {
77 global srcdir
78 global subdir
79 global binfile
80 global gdb_prompt
81 global decimal
82
83 gdb_start
84 gdb_reinitialize_dir $srcdir/$subdir
85 gdb_load ${binfile}
86
87 source ${binfile}.ci
88
89 #
90 # set it up at a breakpoint so we can play with the variable values
91 #
92 if ![runto_main] then {
93 perror "couldn't run to breakpoint"
94 continue
95 }
96
97 send_gdb "break marker1\n" ; gdb_expect -re ".*$gdb_prompt $"
98
99 send_gdb "cont\n"
100 gdb_expect {
101 -re "Break.* marker1 \\(\\) at .*:$decimal.*$gdb_prompt $" {
102 send_gdb "up\n"
103 gdb_expect {
104 -re ".*$gdb_prompt $" {}
105 timeout { fail "up from marker1" }
106 }
107 }
108 -re "$gdb_prompt $" { fail "continue to marker1" }
109 timeout { fail "(timeout) continue to marker1" }
110 }
111 }
112
113
114
115
116
117 send_gdb "print s\n"
118 gdb_expect {
119 -re ".\[0-9\]* = -1.*$gdb_prompt $" {
120 pass "print value of s"
121 }
122 -re ".*$gdb_prompt $" { fail "print value of s" }
123 timeout { fail "(timeout) print value of s" }
124 }
125
126
127 send_gdb "ptype s\n"
128 gdb_expect {
129 -re "type = short.*$gdb_prompt $" { pass "ptype s" }
130 -re ".*$gdb_prompt $" { fail "ptype s" }
131 timeout { fail "(timeout) ptype s" }
132 }
133
134
135 send_gdb "print *ps\n"
136 gdb_expect {
137 -re ".\[0-9\]* = -1.*$gdb_prompt $" {
138 pass "print value of ps"
139 }
140 -re ".*$gdb_prompt $" { fail "print value of ps" }
141 timeout { fail "(timeout) print value of ps" }
142 }
143
144
145 send_gdb "ptype ps\n"
146 gdb_expect {
147 -re "type = short \*.*$gdb_prompt $" { pass "ptype ps" }
148 -re ".*$gdb_prompt $" { fail "ptype ps" }
149 timeout { fail "(timeout) ptype ps" }
150 }
151
152 send_gdb "print as\[0\]\n"
153 gdb_expect {
154 -re ".\[0-9\]* = 0.*$gdb_prompt $" {
155 pass "print value of as\[0\]"
156 }
157 -re ".*$gdb_prompt $" { fail "print value of as\[0\]" }
158 timeout { fail "(timeout) print value of as\[0\]" }
159 }
160
161
162 send_gdb "ptype as\n"
163 gdb_expect {
164 -re "type = short \\\[4\\\].*$gdb_prompt $" { pass "ptype as" }
165 -re ".*$gdb_prompt $" { fail "ptype as" }
166 timeout { fail "(timeout) ptype as" }
167 }
168
169 send_gdb "print as\[1\]\n"
170 gdb_expect {
171 -re ".\[0-9\]* = 1.*$gdb_prompt $" {
172 pass "print value of as\[1\]"
173 }
174 -re ".*$gdb_prompt $" { fail "print value of as\[1\]" }
175 timeout { fail "(timeout) print value of as\[1\]" }
176 }
177
178 send_gdb "print as\[2\]\n"
179 gdb_expect {
180 -re ".\[0-9\]* = 2.*$gdb_prompt $" {
181 pass "print value of as\[2\]"
182 }
183 -re ".*$gdb_prompt $" { fail "print value of as\[2\]" }
184 timeout { fail "(timeout) print value of as\[2\]" }
185 }
186
187 send_gdb "print as\[3\]\n"
188 gdb_expect {
189 -re ".\[0-9\]* = 3.*$gdb_prompt $" {
190 pass "print value of as\[3\]"
191 }
192 -re ".*$gdb_prompt $" { fail "print value of as\[3\]" }
193 timeout { fail "(timeout) print value of as\[3\]" }
194 }
195
196 send_gdb "print rs\n"
197 gdb_expect {
198 -re ".\[0-9\]* = \\(short &\\) @$hex: -1.*$gdb_prompt $" {
199 pass "print value of rs"
200 }
201 -re ".*$gdb_prompt $" { fail "print value of rs" }
202 timeout { fail "(timeout) print value of rs" }
203 eof { fail "print rs ($GDB dumped core) (FIXME)" ; gdb_start_again ; }
204
205 }
206
207 send_gdb "ptype rs\n"
208 gdb_expect {
209 -re "type = short &.*$gdb_prompt $" { pass "ptype rs" }
210 -re ".*$gdb_prompt $" { fail "ptype rs" }
211 timeout { fail "(timeout) ptype rs" }
212 }
213
214
215 send_gdb "print *rps\n"
216 gdb_expect {
217 -re ".\[0-9\]* = -1.*$gdb_prompt $" {
218 pass "print value of *rps"
219 }
220 -re ".*$gdb_prompt $" { fail "print value of *rps" }
221 timeout { fail "(timeout) print value of *rps" }
222 }
223
224
225 send_gdb "ptype rps\n"
226 gdb_expect {
227 -re "type = short \\*&.*$gdb_prompt $" { pass "ptype rps" }
228 -re ".*$gdb_prompt $" { fail "ptype rps" }
229 timeout { fail "(timeout) ptype rps" }
230 }
231
232
233
234 send_gdb "print ras\[0\]\n"
235 gdb_expect {
236 -re ".\[0-9\]* = 0.*$gdb_prompt $" {
237 pass "print value of ras\[0\]"
238 }
239 -re ".*$gdb_prompt $" { fail "print value of ras\[0\]" }
240 timeout { fail "(timeout) print value of ras\[0\]" }
241 }
242
243
244 send_gdb "ptype ras\n"
245 gdb_expect {
246 -re "type = short \\\(&\\\)\\\[4\\\].*$gdb_prompt $" { pass "ptype ras" }
247 -re ".*$gdb_prompt $" { fail "ptype ras" }
248 timeout { fail "(timeout) ptype ras" }
249 }
250
251 send_gdb "print ras\[1\]\n"
252 gdb_expect {
253 -re ".\[0-9\]* = 1.*$gdb_prompt $" {
254 pass "print value of ras\[1\]"
255 }
256 -re ".*$gdb_prompt $" { fail "print value of ras\[1\]" }
257 timeout { fail "(timeout) print value of ras\[1\]" }
258 }
259
260 send_gdb "print ras\[2\]\n"
261 gdb_expect {
262 -re ".\[0-9\]* = 2.*$gdb_prompt $" {
263 pass "print value of ras\[2\]"
264 }
265 -re ".*$gdb_prompt $" { fail "print value of ras\[2\]" }
266 timeout { fail "(timeout) print value of ras\[2\]" }
267 }
268
269 send_gdb "print ras\[3\]\n"
270 gdb_expect {
271 -re ".\[0-9\]* = 3.*$gdb_prompt $" {
272 pass "print value of ras\[3\]"
273 }
274 -re ".*$gdb_prompt $" { fail "print value of ras\[3\]" }
275 timeout { fail "(timeout) print value of ras\[3\]" }
276 }