]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blob - gdb/testsuite/gdb.base/assign.exp
Copyright updates for 2007.
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.base / assign.exp
1 # Copyright 1998, 1999, 2007 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 # This file was written by Elena Zannoni (ezannoni@cygnus.com)
21
22 # This file is part of the gdb testsuite
23 #
24 # tests for all the assignemnt operators
25 # with mixed types and with int type variables
26 #
27
28 if $tracelevel then {
29 strace $tracelevel
30 }
31
32 #
33 # test running programs
34 #
35 set prms_id 0
36 set bug_id 0
37
38 set testfile "all-types"
39 set srcfile ${testfile}.c
40 set binfile ${objdir}/${subdir}/${testfile}
41
42 if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug nowarnings}] != "" } {
43 untested assign.exp
44 return -1
45 }
46
47
48
49 gdb_exit
50 gdb_start
51 gdb_reinitialize_dir $srcdir/$subdir
52 gdb_load ${binfile}
53
54
55 #
56 # set it up at a breakpoint so we can play with the variable values
57 #
58
59 if ![runto_main] then {
60 perror "couldn't run to breakpoint"
61 continue
62 }
63
64 gdb_test "next" "return 0;" "continuing after dummy()"
65
66 send_gdb "print v_int=57\n"
67 gdb_expect {
68 -re ".*57.*$gdb_prompt $" {
69 send_gdb "print v_int\n"
70 gdb_expect {
71 -re ".*57.*$gdb_prompt $" {
72 pass "v_int=57"
73 }
74 -re ".*$gdb_prompt $" { fail "v_int=57" }
75 timeout { fail "(timeout) v_int=57" }
76 }
77 }
78 -re ".*$gdb_prompt $" { fail "v_int=57" }
79 timeout { fail "(timeout) v_int=57" }
80 }
81
82
83 gdb_test "set variable v_int = 6" "" "set v_int to 6"
84
85
86 send_gdb "print v_int+=57\n"
87 gdb_expect {
88 -re ".*63.*$gdb_prompt $" {
89 send_gdb "print v_int\n"
90 gdb_expect {
91 -re ".*63.*$gdb_prompt $" {
92 pass "v_int+=57"
93 }
94 -re ".*$gdb_prompt $" { fail "v_int+=57" }
95 timeout { fail "(timeout) v_int+=57" }
96 }
97 }
98 -re ".*$gdb_prompt $" { fail "v_int+=57" }
99 timeout { fail "(timeout) v_int+=57" }
100 }
101
102 gdb_test "set variable v_int = 6" "" "set v_int to 6"
103
104 send_gdb "print v_int-=57\n"
105 gdb_expect {
106 -re ".*-51.*$gdb_prompt $" {
107 send_gdb "print v_int\n"
108 gdb_expect {
109 -re ".*-51.*$gdb_prompt $" {
110 pass "v_int-=57"
111 }
112 -re ".*$gdb_prompt $" { fail "v_int-=57" }
113 timeout { fail "(timeout) v_int-=57" }
114 }
115 }
116 -re ".*$gdb_prompt $" { fail "v_int-=57" }
117 timeout { fail "(timeout) v_int-=57" }
118 }
119
120 gdb_test "set variable v_int = 6" "" "set v_int to 6"
121
122 send_gdb "print v_int*=5\n"
123 gdb_expect {
124 -re ".*30.*$gdb_prompt $" {
125 send_gdb "print v_int\n"
126 gdb_expect {
127 -re ".*30.*$gdb_prompt $" {
128 pass "v_int*=5"
129 }
130 -re ".*$gdb_prompt $" { fail "v_int*=5" }
131 timeout { fail "(timeout) v_int*=5" }
132 }
133 }
134 -re ".*$gdb_prompt $" { fail "v_int*=5" }
135 timeout { fail "(timeout) v_int*=5" }
136 }
137
138 gdb_test "set variable v_int = 6" "" "set v_int to 6"
139
140 send_gdb "print v_int/=4\n"
141 gdb_expect {
142 -re ".*1.*$gdb_prompt $" {
143 send_gdb "print v_int\n"
144 gdb_expect {
145 -re ".*1.*$gdb_prompt $" {
146 pass "v_int/=4"
147 }
148 -re ".*$gdb_prompt $" { fail "v_int/=4" }
149 timeout { fail "(timeout) v_int/=4" }
150 }
151 }
152 -re ".*$gdb_prompt $" { fail "v_int/=4" }
153 timeout { fail "(timeout) v_int/=4" }
154 }
155
156
157
158 gdb_test "set variable v_int = 6" "" "set v_int to 6"
159
160 send_gdb "print v_int%=4\n"
161 gdb_expect {
162 -re ".*2.*$gdb_prompt $" {
163 send_gdb "print v_int\n"
164 gdb_expect {
165 -re ".*2.*$gdb_prompt $" {
166 pass "v_int%=4"
167 }
168 -re ".*$gdb_prompt $" { fail "v_int%=4" }
169 timeout { fail "(timeout) v_int%=4" }
170 }
171 }
172 -re ".*$gdb_prompt $" { fail "v_int%=4" }
173 timeout { fail "(timeout) v_int%=4" }
174 }
175
176
177
178 gdb_test "set variable v_int = 6" "" "set v_int to 6"
179
180
181
182 send_gdb "print v_int+=v_char\n"
183 gdb_expect {
184 -re ".*71.*$gdb_prompt $" {
185 send_gdb "print v_int\n"
186 gdb_expect {
187 -re ".*71.*$gdb_prompt $" {
188 pass "v_int+=char"
189 }
190 -re ".*$gdb_prompt $" { fail "v_int+=v_char" }
191 timeout { fail "(timeout) v_int+=v_char" }
192 }
193 }
194 -re ".*$gdb_prompt $" { fail "v_int+=v_char" }
195 timeout { fail "(timeout) v_int+=v_char" }
196 }
197
198
199 gdb_test "set variable v_int = 6" "" "set v_int to 6"
200
201
202
203 send_gdb "print v_int+=v_signed_char\n"
204 gdb_expect {
205 -re ".*72.*$gdb_prompt $" {
206 send_gdb "print v_int\n"
207 gdb_expect {
208 -re ".*72.*$gdb_prompt $" {
209 pass "v_int+=signed_char"
210 }
211 -re ".*$gdb_prompt $" { fail "v_int+=v_signed_char" }
212 timeout { fail "(timeout) v_int+=v_signed_char" }
213 }
214 }
215 -re ".*$gdb_prompt $" { fail "v_int+=v_signed_char" }
216 timeout { fail "(timeout) v_int+=v_signed_char" }
217 }
218
219
220 gdb_test "set variable v_int = 6" "" "set v_int to 6"
221
222
223
224 send_gdb "print v_int+=v_unsigned_char\n"
225 gdb_expect {
226 -re ".*73.*$gdb_prompt $" {
227 send_gdb "print v_int\n"
228 gdb_expect {
229 -re ".*73.*$gdb_prompt $" {
230 pass "v_int+=unsigned_char"
231 }
232 -re ".*$gdb_prompt $" { fail "v_int+=v_unsigned_char" }
233 timeout { fail "(timeout) v_int+=v_unsigned_char" }
234 }
235 }
236 -re ".*$gdb_prompt $" { fail "v_int+=v_unsigned_char" }
237 timeout { fail "(timeout) v_int+=v_unsigned_char" }
238 }
239
240
241 gdb_test "set variable v_int = 6" "" "set v_int to 6"
242
243
244
245 send_gdb "print v_int+=v_short\n"
246 gdb_expect {
247 -re ".*9.*$gdb_prompt $" {
248 send_gdb "print v_int\n"
249 gdb_expect {
250 -re ".*9.*$gdb_prompt $" {
251 pass "v_int+=short"
252 }
253 -re ".*$gdb_prompt $" { fail "v_int+=v_short" }
254 timeout { fail "(timeout) v_int+=v_short" }
255 }
256 }
257 -re ".*$gdb_prompt $" { fail "v_int+=v_short" }
258 timeout { fail "(timeout) v_int+=v_short" }
259 }
260
261
262 gdb_test "set variable v_int = 6" "" "set v_int to 6"
263
264
265
266 send_gdb "print v_int+=v_signed_short\n"
267 gdb_expect {
268 -re ".*10.*$gdb_prompt $" {
269 send_gdb "print v_int\n"
270 gdb_expect {
271 -re ".*10.*$gdb_prompt $" {
272 pass "v_int+=signed_short"
273 }
274 -re ".*$gdb_prompt $" { fail "v_int+=v_signed_short" }
275 timeout { fail "(timeout) v_int+=v_signed_short" }
276 }
277 }
278 -re ".*$gdb_prompt $" { fail "v_int+=v_signed_short" }
279 timeout { fail "(timeout) v_int+=v_signed_short" }
280 }
281
282
283 gdb_test "set variable v_int = 6" "" "set v_int to 6"
284
285
286
287 send_gdb "print v_int+=v_unsigned_short\n"
288 gdb_expect {
289 -re ".*11.*$gdb_prompt $" {
290 send_gdb "print v_int\n"
291 gdb_expect {
292 -re ".*11.*$gdb_prompt $" {
293 pass "v_int=+unsigned_short"
294 }
295 -re ".*$gdb_prompt $" { fail "v_int+=v_unsigned_short" }
296 timeout { fail "(timeout) v_int+=v_unsigned_short" }
297 }
298 }
299 -re ".*$gdb_prompt $" { fail "v_int+=v_unsigned_short" }
300 timeout { fail "(timeout) v_int+=v_unsigned_short" }
301 }
302
303
304 gdb_test "set variable v_int = 6" "" "set v_int to 6"
305
306
307
308 send_gdb "print v_int+=v_signed_int\n"
309 gdb_expect {
310 -re ".*13.*$gdb_prompt $" {
311 send_gdb "print v_int\n"
312 gdb_expect {
313 -re ".*13.*$gdb_prompt $" {
314 pass "v_int+=signed_int"
315 }
316 -re ".*$gdb_prompt $" { fail "v_int+=v_signed_int" }
317 timeout { fail "(timeout) v_int+=v_signed_int" }
318 }
319 }
320 -re ".*$gdb_prompt $" { fail "v_int+=v_signed_int" }
321 timeout { fail "(timeout) v_int+=v_signed_int" }
322 }
323
324
325 gdb_test "set variable v_int = 6" "" "set v_int to 6"
326
327
328
329 send_gdb "print v_int+=v_unsigned_int\n"
330 gdb_expect {
331 -re ".*14.*$gdb_prompt $" {
332 send_gdb "print v_int\n"
333 gdb_expect {
334 -re ".*14.*$gdb_prompt $" {
335 pass "v_int+=unsigned_int"
336 }
337 -re ".*$gdb_prompt $" { fail "v_int+=v_unsigned_int" }
338 timeout { fail "(timeout) v_int+=v_unsigned_int" }
339 }
340 }
341 -re ".*$gdb_prompt $" { fail "v_int+=v_unsigned_int" }
342 timeout { fail "(timeout) v_int+=v_unsigned_int" }
343 }
344
345
346 gdb_test "set variable v_int = 6" "" "set v_int to 6"
347
348
349
350 send_gdb "print v_int+=v_long\n"
351 gdb_expect {
352 -re ".*15.*$gdb_prompt $" {
353 send_gdb "print v_int\n"
354 gdb_expect {
355 -re ".*15.*$gdb_prompt $" {
356 pass "v_int+=long"
357 }
358 -re ".*$gdb_prompt $" { fail "v_int+=v_long" }
359 timeout { fail "(timeout) v_int+=v_long" }
360 }
361 }
362 -re ".*$gdb_prompt $" { fail "v_int+=v_long" }
363 timeout { fail "(timeout) v_int+=v_long" }
364 }
365
366
367 gdb_test "set variable v_int = 6" "" "set v_int to 6"
368
369
370
371 send_gdb "print v_int+=v_signed_long\n"
372 gdb_expect {
373 -re ".*16.*$gdb_prompt $" {
374 send_gdb "print v_int\n"
375 gdb_expect {
376 -re ".*16.*$gdb_prompt $" {
377 pass "v_int+=signed_long"
378 }
379 -re ".*$gdb_prompt $" { fail "v_int+=v_signed_long" }
380 timeout { fail "(timeout) v_int+=v_signed_long" }
381 }
382 }
383 -re ".*$gdb_prompt $" { fail "v_int+=v_signed_long" }
384 timeout { fail "(timeout) v_int+=v_signed_long" }
385 }
386
387
388 gdb_test "set variable v_int = 6" "" "set v_int to 6"
389
390
391 send_gdb "print v_int+=v_unsigned_long\n"
392 gdb_expect {
393 -re ".*17.*$gdb_prompt $" {
394 send_gdb "print v_int\n"
395 gdb_expect {
396 -re ".*17.*$gdb_prompt $" {
397 pass "v_int+=unsigned_long"
398 }
399 -re ".*$gdb_prompt $" { fail "v_int+=v_unsigned_long" }
400 timeout { fail "(timeout) v_int+=v_unsigned_long" }
401 }
402 }
403 -re ".*$gdb_prompt $" { fail "v_int+=v_unsigned_long" }
404 timeout { fail "(timeout) v_int+=v_unsigned_long" }
405 }
406
407
408 gdb_test "set variable v_int = 6" "" "set v_int to 6"
409
410
411 send_gdb "print v_int+=v_float\n"
412 gdb_expect {
413 -re ".*106\r\n$gdb_prompt $" {
414 send_gdb "print v_int\n"
415 gdb_expect {
416 -re ".*106\r\n$gdb_prompt $" {
417 pass "v_int+=v_float"
418 }
419 -re ".*$gdb_prompt $" { fail "v_int+=v_float" }
420 timeout { fail "(timeout) v_int+=v_float" }
421 }
422 }
423 -re ".*$gdb_prompt $" { fail "v_int+=v_float" }
424 timeout { fail "(timeout) v_int+=v_float" }
425 }
426
427
428 gdb_test "set variable v_int = 6" "" "set v_int to 6"
429
430
431 send_gdb "print v_int+=v_double\n"
432 gdb_expect {
433 -re ".*206\r\n$gdb_prompt $" {
434 send_gdb "print v_int\n"
435 gdb_expect {
436 -re ".*206\r\n$gdb_prompt $" {
437 pass "v_int+=double"
438 }
439 -re ".*$gdb_prompt $" { fail "v_int+=v_double" }
440 timeout { fail "(timeout) v_int+=v_double" }
441 }
442 }
443 -re ".*$gdb_prompt $" { fail "v_int+=v_double" }
444 timeout { fail "(timeout) v_int+=v_double" }
445 }
446
447