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 short type variables.
33 # test running programs
38 set testfile "ref-types"
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 marker1\n" ; gdb_expect -re ".*$gdb_prompt $"
64 -re "Break.* marker1 \\(\\) at .*:$decimal.*$gdb_prompt $" {
67 -re ".*$gdb_prompt $" {}
68 timeout { fail "up from marker1" }
71 -re "$gdb_prompt $" { fail "continue to marker1" }
72 timeout { fail "(timeout) continue to marker1" }
76 proc gdb_start_again {} {
84 gdb_reinitialize_dir $srcdir/$subdir
90 # set it up at a breakpoint so we can play with the variable values
92 if ![runto_main] then {
93 perror "couldn't run to breakpoint"
97 send_gdb "break marker1\n" ; gdb_expect -re ".*$gdb_prompt $"
101 -re "Break.* marker1 \\(\\) at .*:$decimal.*$gdb_prompt $" {
104 -re ".*$gdb_prompt $" {}
105 timeout { fail "up from marker1" }
108 -re "$gdb_prompt $" { fail "continue to marker1" }
109 timeout { fail "(timeout) continue to marker1" }
119 -re ".\[0-9\]* = -1.*$gdb_prompt $" {
120 pass "print value of s"
122 -re ".*$gdb_prompt $" { fail "print value of s" }
123 timeout { fail "(timeout) print value of s" }
129 -re "type = short.*$gdb_prompt $" { pass "ptype s" }
130 -re ".*$gdb_prompt $" { fail "ptype s" }
131 timeout { fail "(timeout) ptype s" }
135 send_gdb "print *ps\n"
137 -re ".\[0-9\]* = -1.*$gdb_prompt $" {
138 pass "print value of ps"
140 -re ".*$gdb_prompt $" { fail "print value of ps" }
141 timeout { fail "(timeout) print value of ps" }
145 send_gdb "ptype ps\n"
147 -re "type = short \*.*$gdb_prompt $" { pass "ptype ps" }
148 -re ".*$gdb_prompt $" { fail "ptype ps" }
149 timeout { fail "(timeout) ptype ps" }
152 send_gdb "print as\[0\]\n"
154 -re ".\[0-9\]* = 0.*$gdb_prompt $" {
155 pass "print value of as\[0\]"
157 -re ".*$gdb_prompt $" { fail "print value of as\[0\]" }
158 timeout { fail "(timeout) print value of as\[0\]" }
162 send_gdb "ptype as\n"
164 -re "type = short \\\[4\\\].*$gdb_prompt $" { pass "ptype as" }
165 -re ".*$gdb_prompt $" { fail "ptype as" }
166 timeout { fail "(timeout) ptype as" }
169 send_gdb "print as\[1\]\n"
171 -re ".\[0-9\]* = 1.*$gdb_prompt $" {
172 pass "print value of as\[1\]"
174 -re ".*$gdb_prompt $" { fail "print value of as\[1\]" }
175 timeout { fail "(timeout) print value of as\[1\]" }
178 send_gdb "print as\[2\]\n"
180 -re ".\[0-9\]* = 2.*$gdb_prompt $" {
181 pass "print value of as\[2\]"
183 -re ".*$gdb_prompt $" { fail "print value of as\[2\]" }
184 timeout { fail "(timeout) print value of as\[2\]" }
187 send_gdb "print as\[3\]\n"
189 -re ".\[0-9\]* = 3.*$gdb_prompt $" {
190 pass "print value of as\[3\]"
192 -re ".*$gdb_prompt $" { fail "print value of as\[3\]" }
193 timeout { fail "(timeout) print value of as\[3\]" }
196 send_gdb "print rs\n"
198 -re ".\[0-9\]* = \\(short &\\) @$hex: -1.*$gdb_prompt $" {
199 pass "print value of rs"
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 ; }
207 send_gdb "ptype rs\n"
209 -re "type = short &.*$gdb_prompt $" { pass "ptype rs" }
210 -re ".*$gdb_prompt $" { fail "ptype rs" }
211 timeout { fail "(timeout) ptype rs" }
215 send_gdb "print *rps\n"
217 -re ".\[0-9\]* = -1.*$gdb_prompt $" {
218 pass "print value of *rps"
220 -re ".*$gdb_prompt $" { fail "print value of *rps" }
221 timeout { fail "(timeout) print value of *rps" }
225 send_gdb "ptype rps\n"
227 -re "type = short \\*&.*$gdb_prompt $" { pass "ptype rps" }
228 -re ".*$gdb_prompt $" { fail "ptype rps" }
229 timeout { fail "(timeout) ptype rps" }
234 send_gdb "print ras\[0\]\n"
236 -re ".\[0-9\]* = 0.*$gdb_prompt $" {
237 pass "print value of ras\[0\]"
239 -re ".*$gdb_prompt $" { fail "print value of ras\[0\]" }
240 timeout { fail "(timeout) print value of ras\[0\]" }
244 send_gdb "ptype ras\n"
246 -re "type = short \\\(&\\\)\\\[4\\\].*$gdb_prompt $" { pass "ptype ras" }
247 -re ".*$gdb_prompt $" { fail "ptype ras" }
248 timeout { fail "(timeout) ptype ras" }
251 send_gdb "print ras\[1\]\n"
253 -re ".\[0-9\]* = 1.*$gdb_prompt $" {
254 pass "print value of ras\[1\]"
256 -re ".*$gdb_prompt $" { fail "print value of ras\[1\]" }
257 timeout { fail "(timeout) print value of ras\[1\]" }
260 send_gdb "print ras\[2\]\n"
262 -re ".\[0-9\]* = 2.*$gdb_prompt $" {
263 pass "print value of ras\[2\]"
265 -re ".*$gdb_prompt $" { fail "print value of ras\[2\]" }
266 timeout { fail "(timeout) print value of ras\[2\]" }
269 send_gdb "print ras\[3\]\n"
271 -re ".\[0-9\]* = 3.*$gdb_prompt $" {
272 pass "print value of ras\[3\]"
274 -re ".*$gdb_prompt $" { fail "print value of ras\[3\]" }
275 timeout { fail "(timeout) print value of ras\[3\]" }