]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - gdb/testsuite/gdb.cp/ref-types.exp
Copyright updates for 2007.
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.cp / ref-types.exp
CommitLineData
7a292a7a 1# Tests for reference types with short type variables in GDB.
6aba47ca 2# Copyright 1998, 1999, 2000, 2004, 2007 Free Software Foundation, Inc.
c906108c
SS
3
4# This program is free software; you can redistribute it and/or modify
5# it under the terms of the GNU General Public License as published by
6# the Free Software Foundation; either version 2 of the License, or
7# (at your option) any later version.
8#
9# This program is distributed in the hope that it will be useful,
10# but WITHOUT ANY WARRANTY; without even the implied warranty of
11# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12# GNU General Public License for more details.
13#
14# You should have received a copy of the GNU General Public License
15# along with this program; if not, write to the Free Software
16# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17
c906108c
SS
18# written by Elena Zannoni (ezannoni@cygnus.com)
19
c906108c
SS
20if $tracelevel then {
21 strace $tracelevel
22 }
23
24#
25# test running programs
26#
27set prms_id 0
28set bug_id 0
29
d4f3574e
SS
30if { [skip_cplus_tests] } { continue }
31
c906108c
SS
32set testfile "ref-types"
33set srcfile ${testfile}.cc
34set binfile ${objdir}/${subdir}/${testfile}
35
36if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug c++}] != "" } {
b60f0898
JB
37 untested ref-types.exp
38 return -1
c906108c
SS
39}
40
41gdb_exit
42gdb_start
43gdb_reinitialize_dir $srcdir/$subdir
44gdb_load ${binfile}
45
46
47#
48# set it up at a breakpoint so we can play with the variable values
49#
50if ![runto_main] then {
51 perror "couldn't run to breakpoint"
52 continue
53}
54
b6c11a24
MC
55if ![runto 'marker1'] then {
56 perror "couldn't run to marker1"
c906108c
SS
57 continue
58}
59
b6c11a24
MC
60gdb_test "up" ".*main.*" "up from marker1 1"
61
62proc gdb_start_again {} {
63 global srcdir
64 global subdir
65 global binfile
66 global gdb_prompt
67 global decimal
68
69 gdb_start
70 gdb_reinitialize_dir $srcdir/$subdir
71 gdb_load ${binfile}
72
b6c11a24
MC
73 #
74 # set it up at a breakpoint so we can play with the variable values
75 #
76 if ![runto_main] then {
77 perror "couldn't run to breakpoint"
78 continue
c906108c 79 }
c906108c 80
b6c11a24
MC
81 if ![runto 'marker1'] then {
82 perror "couldn't run to marker1"
83 continue
84 }
c906108c 85
b6c11a24
MC
86 gdb_test "up" ".*main.*" "up from marker1 2"
87}
c906108c
SS
88
89
90
91send_gdb "print s\n"
92gdb_expect {
93 -re ".\[0-9\]* = -1.*$gdb_prompt $" {
94 pass "print value of s"
95 }
96 -re ".*$gdb_prompt $" { fail "print value of s" }
97 timeout { fail "(timeout) print value of s" }
98 }
99
100
101send_gdb "ptype s\n"
102gdb_expect {
103 -re "type = short.*$gdb_prompt $" { pass "ptype s" }
104 -re ".*$gdb_prompt $" { fail "ptype s" }
105 timeout { fail "(timeout) ptype s" }
106}
107
108
109send_gdb "print *ps\n"
110gdb_expect {
111 -re ".\[0-9\]* = -1.*$gdb_prompt $" {
112 pass "print value of ps"
113 }
114 -re ".*$gdb_prompt $" { fail "print value of ps" }
115 timeout { fail "(timeout) print value of ps" }
116 }
117
118
119send_gdb "ptype ps\n"
120gdb_expect {
121 -re "type = short \*.*$gdb_prompt $" { pass "ptype ps" }
122 -re ".*$gdb_prompt $" { fail "ptype ps" }
123 timeout { fail "(timeout) ptype ps" }
124}
125
126send_gdb "print as\[0\]\n"
127gdb_expect {
128 -re ".\[0-9\]* = 0.*$gdb_prompt $" {
129 pass "print value of as\[0\]"
130 }
131 -re ".*$gdb_prompt $" { fail "print value of as\[0\]" }
132 timeout { fail "(timeout) print value of as\[0\]" }
133 }
134
135
136send_gdb "ptype as\n"
137gdb_expect {
138 -re "type = short \\\[4\\\].*$gdb_prompt $" { pass "ptype as" }
7a292a7a 139 -re "type = short int \\\[4\\\].*$gdb_prompt $" { pass "ptype as" }
c906108c
SS
140 -re ".*$gdb_prompt $" { fail "ptype as" }
141 timeout { fail "(timeout) ptype as" }
142}
143
144send_gdb "print as\[1\]\n"
145gdb_expect {
146 -re ".\[0-9\]* = 1.*$gdb_prompt $" {
147 pass "print value of as\[1\]"
148 }
149 -re ".*$gdb_prompt $" { fail "print value of as\[1\]" }
150 timeout { fail "(timeout) print value of as\[1\]" }
151 }
152
153send_gdb "print as\[2\]\n"
154gdb_expect {
155 -re ".\[0-9\]* = 2.*$gdb_prompt $" {
156 pass "print value of as\[2\]"
157 }
158 -re ".*$gdb_prompt $" { fail "print value of as\[2\]" }
159 timeout { fail "(timeout) print value of as\[2\]" }
160 }
161
162send_gdb "print as\[3\]\n"
163gdb_expect {
164 -re ".\[0-9\]* = 3.*$gdb_prompt $" {
165 pass "print value of as\[3\]"
166 }
167 -re ".*$gdb_prompt $" { fail "print value of as\[3\]" }
168 timeout { fail "(timeout) print value of as\[3\]" }
169 }
170
171send_gdb "print rs\n"
172gdb_expect {
173 -re ".\[0-9\]* = \\(short &\\) @$hex: -1.*$gdb_prompt $" {
174 pass "print value of rs"
7a292a7a
SS
175 }
176 -re ".\[0-9\]* = \\(short int &\\) @$hex: -1.*$gdb_prompt $" {
177 pass "print value of rs"
178 }
c906108c
SS
179 -re ".*$gdb_prompt $" { fail "print value of rs" }
180 timeout { fail "(timeout) print value of rs" }
181 eof { fail "print rs ($GDB dumped core) (FIXME)" ; gdb_start_again ; }
182
183 }
184
185send_gdb "ptype rs\n"
186gdb_expect {
187 -re "type = short &.*$gdb_prompt $" { pass "ptype rs" }
7a292a7a 188 -re "type = short int &.*$gdb_prompt $" { pass "ptype rs" }
c906108c
SS
189 -re ".*$gdb_prompt $" { fail "ptype rs" }
190 timeout { fail "(timeout) ptype rs" }
191}
192
193
194send_gdb "print *rps\n"
195gdb_expect {
196 -re ".\[0-9\]* = -1.*$gdb_prompt $" {
197 pass "print value of *rps"
198 }
199 -re ".*$gdb_prompt $" { fail "print value of *rps" }
200 timeout { fail "(timeout) print value of *rps" }
201 }
202
203
204send_gdb "ptype rps\n"
205gdb_expect {
206 -re "type = short \\*&.*$gdb_prompt $" { pass "ptype rps" }
7a292a7a 207 -re "type = short int \\*&.*$gdb_prompt $" { pass "ptype rps" }
c906108c
SS
208 -re ".*$gdb_prompt $" { fail "ptype rps" }
209 timeout { fail "(timeout) ptype rps" }
210}
211
212
213
214send_gdb "print ras\[0\]\n"
215gdb_expect {
216 -re ".\[0-9\]* = 0.*$gdb_prompt $" {
217 pass "print value of ras\[0\]"
218 }
219 -re ".*$gdb_prompt $" { fail "print value of ras\[0\]" }
220 timeout { fail "(timeout) print value of ras\[0\]" }
221 }
222
223
224send_gdb "ptype ras\n"
225gdb_expect {
226 -re "type = short \\\(&\\\)\\\[4\\\].*$gdb_prompt $" { pass "ptype ras" }
7a292a7a 227 -re "type = short int \\\(&\\\)\\\[4\\\].*$gdb_prompt $" { pass "ptype ras" }
c906108c
SS
228 -re ".*$gdb_prompt $" { fail "ptype ras" }
229 timeout { fail "(timeout) ptype ras" }
230}
231
232send_gdb "print ras\[1\]\n"
233gdb_expect {
234 -re ".\[0-9\]* = 1.*$gdb_prompt $" {
235 pass "print value of ras\[1\]"
236 }
237 -re ".*$gdb_prompt $" { fail "print value of ras\[1\]" }
238 timeout { fail "(timeout) print value of ras\[1\]" }
239 }
240
241send_gdb "print ras\[2\]\n"
242gdb_expect {
243 -re ".\[0-9\]* = 2.*$gdb_prompt $" {
244 pass "print value of ras\[2\]"
245 }
246 -re ".*$gdb_prompt $" { fail "print value of ras\[2\]" }
247 timeout { fail "(timeout) print value of ras\[2\]" }
248 }
249
250send_gdb "print ras\[3\]\n"
251gdb_expect {
252 -re ".\[0-9\]* = 3.*$gdb_prompt $" {
253 pass "print value of ras\[3\]"
254 }
255 -re ".*$gdb_prompt $" { fail "print value of ras\[3\]" }
256 timeout { fail "(timeout) print value of ras\[3\]" }
257 }
a0b3c4fd
JM
258
259
b6c11a24
MC
260if ![runto 'f'] then {
261 perror "couldn't run to f"
262 continue
263}
a0b3c4fd 264
b6c11a24 265gdb_test "up" ".main2.*" "up from f"
a0b3c4fd
JM
266
267send_gdb "print C\n"
268gdb_expect {
269 -re ".\[0-9\]* = 65 \'A\'.*$gdb_prompt $" {
270 pass "print value of C"
271 }
272 -re ".*$gdb_prompt $" { fail "print value of C" }
273 timeout { fail "(timeout) print value of C" }
274 }
275
276
277send_gdb "ptype C\n"
278gdb_expect {
279 -re "type = char.*$gdb_prompt $" { pass "ptype C" }
280 -re ".*$gdb_prompt $" { fail "ptype C" }
281 timeout { fail "(timeout) ptype C" }
282}
283
284
285send_gdb "print UC\n"
286gdb_expect {
287 -re ".\[0-9\]* = 21 '\.025'\.*$gdb_prompt $" {
288 pass "print value of UC"
289 }
290 -re ".*$gdb_prompt $" { fail "print value of UC" }
291 timeout { fail "(timeout) print value of UC" }
292 }
293
294
295send_gdb "ptype UC\n"
296gdb_expect {
297 -re "type = unsigned char.*$gdb_prompt $" { pass "ptype UC" }
298 -re ".*$gdb_prompt $" { fail "ptype UC" }
299 timeout { fail "(timeout) ptype UC" }
300}
301
302
303send_gdb "print S\n"
304gdb_expect {
305 -re ".\[0-9\]* = -14.*$gdb_prompt $" {
306 pass "print value of S"
307 }
308 -re ".*$gdb_prompt $" { fail "print value of S" }
309 timeout { fail "(timeout) print value of S" }
310 }
311
312
313send_gdb "ptype S\n"
314gdb_expect {
315 -re "type = short.*$gdb_prompt $" { pass "ptype S" }
316 -re ".*$gdb_prompt $" { fail "ptype S" }
317 timeout { fail "(timeout) ptype S" }
318}
319
320
321send_gdb "print US\n"
322gdb_expect {
323 -re ".\[0-9\]* = 7.*$gdb_prompt $" {
324 pass "print value of US"
325 }
326 -re ".*$gdb_prompt $" { fail "print value of US" }
327 timeout { fail "(timeout) print value of US" }
328 }
329
330
331send_gdb "ptype US\n"
332gdb_expect {
333 -re "type = unsigned short.*$gdb_prompt $" { pass "ptype US" }
334 -re "type = short unsigned.*$gdb_prompt $" { pass "ptype US" }
335 -re ".*$gdb_prompt $" { fail "ptype US" }
336 timeout { fail "(timeout) ptype US" }
337}
338
339
340send_gdb "print I\n"
341gdb_expect {
342 -re ".\[0-9\]* = 102.*$gdb_prompt $" {
343 pass "print value of I"
344 }
345 -re ".*$gdb_prompt $" { fail "print value of I" }
346 timeout { fail "(timeout) print value of I" }
347 }
348
349
350send_gdb "ptype I\n"
351gdb_expect {
352 -re "type = int.*$gdb_prompt $" { pass "ptype I" }
353 -re ".*$gdb_prompt $" { fail "ptype I" }
354 timeout { fail "(timeout) ptype I" }
355}
356
357
358send_gdb "print UI\n"
359gdb_expect {
360 -re ".\[0-9\]* = 1002.*$gdb_prompt $" {
361 pass "print value of UI"
362 }
363 -re ".*$gdb_prompt $" { fail "print value of UI" }
364 timeout { fail "(timeout) print value of UI" }
365 }
366
367
368send_gdb "ptype UI\n"
369gdb_expect {
370 -re "type = unsigned int.*$gdb_prompt $" { pass "ptype UI" }
371 -re ".*$gdb_prompt $" { fail "ptype UI" }
372 timeout { fail "(timeout) ptype UI" }
373}
374
375
376send_gdb "print L\n"
377gdb_expect {
378 -re ".\[0-9\]* = -234.*$gdb_prompt $" {
379 pass "print value of L"
380 }
381 -re ".*$gdb_prompt $" { fail "print value of L" }
382 timeout { fail "(timeout) print value of L" }
383 }
384
385
386send_gdb "ptype L\n"
387gdb_expect {
388 -re "type = long.*$gdb_prompt $" { pass "ptype L" }
389 -re ".*$gdb_prompt $" { fail "ptype L" }
390 timeout { fail "(timeout) ptype L" }
391}
392
393
394send_gdb "print UL\n"
395gdb_expect {
396 -re ".\[0-9\]* = 234.*$gdb_prompt $" {
397 pass "print value of UL"
398 }
399 -re ".*$gdb_prompt $" { fail "print value of UL" }
400 timeout { fail "(timeout) print value of UL" }
401 }
402
403
404send_gdb "ptype UL\n"
405gdb_expect {
406 -re "type = unsigned long.*$gdb_prompt $" { pass "ptype UL" }
407 -re "type = long unsigned.*$gdb_prompt $" { pass "ptype UL" }
408 -re ".*$gdb_prompt $" { fail "ptype UL" }
409 timeout { fail "(timeout) ptype UL" }
410}
411
412
413send_gdb "print F\n"
414gdb_expect {
415 -re ".\[0-9\]* = 1.2\[0-9\]*e\\+10.*$gdb_prompt $" {
416 pass "print value of F"
417 }
418 -re ".*$gdb_prompt $" { fail "print value of F" }
419 timeout { fail "(timeout) print value of F" }
420 }
421
422
423
424send_gdb "ptype F\n"
425gdb_expect {
426 -re "type = float.*$gdb_prompt $" { pass "ptype F" }
427 -re ".*$gdb_prompt $" { fail "ptype F" }
428 timeout { fail "(timeout) ptype F" }
429}
430
431
432send_gdb "print D\n"
433gdb_expect {
434 -re ".\[0-9\]* = -1.375e-123.*$gdb_prompt $" {
435 pass "print value of D"
436 }
437 -re ".*$gdb_prompt $" { fail "print value of D" }
438 timeout { fail "(timeout) print value of D" }
439 }
440
441
442send_gdb "ptype D\n"
443gdb_expect {
444 -re "type = double.*$gdb_prompt $" { pass "ptype D" }
445 -re ".*$gdb_prompt $" { fail "ptype D" }
446 timeout { fail "(timeout) ptype D" }
447}
448
449
450
451#
452# test reference types
453#
454
455
456
457
458send_gdb "ptype rC\n"
459gdb_expect {
460 -re "type = char &.*$gdb_prompt $" { pass "ptype rC" }
461 -re ".*$gdb_prompt $" { fail "ptype rC" }
462 timeout { fail "(timeout) ptype rC" }
463}
464
465
466
467
468send_gdb "ptype rUC\n"
469gdb_expect {
470 -re "type = unsigned char &.*$gdb_prompt $" { pass "ptype rUC" }
471 -re ".*$gdb_prompt $" { fail "ptype rUC" }
472 timeout { fail "(timeout) ptype rUC" }
473}
474
475
476
477send_gdb "ptype rS\n"
478gdb_expect {
479 -re "type = short &.*$gdb_prompt $" { pass "ptype rS" }
480 -re "type = short int &.*$gdb_prompt $" { pass "ptype rS" }
481 -re ".*$gdb_prompt $" { fail "ptype rS" }
482 timeout { fail "(timeout) ptype rS" }
483}
484
485
486
487send_gdb "ptype rUS\n"
488gdb_expect {
489 -re "type = unsigned short &.*$gdb_prompt $" { pass "ptype rUS" }
490 -re "type = short unsigned int &.*$gdb_prompt $" { pass "ptype rUS" }
491 -re ".*$gdb_prompt $" { fail "ptype rUS" }
492 timeout { fail "(timeout) ptype rUS" }
493}
494
495
496send_gdb "ptype rI\n"
497gdb_expect {
498 -re "type = int &.*$gdb_prompt $" { pass "ptype rI" }
499 -re ".*$gdb_prompt $" { fail "ptype rI" }
500 timeout { fail "(timeout) ptype rI" }
501}
502
503
504
505send_gdb "ptype rUI\n"
506gdb_expect {
507 -re "type = unsigned int &.*$gdb_prompt $" { pass "ptype rUI" }
508 -re ".*$gdb_prompt $" { fail "ptype rUI" }
509 timeout { fail "(timeout) ptype rUI" }
510}
511
512
513
514send_gdb "ptype rL\n"
515gdb_expect {
516 -re "type = long &.*$gdb_prompt $" { pass "ptype rL" }
517 -re "type = long int &.*$gdb_prompt $" { pass "ptype rL" }
518 -re ".*$gdb_prompt $" { fail "ptype rL" }
519 timeout { fail "(timeout) ptype rL" }
520}
521
522
523send_gdb "ptype rUL\n"
524gdb_expect {
525 -re "type = unsigned long &.*$gdb_prompt $" { pass "ptype rUL" }
526 -re "type = long unsigned int &.*$gdb_prompt $" { pass "ptype rUL" }
527 -re ".*$gdb_prompt $" { fail "ptype rUL" }
528 timeout { fail "(timeout) ptype rUL" }
529}
530
531
532send_gdb "ptype rF\n"
533gdb_expect {
534 -re "type = float &.*$gdb_prompt $" { pass "ptype rF" }
535 -re ".*$gdb_prompt $" { fail "ptype rF" }
536 timeout { fail "(timeout) ptype rF" }
537}
538
539
540send_gdb "ptype rD\n"
541gdb_expect {
542 -re "type = double &.*$gdb_prompt $" { pass "ptype rD" }
543 -re ".*$gdb_prompt $" { fail "ptype rD" }
544 timeout { fail "(timeout) ptype rD" }
545}
546
547
548send_gdb "print rC\n"
549gdb_expect {
550 -re ".\[0-9\]* = \\(char &\\) @$hex: 65 \'A\'.*$gdb_prompt $" {
551 pass "print value of rC"
552 }
553 -re ".*$gdb_prompt $" { fail "print value of rC" }
554 timeout { fail "(timeout) print value of rC" }
555 }
556
557
558send_gdb "print rUC\n"
559gdb_expect {
560 -re ".\[0-9\]* = \\(unsigned char &\\) @$hex: 21 \'.025\'.*$gdb_prompt $" {
561 pass "print value of rUC"
562 }
563 -re ".*$gdb_prompt $" { fail "print value of rUC" }
564 timeout { fail "(timeout) print value of rUC" }
565 }
566
567
568send_gdb "print rS\n"
569gdb_expect {
570 -re ".\[0-9\]* = \\(short &\\) @$hex: -14.*$gdb_prompt $" {
571 pass "print value of rS"
572 }
573 -re ".\[0-9\]* = \\(short int &\\) @$hex: -14.*$gdb_prompt $" {
574 pass "print value of rS"
575 }
576 -re ".*$gdb_prompt $" { fail "print value of rS" }
577 timeout { fail "(timeout) print value of rS" }
578 }
579
580
581send_gdb "print rUS\n"
582gdb_expect {
583 -re ".\[0-9\]* = \\(unsigned short &\\) @$hex: 7.*$gdb_prompt $" {
584 pass "print value of rUS"
585 }
586 -re ".\[0-9\]* = \\(short unsigned int &\\) @$hex: 7.*$gdb_prompt $" {
587 pass "print value of rUS"
588 }
589 -re ".*$gdb_prompt $" { fail "print value of rUS" }
590 timeout { fail "(timeout) print value of rUS" }
591 }
592
593
594send_gdb "print rI\n"
595gdb_expect {
596 -re ".\[0-9\]* = \\(int &\\) @$hex: 102.*$gdb_prompt $" {
597 pass "print value of rI"
598 }
599 -re ".*$gdb_prompt $" { fail "print value of rI" }
600 timeout { fail "(timeout) print value of rI" }
601 }
602
603
604send_gdb "print rUI\n"
605gdb_expect {
606 -re ".\[0-9\]* = \\(unsigned int &\\) @$hex: 1002.*$gdb_prompt $" {
607 pass "print value of UI"
608 }
609 -re ".*$gdb_prompt $" { fail "print value of rUI" }
610 timeout { fail "(timeout) print value of rUI" }
611 }
612
613
614send_gdb "print rL\n"
615gdb_expect {
616 -re ".\[0-9\]* = \\(long &\\) @$hex: -234.*$gdb_prompt $" {
617 pass "print value of rL"
618 }
619 -re ".\[0-9\]* = \\(long int &\\) @$hex: -234.*$gdb_prompt $" {
620 pass "print value of rL"
621 }
622 -re ".*$gdb_prompt $" { fail "print value of rL" }
623 timeout { fail "(timeout) print value of rL" }
624 }
625
626
627
628send_gdb "print rUL\n"
629gdb_expect {
630 -re ".\[0-9\]* = \\(unsigned long &\\) @$hex: 234.*$gdb_prompt $" {
631 pass "print value of rUL"
632 }
633 -re ".\[0-9\]* = \\(long unsigned int &\\) @$hex: 234.*$gdb_prompt $" {
634 pass "print value of rUL"
635 }
636 -re ".*$gdb_prompt $" { fail "print value of rUL" }
637 timeout { fail "(timeout) print value of rUL" }
638 }
639
640
641send_gdb "print rF\n"
642gdb_expect {
643 -re ".\[0-9\]* = \\(float &\\) @$hex: 1.2\[0-9\]*e\\+10.*$gdb_prompt $" {
644 pass "print value of rF"
645 }
646 -re ".*$gdb_prompt $" { fail "print value of rF" }
647 timeout { fail "(timeout) print value of rF" }
648 }
649
650
651send_gdb "print rD\n"
652gdb_expect {
653 -re ".\[0-9\]* = \\(double &\\) @$hex: -1.375e-123.*$gdb_prompt $" {
654 pass "print value of rD"
655 }
656 -re ".*$gdb_prompt $" { fail "print value of rD" }
657 timeout { fail "(timeout) print value of rD" }
658 }
659