1 # Copyright (C) 1998 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 # Please email any bugs, comments, and/or additions to this file to:
18 # bug-gdb@prep.ai.mit.edu
20 # written by Elena Zannoni (ezannoni@cygnus.com)
22 # This file is part of the gdb testsuite
24 # tests for reference types
25 # with elementary type variables.
33 # test running programs
38 set testfile "ref-types2"
39 set srcfile ${testfile}.cc
40 set binfile ${objdir}/${subdir}/${testfile}
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."
48 gdb_reinitialize_dir $srcdir/$subdir
53 # set it up at a breakpoint so we can play with the variable values
55 if ![runto_main] then {
56 perror "couldn't run to breakpoint"
60 send_gdb "break f\n" ; gdb_expect -re ".*$gdb_prompt $"
64 -re "Break.* f \\(\\) at .*:$decimal.*$gdb_prompt $" {
67 -re ".*$gdb_prompt $" {}
68 timeout { fail "up from f" }
71 -re "$gdb_prompt $" { fail "continue to f" }
72 timeout { fail "(timeout) continue to f" }
78 -re ".\[0-9\]* = 65 \'A\'.*$gdb_prompt $" {
79 pass "print value of C"
81 -re ".*$gdb_prompt $" { fail "print value of C" }
82 timeout { fail "(timeout) print value of C" }
88 -re "type = char.*$gdb_prompt $" { pass "ptype C" }
89 -re ".*$gdb_prompt $" { fail "ptype C" }
90 timeout { fail "(timeout) ptype C" }
96 -re ".\[0-9\]* = 21 '\.025'\.*$gdb_prompt $" {
97 pass "print value of UC"
99 -re ".*$gdb_prompt $" { fail "print value of UC" }
100 timeout { fail "(timeout) print value of UC" }
104 send_gdb "ptype UC\n"
106 -re "type = unsigned char.*$gdb_prompt $" { pass "ptype UC" }
107 -re ".*$gdb_prompt $" { fail "ptype UC" }
108 timeout { fail "(timeout) ptype UC" }
114 -re ".\[0-9\]* = -14.*$gdb_prompt $" {
115 pass "print value of S"
117 -re ".*$gdb_prompt $" { fail "print value of S" }
118 timeout { fail "(timeout) print value of S" }
124 -re "type = short.*$gdb_prompt $" { pass "ptype S" }
125 -re ".*$gdb_prompt $" { fail "ptype S" }
126 timeout { fail "(timeout) ptype S" }
130 send_gdb "print US\n"
132 -re ".\[0-9\]* = 7.*$gdb_prompt $" {
133 pass "print value of US"
135 -re ".*$gdb_prompt $" { fail "print value of US" }
136 timeout { fail "(timeout) print value of US" }
140 send_gdb "ptype US\n"
142 -re "type = unsigned short.*$gdb_prompt $" { pass "ptype US" }
143 -re ".*$gdb_prompt $" { fail "ptype US" }
144 timeout { fail "(timeout) ptype US" }
150 -re ".\[0-9\]* = 102.*$gdb_prompt $" {
151 pass "print value of I"
153 -re ".*$gdb_prompt $" { fail "print value of I" }
154 timeout { fail "(timeout) print value of I" }
160 -re "type = int.*$gdb_prompt $" { pass "ptype I" }
161 -re ".*$gdb_prompt $" { fail "ptype I" }
162 timeout { fail "(timeout) ptype I" }
166 send_gdb "print UI\n"
168 -re ".\[0-9\]* = 1002.*$gdb_prompt $" {
169 pass "print value of UI"
171 -re ".*$gdb_prompt $" { fail "print value of UI" }
172 timeout { fail "(timeout) print value of UI" }
176 send_gdb "ptype UI\n"
178 -re "type = unsigned int.*$gdb_prompt $" { pass "ptype UI" }
179 -re ".*$gdb_prompt $" { fail "ptype UI" }
180 timeout { fail "(timeout) ptype UI" }
186 -re ".\[0-9\]* = -234.*$gdb_prompt $" {
187 pass "print value of L"
189 -re ".*$gdb_prompt $" { fail "print value of L" }
190 timeout { fail "(timeout) print value of L" }
196 -re "type = long.*$gdb_prompt $" { pass "ptype L" }
197 -re ".*$gdb_prompt $" { fail "ptype L" }
198 timeout { fail "(timeout) ptype L" }
202 send_gdb "print UL\n"
204 -re ".\[0-9\]* = 234.*$gdb_prompt $" {
205 pass "print value of UL"
207 -re ".*$gdb_prompt $" { fail "print value of UL" }
208 timeout { fail "(timeout) print value of UL" }
212 send_gdb "ptype UL\n"
214 -re "type = unsigned long.*$gdb_prompt $" { pass "ptype UL" }
215 -re ".*$gdb_prompt $" { fail "ptype UL" }
216 timeout { fail "(timeout) ptype UL" }
222 -re ".\[0-9\]* = 1.2\[0-9\]*e\\+10.*$gdb_prompt $" {
223 pass "print value of F"
225 -re ".*$gdb_prompt $" { fail "print value of F" }
226 timeout { fail "(timeout) print value of F" }
233 -re "type = float.*$gdb_prompt $" { pass "ptype F" }
234 -re ".*$gdb_prompt $" { fail "ptype F" }
235 timeout { fail "(timeout) ptype F" }
241 -re ".\[0-9\]* = -1.375e-123.*$gdb_prompt $" {
242 pass "print value of D"
244 -re ".*$gdb_prompt $" { fail "print value of D" }
245 timeout { fail "(timeout) print value of D" }
251 -re "type = double.*$gdb_prompt $" { pass "ptype D" }
252 -re ".*$gdb_prompt $" { fail "ptype D" }
253 timeout { fail "(timeout) ptype D" }
259 # test reference types
265 send_gdb "ptype rC\n"
267 -re "type = char &.*$gdb_prompt $" { pass "ptype rC" }
268 -re ".*$gdb_prompt $" { fail "ptype rC" }
269 timeout { fail "(timeout) ptype rC" }
275 send_gdb "ptype rUC\n"
277 -re "type = unsigned char &.*$gdb_prompt $" { pass "ptype rUC" }
278 -re ".*$gdb_prompt $" { fail "ptype rUC" }
279 timeout { fail "(timeout) ptype rUC" }
284 send_gdb "ptype rS\n"
286 -re "type = short &.*$gdb_prompt $" { pass "ptype rS" }
287 -re ".*$gdb_prompt $" { fail "ptype rS" }
288 timeout { fail "(timeout) ptype rS" }
293 send_gdb "ptype rUS\n"
295 -re "type = unsigned short &.*$gdb_prompt $" { pass "ptype rUS" }
296 -re ".*$gdb_prompt $" { fail "ptype rUS" }
297 timeout { fail "(timeout) ptype rUS" }
301 send_gdb "ptype rI\n"
303 -re "type = int &.*$gdb_prompt $" { pass "ptype rI" }
304 -re ".*$gdb_prompt $" { fail "ptype rI" }
305 timeout { fail "(timeout) ptype rI" }
310 send_gdb "ptype rUI\n"
312 -re "type = unsigned int &.*$gdb_prompt $" { pass "ptype rUI" }
313 -re ".*$gdb_prompt $" { fail "ptype rUI" }
314 timeout { fail "(timeout) ptype rUI" }
319 send_gdb "ptype rL\n"
321 -re "type = long &.*$gdb_prompt $" { pass "ptype rL" }
322 -re ".*$gdb_prompt $" { fail "ptype rL" }
323 timeout { fail "(timeout) ptype rL" }
327 send_gdb "ptype rUL\n"
329 -re "type = unsigned long &.*$gdb_prompt $" { pass "ptype rUL" }
330 -re ".*$gdb_prompt $" { fail "ptype rUL" }
331 timeout { fail "(timeout) ptype rUL" }
335 send_gdb "ptype rF\n"
337 -re "type = float &.*$gdb_prompt $" { pass "ptype rF" }
338 -re ".*$gdb_prompt $" { fail "ptype rF" }
339 timeout { fail "(timeout) ptype rF" }
343 send_gdb "ptype rD\n"
345 -re "type = double &.*$gdb_prompt $" { pass "ptype rD" }
346 -re ".*$gdb_prompt $" { fail "ptype rD" }
347 timeout { fail "(timeout) ptype rD" }
351 send_gdb "print rC\n"
353 -re ".\[0-9\]* = \\(char &\\) @$hex: 65 \'A\'.*$gdb_prompt $" {
354 pass "print value of rC"
356 -re ".*$gdb_prompt $" { fail "print value of rC" }
357 timeout { fail "(timeout) print value of rC" }
361 send_gdb "print rUC\n"
363 -re ".\[0-9\]* = \\(unsigned char &\\) @$hex: 21 \'.025\'.*$gdb_prompt $" {
364 pass "print value of rUC"
366 -re ".*$gdb_prompt $" { fail "print value of rUC" }
367 timeout { fail "(timeout) print value of rUC" }
371 send_gdb "print rS\n"
373 -re ".\[0-9\]* = \\(short &\\) @$hex: -14.*$gdb_prompt $" {
374 pass "print value of rS"
376 -re ".*$gdb_prompt $" { fail "print value of rS" }
377 timeout { fail "(timeout) print value of rS" }
381 send_gdb "print rUS\n"
383 -re ".\[0-9\]* = \\(unsigned short &\\) @$hex: 7.*$gdb_prompt $" {
384 pass "print value of rUS"
386 -re ".*$gdb_prompt $" { fail "print value of rUS" }
387 timeout { fail "(timeout) print value of rUS" }
391 send_gdb "print rI\n"
393 -re ".\[0-9\]* = \\(int &\\) @$hex: 102.*$gdb_prompt $" {
394 pass "print value of rI"
396 -re ".*$gdb_prompt $" { fail "print value of rI" }
397 timeout { fail "(timeout) print value of rI" }
401 send_gdb "print rUI\n"
403 -re ".\[0-9\]* = \\(unsigned int &\\) @$hex: 1002.*$gdb_prompt $" {
404 pass "print value of UI"
406 -re ".*$gdb_prompt $" { fail "print value of rUI" }
407 timeout { fail "(timeout) print value of rUI" }
411 send_gdb "print rL\n"
413 -re ".\[0-9\]* = \\(long &\\) @$hex: -234.*$gdb_prompt $" {
414 pass "print value of rL"
416 -re ".*$gdb_prompt $" { fail "print value of rL" }
417 timeout { fail "(timeout) print value of rL" }
422 send_gdb "print rUL\n"
424 -re ".\[0-9\]* = \\(unsigned long &\\) @$hex: 234.*$gdb_prompt $" {
425 pass "print value of rUL"
427 -re ".*$gdb_prompt $" { fail "print value of rUL" }
428 timeout { fail "(timeout) print value of rUL" }
432 send_gdb "print rF\n"
434 -re ".\[0-9\]* = \\(float &\\) @$hex: 1.2\[0-9\]*e\\+10.*$gdb_prompt $" {
435 pass "print value of rF"
437 -re ".*$gdb_prompt $" { fail "print value of rF" }
438 timeout { fail "(timeout) print value of rF" }
442 send_gdb "print rD\n"
444 -re ".\[0-9\]* = \\(double &\\) @$hex: -1.375e-123.*$gdb_prompt $" {
445 pass "print value of rD"
447 -re ".*$gdb_prompt $" { fail "print value of rD" }
448 timeout { fail "(timeout) print value of rD" }