* cp-demangle.c (cplus_demangle_v3): Check that it's a v3 mangled
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.base / miscexprs.exp
CommitLineData
c906108c
SS
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
21# This file is part of the gdb testsuite
22# file written by Elena Zannoni (ezannoni@cygnus.com)
23
24#
25# tests for expressions with struct/array elements and mixed operator types
26# with elementary types
27#
28
29if $tracelevel then {
30 strace $tracelevel
31 }
32
33#
34# test running programs
35#
36set prms_id 0
37set bug_id 0
38
39set testfile "miscexprs"
40set srcfile ${testfile}.c
41set binfile ${objdir}/${subdir}/${testfile}
42
43if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug additional_flags=-w}] != "" } {
44 gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail."
45}
46
085dd6e6
JM
47if [get_compiler_info ${binfile}] {
48 return -1;
49}
c906108c
SS
50
51gdb_exit
52gdb_start
53gdb_reinitialize_dir $srcdir/$subdir
54gdb_load ${binfile}
55
56
57#
58# set it up at a breakpoint so we can play with the variable values
59#
60if ![runto_main] then {
61 perror "couldn't run to breakpoint"
62 continue
63}
64
65send_gdb "break marker1\n" ; gdb_expect -re ".*$gdb_prompt $"
66
67 send_gdb "cont\n"
68 gdb_expect {
69 -re "Break.* marker1 \\(\\) at .*:$decimal.*$gdb_prompt $" {
70 send_gdb "up\n"
71 gdb_expect {
72 -re ".*$gdb_prompt $" {}
73 timeout { fail "up from marker1" }
74 }
75 }
76 -re "$gdb_prompt $" { fail "continue to marker1" }
77 timeout { fail "(timeout) continue to marker1" }
78 }
79
80global hex
81
82send_gdb "print &ibig.i\[0\]\n"
83gdb_expect {
84 -re ".\[0-9\]* = \\(int \\*\\) $hex.*$gdb_prompt $" {
85 pass "print value of &ibig.i\[0\]"
86 }
87 -re ".*$gdb_prompt $" { fail "print value of &ibig.i\[0\]" }
88 timeout { fail "(timeout) print value of &ibig.i\[0\]" }
89 }
90
91send_gdb "print &cbig.c\[0\]\n"
92gdb_expect {
93 -re ".\[0-9\]* = $hex \"\".*$gdb_prompt $" {
94 pass "print value of &cbig.c\[0\]"
95 }
085dd6e6
JM
96 -re ".\[0-9\]* = $hex \"*\".*$gdb_prompt $" {
97 pass "print value of &cbig.c\[0\]"
98 }
c906108c
SS
99 -re ".*$gdb_prompt $" { fail "print value of &cbig.c\[0\]" }
100 timeout { fail "(timeout) print value of &cbig.c\[0\]" }
101 }
102
103send_gdb "print &fbig.f\[0\]\n"
104gdb_expect {
105 -re ".\[0-9\]* = \\(float \\*\\) $hex.*$gdb_prompt $" {
106 pass "print value of &fbig.f\[0\]"
107 }
108 -re ".*$gdb_prompt $" { fail "print value of &fbig.f\[0\]" }
109 timeout { fail "(timeout) print value of &fbig.f\[0\]" }
110 }
111
112send_gdb "print &dbig.d\[0\]\n"
113gdb_expect {
114 -re ".\[0-9\]* = \\(double \\*\\) $hex.*$gdb_prompt $" {
115 pass "print value of &dbig.d\[0\]"
116 }
117 -re ".*$gdb_prompt $" { fail "print value of &dbig.d\[0\]" }
118 timeout { fail "(timeout) print value of &dbig.d\[0\]" }
119 }
120
121send_gdb "print &sbig.s\[0\]\n"
122gdb_expect {
7a292a7a
SS
123 -re ".\[0-9\]* = \\(short \\*\\) $hex.*$gdb_prompt $" {
124 pass "print value of &sbig.s\[0\]"
125 }
c906108c
SS
126 -re ".\[0-9\]* = \\(short int \\*\\) $hex.*$gdb_prompt $" {
127 pass "print value of &sbig.s\[0\]"
7a292a7a 128 }
c906108c
SS
129 -re ".*$gdb_prompt $" { fail "print value of &sbig.s\[0\]" }
130 timeout { fail "(timeout) print value of &sbig.s\[0\]" }
131 }
132
133send_gdb "print &lbig.l\[0\]\n"
134gdb_expect {
7a292a7a
SS
135 -re ".\[0-9\]* = \\(long \\*\\) $hex.*$gdb_prompt $" {
136 pass "print value of &lbig.l\[0\]"
137 }
c906108c
SS
138 -re ".\[0-9\]* = \\(long int \\*\\) $hex.*$gdb_prompt $" {
139 pass "print value of &lbig.l\[0\]"
7a292a7a 140 }
c906108c
SS
141 -re ".*$gdb_prompt $" { fail "print value of &lbig.l\[0\]" }
142 timeout { fail "(timeout) print value of &lbig.l\[0\]" }
143 }
144
145
146send_gdb "print ibig.i\[100\] | 1\n"
147gdb_expect {
148 -re ".\[0-9\]* = 5.*$gdb_prompt $" {
149 pass "print value of ibig.i\[100\] | 1"
150 }
151 -re ".*$gdb_prompt $" { fail "print value of ibig.i\[100\] | 1" }
152 timeout { fail "(timeout) print value of ibig.i\[100\] | 1" }
153 }
154
155
156send_gdb "print sbig.s\[90\] & 127\n"
157gdb_expect {
158 -re ".\[0-9\]* = 127.*$gdb_prompt $" {
159 pass "print value of sbig.s\[90\] & 127"
160 }
161 -re ".*$gdb_prompt $" { fail "print value of sbig.s\[90\] & 127" }
162 timeout { fail "(timeout) print value of sbig.s\[90\] & 127" }
163 }
164
165send_gdb "print !ibig.i\[100\]\n"
166gdb_expect {
085dd6e6 167 -re ".\[0-9\]* = $false.*$gdb_prompt $" {
c906108c
SS
168 pass "print value of !ibig.i\[100\]"
169 }
170 -re ".*$gdb_prompt $" { fail "print value of !ibig.i\[100\]" }
171 timeout { fail "(timeout) print value of !ibig.i\[100\]" }
172 }
173
174send_gdb "print !sbig.s\[90\]\n"
175gdb_expect {
085dd6e6 176 -re ".\[0-9\]* = $false.*$gdb_prompt $" {
c906108c
SS
177 pass "print value of !sbig.s\[90\]"
178 }
179 -re ".*$gdb_prompt $" { fail "print value of !sbig.s\[90\]" }
180 timeout { fail "(timeout) print value of !sbig.s\[90\]" }
181 }
182
183
184send_gdb "print !fbig.f\[100\]\n"
185gdb_expect {
085dd6e6 186 -re ".\[0-9\]* = $false.*$gdb_prompt $" {
c906108c
SS
187 pass "print value of !ibig.i\[100\]"
188 }
189 -re ".*$gdb_prompt $" { fail "print value of !ibig.i\[100\]" }
190 timeout { fail "(timeout) print value of !ibig.i\[100\]" }
191 }
192
193send_gdb "print !dbig.d\[202\]\n"
194gdb_expect {
085dd6e6 195 -re ".\[0-9\]* = $false.*$gdb_prompt $" {
c906108c
SS
196 pass "print value of !ibig.i\[100\]"
197 }
198 -re ".*$gdb_prompt $" { fail "print value of !ibig.i\[100\]" }
199 timeout { fail "(timeout) print value of !ibig.i\[100\]" }
200 }
201
202
203
204send_gdb "print sbig.s\[90\] * 10\n"
205gdb_expect {
206 -re ".\[0-9\]* = 2550.*$gdb_prompt $" {
207 pass "print value of !sbig.s\[90\] * 10"
208 }
209 -re ".*$gdb_prompt $" { fail "print value of !sbig.s\[90\] * 10" }
210 timeout { fail "(timeout) print value of !sbig.s\[90\] * 10" }
211 }
212
213send_gdb "print ibig.i\[100\] * sbig.s\[90\]\n"
214gdb_expect {
215 -re ".\[0-9\]* = 1275.*$gdb_prompt $" {
216 pass "print value of ibig.i\[100\] * sbig.s\[90\]"
217 }
218 -re ".*$gdb_prompt $" { fail "print value of ibig.i\[100\] * sbig.s\[90\]" }
219 timeout { fail "(timeout) print value of ibig.i\[100\] * sbig.s\[90\]" }
220 }
221
222send_gdb "print fbig.f\[100\] * dbig.d\[202\]\n"
223gdb_expect {
224 -re ".\[0-9\]* = 119.99\[0-9\]*.*$gdb_prompt $" {
225 pass "print value of fbig.f\[100\] * dbig.d\[202\]"
226 }
227 -re ".*$gdb_prompt $" { fail "print value of fbig.f\[100\] * dbig.d\[202\]" }
228 timeout { fail "(timeout) print value of fbig.f\[100\] * dbig.d\[202\]" }
229 }
230
231send_gdb "print !(sbig.s\[90\] * 2)\n"
232gdb_expect {
085dd6e6 233 -re ".\[0-9\]* = $false.*$gdb_prompt $" {
c906108c
SS
234 pass "print value of !(sbig.s\[90\] * 2)"
235 }
236 -re ".*$gdb_prompt $" { fail "print value of !(sbig.s\[90\] * 2)" }
237 timeout { fail "(timeout) print value of !(sbig.s\[90\] * 2)" }
238 }
239
240
241send_gdb "print sizeof(sbig)\n"
242gdb_expect {
243 -re ".\[0-9\]* = 800.*$gdb_prompt $" {
244 pass "print value of sizeof(sbig)"
245 }
246 -re ".*$gdb_prompt $" { fail "print value of sizeof(sbig)" }
247 timeout { fail "(timeout) print value of sizeof(sbig)" }
248 }
249
250
251send_gdb "print sizeof(cbig)\n"
252gdb_expect {
253 -re ".\[0-9\]* = 100.*$gdb_prompt $" {
254 pass "print value of sizeof(cbig)"
255 }
256 -re ".*$gdb_prompt $" { fail "print value of sizeof(cbig)" }
257 timeout { fail "(timeout) print value of sizeof(cbig)" }
258 }
259
260
b84b7669 261send_gdb "print sizeof(lbig)/sizeof(long)\n"
085dd6e6 262gdb_expect {
b84b7669
MS
263 -re ".\[0-9\]* = 900.*$gdb_prompt $" {
264 pass "print value of sizeof(lbig)/sizeof(long)"
085dd6e6 265 }
b84b7669
MS
266 -re ".*$gdb_prompt $" { fail "print value of sizeof(lbig)/sizeof(long)" }
267 timeout { fail "(timeout) print value of sizeof(lbig)/sizeof(long)" }
085dd6e6 268 }
c906108c
SS
269
270send_gdb "print ibig.i\[100\] << 2\n"
271gdb_expect {
272 -re ".\[0-9\]* = 20.*$gdb_prompt $" {
273 pass "print value of ibig.i\[100\] << 2"
274 }
275 -re ".*$gdb_prompt $" { fail "print value of ibig.i\[100\] << 2" }
276 timeout { fail "(timeout) print value of ibig.i\[100\] << 2" }
277 }
278
279send_gdb "print sbig.s\[90\] >> 4\n"
280gdb_expect {
281 -re ".\[0-9\]* = 15.*$gdb_prompt $" {
282 pass "print value of sbig.s\[90\] >> 4"
283 }
284 -re ".*$gdb_prompt $" { fail "print value of sbig.s\[90\] >> 4" }
285 timeout { fail "(timeout) print value of sbig.s\[90\] >> 4" }
286 }
287
288send_gdb "print lbig.l\[333\] >> 6\n"
289gdb_expect {
290 -re ".\[0-9\]* = 15624999.*$gdb_prompt $" {
291 pass "print value of lbig.l\[333\] >> 6"
292 }
293 -re ".*$gdb_prompt $" { fail "print value of lbig.l\[333\] >> 6" }
294 timeout { fail "(timeout) print value of lbig.l\[333\] >> 6" }
295 }
This page took 0.095645 seconds and 4 git commands to generate.