]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blob - gdb/testsuite/gdb.c++/ref-types2.exp
Initial creation of sourceware repository
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.c++ / ref-types2.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 elementary 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-types2"
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 f\n" ; gdb_expect -re ".*$gdb_prompt $"
61
62 send_gdb "cont\n"
63 gdb_expect {
64 -re "Break.* f \\(\\) at .*:$decimal.*$gdb_prompt $" {
65 send_gdb "up\n"
66 gdb_expect {
67 -re ".*$gdb_prompt $" {}
68 timeout { fail "up from f" }
69 }
70 }
71 -re "$gdb_prompt $" { fail "continue to f" }
72 timeout { fail "(timeout) continue to f" }
73 }
74
75
76 send_gdb "print C\n"
77 gdb_expect {
78 -re ".\[0-9\]* = 65 \'A\'.*$gdb_prompt $" {
79 pass "print value of C"
80 }
81 -re ".*$gdb_prompt $" { fail "print value of C" }
82 timeout { fail "(timeout) print value of C" }
83 }
84
85
86 send_gdb "ptype C\n"
87 gdb_expect {
88 -re "type = char.*$gdb_prompt $" { pass "ptype C" }
89 -re ".*$gdb_prompt $" { fail "ptype C" }
90 timeout { fail "(timeout) ptype C" }
91 }
92
93
94 send_gdb "print UC\n"
95 gdb_expect {
96 -re ".\[0-9\]* = 21 '\.025'\.*$gdb_prompt $" {
97 pass "print value of UC"
98 }
99 -re ".*$gdb_prompt $" { fail "print value of UC" }
100 timeout { fail "(timeout) print value of UC" }
101 }
102
103
104 send_gdb "ptype UC\n"
105 gdb_expect {
106 -re "type = unsigned char.*$gdb_prompt $" { pass "ptype UC" }
107 -re ".*$gdb_prompt $" { fail "ptype UC" }
108 timeout { fail "(timeout) ptype UC" }
109 }
110
111
112 send_gdb "print S\n"
113 gdb_expect {
114 -re ".\[0-9\]* = -14.*$gdb_prompt $" {
115 pass "print value of S"
116 }
117 -re ".*$gdb_prompt $" { fail "print value of S" }
118 timeout { fail "(timeout) print value of S" }
119 }
120
121
122 send_gdb "ptype S\n"
123 gdb_expect {
124 -re "type = short.*$gdb_prompt $" { pass "ptype S" }
125 -re ".*$gdb_prompt $" { fail "ptype S" }
126 timeout { fail "(timeout) ptype S" }
127 }
128
129
130 send_gdb "print US\n"
131 gdb_expect {
132 -re ".\[0-9\]* = 7.*$gdb_prompt $" {
133 pass "print value of US"
134 }
135 -re ".*$gdb_prompt $" { fail "print value of US" }
136 timeout { fail "(timeout) print value of US" }
137 }
138
139
140 send_gdb "ptype US\n"
141 gdb_expect {
142 -re "type = unsigned short.*$gdb_prompt $" { pass "ptype US" }
143 -re ".*$gdb_prompt $" { fail "ptype US" }
144 timeout { fail "(timeout) ptype US" }
145 }
146
147
148 send_gdb "print I\n"
149 gdb_expect {
150 -re ".\[0-9\]* = 102.*$gdb_prompt $" {
151 pass "print value of I"
152 }
153 -re ".*$gdb_prompt $" { fail "print value of I" }
154 timeout { fail "(timeout) print value of I" }
155 }
156
157
158 send_gdb "ptype I\n"
159 gdb_expect {
160 -re "type = int.*$gdb_prompt $" { pass "ptype I" }
161 -re ".*$gdb_prompt $" { fail "ptype I" }
162 timeout { fail "(timeout) ptype I" }
163 }
164
165
166 send_gdb "print UI\n"
167 gdb_expect {
168 -re ".\[0-9\]* = 1002.*$gdb_prompt $" {
169 pass "print value of UI"
170 }
171 -re ".*$gdb_prompt $" { fail "print value of UI" }
172 timeout { fail "(timeout) print value of UI" }
173 }
174
175
176 send_gdb "ptype UI\n"
177 gdb_expect {
178 -re "type = unsigned int.*$gdb_prompt $" { pass "ptype UI" }
179 -re ".*$gdb_prompt $" { fail "ptype UI" }
180 timeout { fail "(timeout) ptype UI" }
181 }
182
183
184 send_gdb "print L\n"
185 gdb_expect {
186 -re ".\[0-9\]* = -234.*$gdb_prompt $" {
187 pass "print value of L"
188 }
189 -re ".*$gdb_prompt $" { fail "print value of L" }
190 timeout { fail "(timeout) print value of L" }
191 }
192
193
194 send_gdb "ptype L\n"
195 gdb_expect {
196 -re "type = long.*$gdb_prompt $" { pass "ptype L" }
197 -re ".*$gdb_prompt $" { fail "ptype L" }
198 timeout { fail "(timeout) ptype L" }
199 }
200
201
202 send_gdb "print UL\n"
203 gdb_expect {
204 -re ".\[0-9\]* = 234.*$gdb_prompt $" {
205 pass "print value of UL"
206 }
207 -re ".*$gdb_prompt $" { fail "print value of UL" }
208 timeout { fail "(timeout) print value of UL" }
209 }
210
211
212 send_gdb "ptype UL\n"
213 gdb_expect {
214 -re "type = unsigned long.*$gdb_prompt $" { pass "ptype UL" }
215 -re ".*$gdb_prompt $" { fail "ptype UL" }
216 timeout { fail "(timeout) ptype UL" }
217 }
218
219
220 send_gdb "print F\n"
221 gdb_expect {
222 -re ".\[0-9\]* = 1.2\[0-9\]*e\\+10.*$gdb_prompt $" {
223 pass "print value of F"
224 }
225 -re ".*$gdb_prompt $" { fail "print value of F" }
226 timeout { fail "(timeout) print value of F" }
227 }
228
229
230
231 send_gdb "ptype F\n"
232 gdb_expect {
233 -re "type = float.*$gdb_prompt $" { pass "ptype F" }
234 -re ".*$gdb_prompt $" { fail "ptype F" }
235 timeout { fail "(timeout) ptype F" }
236 }
237
238
239 send_gdb "print D\n"
240 gdb_expect {
241 -re ".\[0-9\]* = -1.375e-123.*$gdb_prompt $" {
242 pass "print value of D"
243 }
244 -re ".*$gdb_prompt $" { fail "print value of D" }
245 timeout { fail "(timeout) print value of D" }
246 }
247
248
249 send_gdb "ptype D\n"
250 gdb_expect {
251 -re "type = double.*$gdb_prompt $" { pass "ptype D" }
252 -re ".*$gdb_prompt $" { fail "ptype D" }
253 timeout { fail "(timeout) ptype D" }
254 }
255
256
257
258 #
259 # test reference types
260 #
261
262
263
264
265 send_gdb "ptype rC\n"
266 gdb_expect {
267 -re "type = char &.*$gdb_prompt $" { pass "ptype rC" }
268 -re ".*$gdb_prompt $" { fail "ptype rC" }
269 timeout { fail "(timeout) ptype rC" }
270 }
271
272
273
274
275 send_gdb "ptype rUC\n"
276 gdb_expect {
277 -re "type = unsigned char &.*$gdb_prompt $" { pass "ptype rUC" }
278 -re ".*$gdb_prompt $" { fail "ptype rUC" }
279 timeout { fail "(timeout) ptype rUC" }
280 }
281
282
283
284 send_gdb "ptype rS\n"
285 gdb_expect {
286 -re "type = short &.*$gdb_prompt $" { pass "ptype rS" }
287 -re ".*$gdb_prompt $" { fail "ptype rS" }
288 timeout { fail "(timeout) ptype rS" }
289 }
290
291
292
293 send_gdb "ptype rUS\n"
294 gdb_expect {
295 -re "type = unsigned short &.*$gdb_prompt $" { pass "ptype rUS" }
296 -re ".*$gdb_prompt $" { fail "ptype rUS" }
297 timeout { fail "(timeout) ptype rUS" }
298 }
299
300
301 send_gdb "ptype rI\n"
302 gdb_expect {
303 -re "type = int &.*$gdb_prompt $" { pass "ptype rI" }
304 -re ".*$gdb_prompt $" { fail "ptype rI" }
305 timeout { fail "(timeout) ptype rI" }
306 }
307
308
309
310 send_gdb "ptype rUI\n"
311 gdb_expect {
312 -re "type = unsigned int &.*$gdb_prompt $" { pass "ptype rUI" }
313 -re ".*$gdb_prompt $" { fail "ptype rUI" }
314 timeout { fail "(timeout) ptype rUI" }
315 }
316
317
318
319 send_gdb "ptype rL\n"
320 gdb_expect {
321 -re "type = long &.*$gdb_prompt $" { pass "ptype rL" }
322 -re ".*$gdb_prompt $" { fail "ptype rL" }
323 timeout { fail "(timeout) ptype rL" }
324 }
325
326
327 send_gdb "ptype rUL\n"
328 gdb_expect {
329 -re "type = unsigned long &.*$gdb_prompt $" { pass "ptype rUL" }
330 -re ".*$gdb_prompt $" { fail "ptype rUL" }
331 timeout { fail "(timeout) ptype rUL" }
332 }
333
334
335 send_gdb "ptype rF\n"
336 gdb_expect {
337 -re "type = float &.*$gdb_prompt $" { pass "ptype rF" }
338 -re ".*$gdb_prompt $" { fail "ptype rF" }
339 timeout { fail "(timeout) ptype rF" }
340 }
341
342
343 send_gdb "ptype rD\n"
344 gdb_expect {
345 -re "type = double &.*$gdb_prompt $" { pass "ptype rD" }
346 -re ".*$gdb_prompt $" { fail "ptype rD" }
347 timeout { fail "(timeout) ptype rD" }
348 }
349
350
351 send_gdb "print rC\n"
352 gdb_expect {
353 -re ".\[0-9\]* = \\(char &\\) @$hex: 65 \'A\'.*$gdb_prompt $" {
354 pass "print value of rC"
355 }
356 -re ".*$gdb_prompt $" { fail "print value of rC" }
357 timeout { fail "(timeout) print value of rC" }
358 }
359
360
361 send_gdb "print rUC\n"
362 gdb_expect {
363 -re ".\[0-9\]* = \\(unsigned char &\\) @$hex: 21 \'.025\'.*$gdb_prompt $" {
364 pass "print value of rUC"
365 }
366 -re ".*$gdb_prompt $" { fail "print value of rUC" }
367 timeout { fail "(timeout) print value of rUC" }
368 }
369
370
371 send_gdb "print rS\n"
372 gdb_expect {
373 -re ".\[0-9\]* = \\(short &\\) @$hex: -14.*$gdb_prompt $" {
374 pass "print value of rS"
375 }
376 -re ".*$gdb_prompt $" { fail "print value of rS" }
377 timeout { fail "(timeout) print value of rS" }
378 }
379
380
381 send_gdb "print rUS\n"
382 gdb_expect {
383 -re ".\[0-9\]* = \\(unsigned short &\\) @$hex: 7.*$gdb_prompt $" {
384 pass "print value of rUS"
385 }
386 -re ".*$gdb_prompt $" { fail "print value of rUS" }
387 timeout { fail "(timeout) print value of rUS" }
388 }
389
390
391 send_gdb "print rI\n"
392 gdb_expect {
393 -re ".\[0-9\]* = \\(int &\\) @$hex: 102.*$gdb_prompt $" {
394 pass "print value of rI"
395 }
396 -re ".*$gdb_prompt $" { fail "print value of rI" }
397 timeout { fail "(timeout) print value of rI" }
398 }
399
400
401 send_gdb "print rUI\n"
402 gdb_expect {
403 -re ".\[0-9\]* = \\(unsigned int &\\) @$hex: 1002.*$gdb_prompt $" {
404 pass "print value of UI"
405 }
406 -re ".*$gdb_prompt $" { fail "print value of rUI" }
407 timeout { fail "(timeout) print value of rUI" }
408 }
409
410
411 send_gdb "print rL\n"
412 gdb_expect {
413 -re ".\[0-9\]* = \\(long &\\) @$hex: -234.*$gdb_prompt $" {
414 pass "print value of rL"
415 }
416 -re ".*$gdb_prompt $" { fail "print value of rL" }
417 timeout { fail "(timeout) print value of rL" }
418 }
419
420
421
422 send_gdb "print rUL\n"
423 gdb_expect {
424 -re ".\[0-9\]* = \\(unsigned long &\\) @$hex: 234.*$gdb_prompt $" {
425 pass "print value of rUL"
426 }
427 -re ".*$gdb_prompt $" { fail "print value of rUL" }
428 timeout { fail "(timeout) print value of rUL" }
429 }
430
431
432 send_gdb "print rF\n"
433 gdb_expect {
434 -re ".\[0-9\]* = \\(float &\\) @$hex: 1.2\[0-9\]*e\\+10.*$gdb_prompt $" {
435 pass "print value of rF"
436 }
437 -re ".*$gdb_prompt $" { fail "print value of rF" }
438 timeout { fail "(timeout) print value of rF" }
439 }
440
441
442 send_gdb "print rD\n"
443 gdb_expect {
444 -re ".\[0-9\]* = \\(double &\\) @$hex: -1.375e-123.*$gdb_prompt $" {
445 pass "print value of rD"
446 }
447 -re ".*$gdb_prompt $" { fail "print value of rD" }
448 timeout { fail "(timeout) print value of rD" }
449 }
450