1 # Tests for reference types with short type variables in GDB.
2 # Copyright 1998, 1999, 2000 Free Software Foundation, Inc.
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.
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.
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.
18 # Please email any bugs, comments, and/or additions to this file to:
19 # bug-gdb@prep.ai.mit.edu
21 # written by Elena Zannoni (ezannoni@cygnus.com)
28 # test running programs
33 if { [skip_cplus_tests] } { continue }
35 set testfile "ref-types"
36 set srcfile ${testfile}.cc
37 set binfile ${objdir}/${subdir}/${testfile}
39 if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug c++}] != "" } {
40 gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail."
45 gdb_reinitialize_dir $srcdir/$subdir
50 # set it up at a breakpoint so we can play with the variable values
52 if ![runto_main] then {
53 perror "couldn't run to breakpoint"
57 if ![runto 'marker1'] then {
58 perror "couldn't run to marker1"
62 gdb_test "up" ".*main.*" "up from marker1 1"
64 proc gdb_start_again {} {
72 gdb_reinitialize_dir $srcdir/$subdir
78 # set it up at a breakpoint so we can play with the variable values
80 if ![runto_main] then {
81 perror "couldn't run to breakpoint"
85 if ![runto 'marker1'] then {
86 perror "couldn't run to marker1"
90 gdb_test "up" ".*main.*" "up from marker1 2"
97 -re ".\[0-9\]* = -1.*$gdb_prompt $" {
98 pass "print value of s"
100 -re ".*$gdb_prompt $" { fail "print value of s" }
101 timeout { fail "(timeout) print value of s" }
107 -re "type = short.*$gdb_prompt $" { pass "ptype s" }
108 -re ".*$gdb_prompt $" { fail "ptype s" }
109 timeout { fail "(timeout) ptype s" }
113 send_gdb "print *ps\n"
115 -re ".\[0-9\]* = -1.*$gdb_prompt $" {
116 pass "print value of ps"
118 -re ".*$gdb_prompt $" { fail "print value of ps" }
119 timeout { fail "(timeout) print value of ps" }
123 send_gdb "ptype ps\n"
125 -re "type = short \*.*$gdb_prompt $" { pass "ptype ps" }
126 -re ".*$gdb_prompt $" { fail "ptype ps" }
127 timeout { fail "(timeout) ptype ps" }
130 send_gdb "print as\[0\]\n"
132 -re ".\[0-9\]* = 0.*$gdb_prompt $" {
133 pass "print value of as\[0\]"
135 -re ".*$gdb_prompt $" { fail "print value of as\[0\]" }
136 timeout { fail "(timeout) print value of as\[0\]" }
140 send_gdb "ptype as\n"
142 -re "type = short \\\[4\\\].*$gdb_prompt $" { pass "ptype as" }
143 -re "type = short int \\\[4\\\].*$gdb_prompt $" { pass "ptype as" }
144 -re ".*$gdb_prompt $" { fail "ptype as" }
145 timeout { fail "(timeout) ptype as" }
148 send_gdb "print as\[1\]\n"
150 -re ".\[0-9\]* = 1.*$gdb_prompt $" {
151 pass "print value of as\[1\]"
153 -re ".*$gdb_prompt $" { fail "print value of as\[1\]" }
154 timeout { fail "(timeout) print value of as\[1\]" }
157 send_gdb "print as\[2\]\n"
159 -re ".\[0-9\]* = 2.*$gdb_prompt $" {
160 pass "print value of as\[2\]"
162 -re ".*$gdb_prompt $" { fail "print value of as\[2\]" }
163 timeout { fail "(timeout) print value of as\[2\]" }
166 send_gdb "print as\[3\]\n"
168 -re ".\[0-9\]* = 3.*$gdb_prompt $" {
169 pass "print value of as\[3\]"
171 -re ".*$gdb_prompt $" { fail "print value of as\[3\]" }
172 timeout { fail "(timeout) print value of as\[3\]" }
175 send_gdb "print rs\n"
177 -re ".\[0-9\]* = \\(short &\\) @$hex: -1.*$gdb_prompt $" {
178 pass "print value of rs"
180 -re ".\[0-9\]* = \\(short int &\\) @$hex: -1.*$gdb_prompt $" {
181 pass "print value of rs"
183 -re ".*$gdb_prompt $" { fail "print value of rs" }
184 timeout { fail "(timeout) print value of rs" }
185 eof { fail "print rs ($GDB dumped core) (FIXME)" ; gdb_start_again ; }
189 send_gdb "ptype rs\n"
191 -re "type = short &.*$gdb_prompt $" { pass "ptype rs" }
192 -re "type = short int &.*$gdb_prompt $" { pass "ptype rs" }
193 -re ".*$gdb_prompt $" { fail "ptype rs" }
194 timeout { fail "(timeout) ptype rs" }
198 send_gdb "print *rps\n"
200 -re ".\[0-9\]* = -1.*$gdb_prompt $" {
201 pass "print value of *rps"
203 -re ".*$gdb_prompt $" { fail "print value of *rps" }
204 timeout { fail "(timeout) print value of *rps" }
208 send_gdb "ptype rps\n"
210 -re "type = short \\*&.*$gdb_prompt $" { pass "ptype rps" }
211 -re "type = short int \\*&.*$gdb_prompt $" { pass "ptype rps" }
212 -re ".*$gdb_prompt $" { fail "ptype rps" }
213 timeout { fail "(timeout) ptype rps" }
218 send_gdb "print ras\[0\]\n"
220 -re ".\[0-9\]* = 0.*$gdb_prompt $" {
221 pass "print value of ras\[0\]"
223 -re ".*$gdb_prompt $" { fail "print value of ras\[0\]" }
224 timeout { fail "(timeout) print value of ras\[0\]" }
228 send_gdb "ptype ras\n"
230 -re "type = short \\\(&\\\)\\\[4\\\].*$gdb_prompt $" { pass "ptype ras" }
231 -re "type = short int \\\(&\\\)\\\[4\\\].*$gdb_prompt $" { pass "ptype ras" }
232 -re ".*$gdb_prompt $" { fail "ptype ras" }
233 timeout { fail "(timeout) ptype ras" }
236 send_gdb "print ras\[1\]\n"
238 -re ".\[0-9\]* = 1.*$gdb_prompt $" {
239 pass "print value of ras\[1\]"
241 -re ".*$gdb_prompt $" { fail "print value of ras\[1\]" }
242 timeout { fail "(timeout) print value of ras\[1\]" }
245 send_gdb "print ras\[2\]\n"
247 -re ".\[0-9\]* = 2.*$gdb_prompt $" {
248 pass "print value of ras\[2\]"
250 -re ".*$gdb_prompt $" { fail "print value of ras\[2\]" }
251 timeout { fail "(timeout) print value of ras\[2\]" }
254 send_gdb "print ras\[3\]\n"
256 -re ".\[0-9\]* = 3.*$gdb_prompt $" {
257 pass "print value of ras\[3\]"
259 -re ".*$gdb_prompt $" { fail "print value of ras\[3\]" }
260 timeout { fail "(timeout) print value of ras\[3\]" }
264 if ![runto 'f'] then {
265 perror "couldn't run to f"
269 gdb_test "up" ".main2.*" "up from f"
273 -re ".\[0-9\]* = 65 \'A\'.*$gdb_prompt $" {
274 pass "print value of C"
276 -re ".*$gdb_prompt $" { fail "print value of C" }
277 timeout { fail "(timeout) print value of C" }
283 -re "type = char.*$gdb_prompt $" { pass "ptype C" }
284 -re ".*$gdb_prompt $" { fail "ptype C" }
285 timeout { fail "(timeout) ptype C" }
289 send_gdb "print UC\n"
291 -re ".\[0-9\]* = 21 '\.025'\.*$gdb_prompt $" {
292 pass "print value of UC"
294 -re ".*$gdb_prompt $" { fail "print value of UC" }
295 timeout { fail "(timeout) print value of UC" }
299 send_gdb "ptype UC\n"
301 -re "type = unsigned char.*$gdb_prompt $" { pass "ptype UC" }
302 -re ".*$gdb_prompt $" { fail "ptype UC" }
303 timeout { fail "(timeout) ptype UC" }
309 -re ".\[0-9\]* = -14.*$gdb_prompt $" {
310 pass "print value of S"
312 -re ".*$gdb_prompt $" { fail "print value of S" }
313 timeout { fail "(timeout) print value of S" }
319 -re "type = short.*$gdb_prompt $" { pass "ptype S" }
320 -re ".*$gdb_prompt $" { fail "ptype S" }
321 timeout { fail "(timeout) ptype S" }
325 send_gdb "print US\n"
327 -re ".\[0-9\]* = 7.*$gdb_prompt $" {
328 pass "print value of US"
330 -re ".*$gdb_prompt $" { fail "print value of US" }
331 timeout { fail "(timeout) print value of US" }
335 send_gdb "ptype US\n"
337 -re "type = unsigned short.*$gdb_prompt $" { pass "ptype US" }
338 -re "type = short unsigned.*$gdb_prompt $" { pass "ptype US" }
339 -re ".*$gdb_prompt $" { fail "ptype US" }
340 timeout { fail "(timeout) ptype US" }
346 -re ".\[0-9\]* = 102.*$gdb_prompt $" {
347 pass "print value of I"
349 -re ".*$gdb_prompt $" { fail "print value of I" }
350 timeout { fail "(timeout) print value of I" }
356 -re "type = int.*$gdb_prompt $" { pass "ptype I" }
357 -re ".*$gdb_prompt $" { fail "ptype I" }
358 timeout { fail "(timeout) ptype I" }
362 send_gdb "print UI\n"
364 -re ".\[0-9\]* = 1002.*$gdb_prompt $" {
365 pass "print value of UI"
367 -re ".*$gdb_prompt $" { fail "print value of UI" }
368 timeout { fail "(timeout) print value of UI" }
372 send_gdb "ptype UI\n"
374 -re "type = unsigned int.*$gdb_prompt $" { pass "ptype UI" }
375 -re ".*$gdb_prompt $" { fail "ptype UI" }
376 timeout { fail "(timeout) ptype UI" }
382 -re ".\[0-9\]* = -234.*$gdb_prompt $" {
383 pass "print value of L"
385 -re ".*$gdb_prompt $" { fail "print value of L" }
386 timeout { fail "(timeout) print value of L" }
392 -re "type = long.*$gdb_prompt $" { pass "ptype L" }
393 -re ".*$gdb_prompt $" { fail "ptype L" }
394 timeout { fail "(timeout) ptype L" }
398 send_gdb "print UL\n"
400 -re ".\[0-9\]* = 234.*$gdb_prompt $" {
401 pass "print value of UL"
403 -re ".*$gdb_prompt $" { fail "print value of UL" }
404 timeout { fail "(timeout) print value of UL" }
408 send_gdb "ptype UL\n"
410 -re "type = unsigned long.*$gdb_prompt $" { pass "ptype UL" }
411 -re "type = long unsigned.*$gdb_prompt $" { pass "ptype UL" }
412 -re ".*$gdb_prompt $" { fail "ptype UL" }
413 timeout { fail "(timeout) ptype UL" }
419 -re ".\[0-9\]* = 1.2\[0-9\]*e\\+10.*$gdb_prompt $" {
420 pass "print value of F"
422 -re ".*$gdb_prompt $" { fail "print value of F" }
423 timeout { fail "(timeout) print value of F" }
430 -re "type = float.*$gdb_prompt $" { pass "ptype F" }
431 -re ".*$gdb_prompt $" { fail "ptype F" }
432 timeout { fail "(timeout) ptype F" }
438 -re ".\[0-9\]* = -1.375e-123.*$gdb_prompt $" {
439 pass "print value of D"
441 -re ".*$gdb_prompt $" { fail "print value of D" }
442 timeout { fail "(timeout) print value of D" }
448 -re "type = double.*$gdb_prompt $" { pass "ptype D" }
449 -re ".*$gdb_prompt $" { fail "ptype D" }
450 timeout { fail "(timeout) ptype D" }
456 # test reference types
462 send_gdb "ptype rC\n"
464 -re "type = char &.*$gdb_prompt $" { pass "ptype rC" }
465 -re ".*$gdb_prompt $" { fail "ptype rC" }
466 timeout { fail "(timeout) ptype rC" }
472 send_gdb "ptype rUC\n"
474 -re "type = unsigned char &.*$gdb_prompt $" { pass "ptype rUC" }
475 -re ".*$gdb_prompt $" { fail "ptype rUC" }
476 timeout { fail "(timeout) ptype rUC" }
481 send_gdb "ptype rS\n"
483 -re "type = short &.*$gdb_prompt $" { pass "ptype rS" }
484 -re "type = short int &.*$gdb_prompt $" { pass "ptype rS" }
485 -re ".*$gdb_prompt $" { fail "ptype rS" }
486 timeout { fail "(timeout) ptype rS" }
491 send_gdb "ptype rUS\n"
493 -re "type = unsigned short &.*$gdb_prompt $" { pass "ptype rUS" }
494 -re "type = short unsigned int &.*$gdb_prompt $" { pass "ptype rUS" }
495 -re ".*$gdb_prompt $" { fail "ptype rUS" }
496 timeout { fail "(timeout) ptype rUS" }
500 send_gdb "ptype rI\n"
502 -re "type = int &.*$gdb_prompt $" { pass "ptype rI" }
503 -re ".*$gdb_prompt $" { fail "ptype rI" }
504 timeout { fail "(timeout) ptype rI" }
509 send_gdb "ptype rUI\n"
511 -re "type = unsigned int &.*$gdb_prompt $" { pass "ptype rUI" }
512 -re ".*$gdb_prompt $" { fail "ptype rUI" }
513 timeout { fail "(timeout) ptype rUI" }
518 send_gdb "ptype rL\n"
520 -re "type = long &.*$gdb_prompt $" { pass "ptype rL" }
521 -re "type = long int &.*$gdb_prompt $" { pass "ptype rL" }
522 -re ".*$gdb_prompt $" { fail "ptype rL" }
523 timeout { fail "(timeout) ptype rL" }
527 send_gdb "ptype rUL\n"
529 -re "type = unsigned long &.*$gdb_prompt $" { pass "ptype rUL" }
530 -re "type = long unsigned int &.*$gdb_prompt $" { pass "ptype rUL" }
531 -re ".*$gdb_prompt $" { fail "ptype rUL" }
532 timeout { fail "(timeout) ptype rUL" }
536 send_gdb "ptype rF\n"
538 -re "type = float &.*$gdb_prompt $" { pass "ptype rF" }
539 -re ".*$gdb_prompt $" { fail "ptype rF" }
540 timeout { fail "(timeout) ptype rF" }
544 send_gdb "ptype rD\n"
546 -re "type = double &.*$gdb_prompt $" { pass "ptype rD" }
547 -re ".*$gdb_prompt $" { fail "ptype rD" }
548 timeout { fail "(timeout) ptype rD" }
552 send_gdb "print rC\n"
554 -re ".\[0-9\]* = \\(char &\\) @$hex: 65 \'A\'.*$gdb_prompt $" {
555 pass "print value of rC"
557 -re ".*$gdb_prompt $" { fail "print value of rC" }
558 timeout { fail "(timeout) print value of rC" }
562 send_gdb "print rUC\n"
564 -re ".\[0-9\]* = \\(unsigned char &\\) @$hex: 21 \'.025\'.*$gdb_prompt $" {
565 pass "print value of rUC"
567 -re ".*$gdb_prompt $" { fail "print value of rUC" }
568 timeout { fail "(timeout) print value of rUC" }
572 send_gdb "print rS\n"
574 -re ".\[0-9\]* = \\(short &\\) @$hex: -14.*$gdb_prompt $" {
575 pass "print value of rS"
577 -re ".\[0-9\]* = \\(short int &\\) @$hex: -14.*$gdb_prompt $" {
578 pass "print value of rS"
580 -re ".*$gdb_prompt $" { fail "print value of rS" }
581 timeout { fail "(timeout) print value of rS" }
585 send_gdb "print rUS\n"
587 -re ".\[0-9\]* = \\(unsigned short &\\) @$hex: 7.*$gdb_prompt $" {
588 pass "print value of rUS"
590 -re ".\[0-9\]* = \\(short unsigned int &\\) @$hex: 7.*$gdb_prompt $" {
591 pass "print value of rUS"
593 -re ".*$gdb_prompt $" { fail "print value of rUS" }
594 timeout { fail "(timeout) print value of rUS" }
598 send_gdb "print rI\n"
600 -re ".\[0-9\]* = \\(int &\\) @$hex: 102.*$gdb_prompt $" {
601 pass "print value of rI"
603 -re ".*$gdb_prompt $" { fail "print value of rI" }
604 timeout { fail "(timeout) print value of rI" }
608 send_gdb "print rUI\n"
610 -re ".\[0-9\]* = \\(unsigned int &\\) @$hex: 1002.*$gdb_prompt $" {
611 pass "print value of UI"
613 -re ".*$gdb_prompt $" { fail "print value of rUI" }
614 timeout { fail "(timeout) print value of rUI" }
618 send_gdb "print rL\n"
620 -re ".\[0-9\]* = \\(long &\\) @$hex: -234.*$gdb_prompt $" {
621 pass "print value of rL"
623 -re ".\[0-9\]* = \\(long int &\\) @$hex: -234.*$gdb_prompt $" {
624 pass "print value of rL"
626 -re ".*$gdb_prompt $" { fail "print value of rL" }
627 timeout { fail "(timeout) print value of rL" }
632 send_gdb "print rUL\n"
634 -re ".\[0-9\]* = \\(unsigned long &\\) @$hex: 234.*$gdb_prompt $" {
635 pass "print value of rUL"
637 -re ".\[0-9\]* = \\(long unsigned int &\\) @$hex: 234.*$gdb_prompt $" {
638 pass "print value of rUL"
640 -re ".*$gdb_prompt $" { fail "print value of rUL" }
641 timeout { fail "(timeout) print value of rUL" }
645 send_gdb "print rF\n"
647 -re ".\[0-9\]* = \\(float &\\) @$hex: 1.2\[0-9\]*e\\+10.*$gdb_prompt $" {
648 pass "print value of rF"
650 -re ".*$gdb_prompt $" { fail "print value of rF" }
651 timeout { fail "(timeout) print value of rF" }
655 send_gdb "print rD\n"
657 -re ".\[0-9\]* = \\(double &\\) @$hex: -1.375e-123.*$gdb_prompt $" {
658 pass "print value of rD"
660 -re ".*$gdb_prompt $" { fail "print value of rD" }
661 timeout { fail "(timeout) print value of rD" }