* config/tc-d30v.c (write_2_short): Don't group repeat instructions
[external/binutils.git] / gdb / testsuite / gdb.c++ / ref-types2.exp
1 # Tests for reference types with elementary type variables in GDB.
2 # Copyright (C) 1998, 1999 Free Software Foundation, Inc.
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
18 # Please email any bugs, comments, and/or additions to this file to:
19 # bug-gdb@prep.ai.mit.edu
20
21 # written by Elena Zannoni (ezannoni@cygnus.com)
22
23 if $tracelevel then {
24         strace $tracelevel
25         }
26
27 #
28 # test running programs
29 #
30 set prms_id 0
31 set bug_id 0
32
33 set testfile "ref-types2"
34 set srcfile ${testfile}.cc
35 set binfile ${objdir}/${subdir}/${testfile}
36
37 if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug c++}] != "" } {
38      gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail."
39 }
40
41 gdb_exit
42 gdb_start
43 gdb_reinitialize_dir $srcdir/$subdir
44 gdb_load ${binfile}
45
46
47 #
48 # set it up at a breakpoint so we can play with the variable values
49 #
50 if ![runto_main] then {
51     perror "couldn't run to breakpoint"
52     continue
53 }
54
55 send_gdb "break f\n" ; gdb_expect -re ".*$gdb_prompt $"
56
57     send_gdb "cont\n"
58     gdb_expect {
59         -re "Break.* f \\(\\) at .*:$decimal.*$gdb_prompt $" {
60             send_gdb "up\n"
61             gdb_expect {
62                 -re ".*$gdb_prompt $" {}
63                 timeout { fail "up from f" }
64             }
65         }
66         -re "$gdb_prompt $" { fail "continue to f"  }
67         timeout { fail "(timeout) continue to f"  }
68     }
69
70
71 send_gdb "print C\n"
72 gdb_expect {
73     -re ".\[0-9\]* = 65 \'A\'.*$gdb_prompt $" {
74         pass "print value of C"
75       }
76     -re ".*$gdb_prompt $" { fail "print value of C" }
77     timeout           { fail "(timeout) print value of C" }
78   }
79
80
81 send_gdb "ptype C\n"
82 gdb_expect {
83     -re "type = char.*$gdb_prompt $"  { pass "ptype C" }
84     -re ".*$gdb_prompt $"   {  fail "ptype C" }
85     timeout             { fail "(timeout) ptype C" }
86 }
87
88
89 send_gdb "print UC\n"
90 gdb_expect {
91     -re ".\[0-9\]* = 21 '\.025'\.*$gdb_prompt $" {
92         pass "print value of UC"
93       }
94     -re ".*$gdb_prompt $" { fail "print value of UC" }
95     timeout           { fail "(timeout) print value of UC" }
96   }
97
98
99 send_gdb "ptype UC\n"
100 gdb_expect {
101     -re "type = unsigned char.*$gdb_prompt $"  { pass "ptype UC" }
102     -re ".*$gdb_prompt $"   {  fail "ptype UC" }
103     timeout             { fail "(timeout) ptype UC" }
104 }
105
106
107 send_gdb "print S\n"
108 gdb_expect {
109     -re ".\[0-9\]* = -14.*$gdb_prompt $" {
110         pass "print value of S"
111       }
112     -re ".*$gdb_prompt $" { fail "print value of S" }
113     timeout           { fail "(timeout) print value of S" }
114   }
115
116
117 send_gdb "ptype S\n"
118 gdb_expect {
119     -re "type = short.*$gdb_prompt $"  { pass "ptype S" }
120     -re ".*$gdb_prompt $"   {  fail "ptype S" }
121     timeout             { fail "(timeout) ptype S" }
122 }
123
124
125 send_gdb "print US\n"
126 gdb_expect {
127     -re ".\[0-9\]* = 7.*$gdb_prompt $" {
128         pass "print value of US"
129       }
130     -re ".*$gdb_prompt $" { fail "print value of US" }
131     timeout           { fail "(timeout) print value of US" }
132   }
133
134
135 send_gdb "ptype US\n"
136 gdb_expect {
137     -re "type = unsigned short.*$gdb_prompt $"  { pass "ptype US" }
138     -re "type = short unsigned.*$gdb_prompt $"  { pass "ptype US" }
139     -re ".*$gdb_prompt $"   {  fail "ptype US" }
140     timeout             { fail "(timeout) ptype US" }
141 }
142
143
144 send_gdb "print I\n"
145 gdb_expect {
146     -re ".\[0-9\]* = 102.*$gdb_prompt $" {
147         pass "print value of I"
148       }
149     -re ".*$gdb_prompt $" { fail "print value of I" }
150     timeout           { fail "(timeout) print value of I" }
151   }
152
153
154 send_gdb "ptype I\n"
155 gdb_expect {
156     -re "type = int.*$gdb_prompt $"  { pass "ptype I" }
157     -re ".*$gdb_prompt $"   {  fail "ptype I" }
158     timeout             { fail "(timeout) ptype I" }
159 }
160
161
162 send_gdb "print UI\n"
163 gdb_expect {
164     -re ".\[0-9\]* = 1002.*$gdb_prompt $" {
165         pass "print value of UI"
166       }
167     -re ".*$gdb_prompt $" { fail "print value of UI" }
168     timeout           { fail "(timeout) print value of UI" }
169   }
170
171
172 send_gdb "ptype UI\n"
173 gdb_expect {
174     -re "type = unsigned int.*$gdb_prompt $"  { pass "ptype UI" }
175     -re ".*$gdb_prompt $"   {  fail "ptype UI" }
176     timeout             { fail "(timeout) ptype UI" }
177 }
178
179
180 send_gdb "print L\n"
181 gdb_expect {
182     -re ".\[0-9\]* = -234.*$gdb_prompt $" {
183         pass "print value of L"
184       }
185     -re ".*$gdb_prompt $" { fail "print value of L" }
186     timeout           { fail "(timeout) print value of L" }
187   }
188
189
190 send_gdb "ptype L\n"
191 gdb_expect {
192     -re "type = long.*$gdb_prompt $"  { pass "ptype L" }
193     -re ".*$gdb_prompt $"   {  fail "ptype L" }
194     timeout             { fail "(timeout) ptype L" }
195 }
196
197
198 send_gdb "print UL\n"
199 gdb_expect {
200     -re ".\[0-9\]* = 234.*$gdb_prompt $" {
201         pass "print value of UL"
202       }
203     -re ".*$gdb_prompt $" { fail "print value of UL" }
204     timeout           { fail "(timeout) print value of UL" }
205   }
206
207
208 send_gdb "ptype UL\n"
209 gdb_expect {
210     -re "type = unsigned long.*$gdb_prompt $"  { pass "ptype UL" }
211     -re "type = long unsigned.*$gdb_prompt $"  { pass "ptype UL" }
212     -re ".*$gdb_prompt $"   {  fail "ptype UL" }
213     timeout             { fail "(timeout) ptype UL" }
214 }
215
216
217 send_gdb "print F\n"
218 gdb_expect {
219     -re ".\[0-9\]* = 1.2\[0-9\]*e\\+10.*$gdb_prompt $" {
220         pass "print value of F"
221       }
222     -re ".*$gdb_prompt $" { fail "print value of F" }
223     timeout           { fail "(timeout) print value of F" }
224   }
225
226
227
228 send_gdb "ptype F\n"
229 gdb_expect {
230     -re "type = float.*$gdb_prompt $"  { pass "ptype F" }
231     -re ".*$gdb_prompt $"   {  fail "ptype F" }
232     timeout             { fail "(timeout) ptype F" }
233 }
234
235
236 send_gdb "print D\n"
237 gdb_expect {
238     -re ".\[0-9\]* = -1.375e-123.*$gdb_prompt $" {
239         pass "print value of D"
240       }
241     -re ".*$gdb_prompt $" { fail "print value of D" }
242     timeout           { fail "(timeout) print value of D" }
243   }
244
245
246 send_gdb "ptype D\n"
247 gdb_expect {
248     -re "type = double.*$gdb_prompt $"  { pass "ptype D" }
249     -re ".*$gdb_prompt $"   {  fail "ptype D" }
250     timeout             { fail "(timeout) ptype D" }
251 }
252
253
254
255 #
256 # test reference types
257 #
258
259
260
261
262 send_gdb "ptype rC\n"
263 gdb_expect {
264     -re "type = char &.*$gdb_prompt $"  { pass "ptype rC" }
265     -re ".*$gdb_prompt $"   {  fail "ptype rC" }
266     timeout             { fail "(timeout) ptype rC" }
267 }
268
269
270
271
272 send_gdb "ptype rUC\n"
273 gdb_expect {
274     -re "type = unsigned char &.*$gdb_prompt $"  { pass "ptype rUC" }
275     -re ".*$gdb_prompt $"   {  fail "ptype rUC" }
276     timeout             { fail "(timeout) ptype rUC" }
277 }
278
279
280
281 send_gdb "ptype rS\n"
282 gdb_expect {
283     -re "type = short &.*$gdb_prompt $"  { pass "ptype rS" }
284     -re "type = short int &.*$gdb_prompt $"  { pass "ptype rS" }
285     -re ".*$gdb_prompt $"   {  fail "ptype rS" }
286     timeout             { fail "(timeout) ptype rS" }
287 }
288
289
290
291 send_gdb "ptype rUS\n"
292 gdb_expect {
293     -re "type = unsigned short &.*$gdb_prompt $"  { pass "ptype rUS" }
294     -re "type = short unsigned int &.*$gdb_prompt $"  { pass "ptype rUS" }
295     -re ".*$gdb_prompt $"   {  fail "ptype rUS" }
296     timeout             { fail "(timeout) ptype rUS" }
297 }
298
299
300 send_gdb "ptype rI\n"
301 gdb_expect {
302     -re "type = int &.*$gdb_prompt $"  { pass "ptype rI" }
303     -re ".*$gdb_prompt $"   {  fail "ptype rI" }
304     timeout             { fail "(timeout) ptype rI" }
305 }
306
307
308
309 send_gdb "ptype rUI\n"
310 gdb_expect {
311     -re "type = unsigned int &.*$gdb_prompt $"  { pass "ptype rUI" }
312     -re ".*$gdb_prompt $"   {  fail "ptype rUI" }
313     timeout             { fail "(timeout) ptype rUI" }
314 }
315
316
317
318 send_gdb "ptype rL\n"
319 gdb_expect {
320     -re "type = long &.*$gdb_prompt $"  { pass "ptype rL" }
321     -re "type = long int &.*$gdb_prompt $"  { pass "ptype rL" }
322     -re ".*$gdb_prompt $"   {  fail "ptype rL" }
323     timeout             { fail "(timeout) ptype rL" }
324 }
325
326
327 send_gdb "ptype rUL\n"
328 gdb_expect {
329     -re "type = unsigned long &.*$gdb_prompt $"  { pass "ptype rUL" }
330     -re "type = long unsigned int &.*$gdb_prompt $"  { pass "ptype rUL" }
331     -re ".*$gdb_prompt $"   {  fail "ptype rUL" }
332     timeout             { fail "(timeout) ptype rUL" }
333 }
334
335
336 send_gdb "ptype rF\n"
337 gdb_expect {
338     -re "type = float &.*$gdb_prompt $"  { pass "ptype rF" }
339     -re ".*$gdb_prompt $"   {  fail "ptype rF" }
340     timeout             { fail "(timeout) ptype rF" }
341 }
342
343
344 send_gdb "ptype rD\n"
345 gdb_expect {
346     -re "type = double &.*$gdb_prompt $"  { pass "ptype rD" }
347     -re ".*$gdb_prompt $"   {  fail "ptype rD" }
348     timeout             { fail "(timeout) ptype rD" }
349 }
350
351
352 send_gdb "print rC\n"
353 gdb_expect {
354     -re ".\[0-9\]* = \\(char &\\) @$hex: 65 \'A\'.*$gdb_prompt $" {
355         pass "print value of rC"
356       }
357     -re ".*$gdb_prompt $" { fail "print value of rC" }
358     timeout           { fail "(timeout) print value of rC" }
359   }
360
361
362 send_gdb "print rUC\n"
363 gdb_expect {
364     -re ".\[0-9\]* = \\(unsigned char &\\) @$hex: 21 \'.025\'.*$gdb_prompt $" {
365         pass "print value of rUC"
366       }
367     -re ".*$gdb_prompt $" { fail "print value of rUC" }
368     timeout           { fail "(timeout) print value of rUC" }
369   }
370
371
372 send_gdb "print rS\n"
373 gdb_expect {
374     -re ".\[0-9\]* = \\(short &\\) @$hex: -14.*$gdb_prompt $" {
375         pass "print value of rS"
376     }
377     -re ".\[0-9\]* = \\(short int &\\) @$hex: -14.*$gdb_prompt $" {
378         pass "print value of rS"
379     }
380     -re ".*$gdb_prompt $" { fail "print value of rS" }
381     timeout           { fail "(timeout) print value of rS" }
382   }
383
384
385 send_gdb "print rUS\n"
386 gdb_expect {
387     -re ".\[0-9\]* = \\(unsigned short &\\) @$hex: 7.*$gdb_prompt $" {
388         pass "print value of rUS"
389     }
390     -re ".\[0-9\]* = \\(short unsigned int &\\) @$hex: 7.*$gdb_prompt $" {
391         pass "print value of rUS"
392     }
393     -re ".*$gdb_prompt $" { fail "print value of rUS" }
394     timeout           { fail "(timeout) print value of rUS" }
395   }
396
397
398 send_gdb "print rI\n"
399 gdb_expect {
400     -re ".\[0-9\]* = \\(int &\\) @$hex: 102.*$gdb_prompt $" {
401         pass "print value of rI"
402       }
403     -re ".*$gdb_prompt $" { fail "print value of rI" }
404     timeout           { fail "(timeout) print value of rI" }
405   }
406
407
408 send_gdb "print rUI\n"
409 gdb_expect {
410     -re ".\[0-9\]* = \\(unsigned int &\\) @$hex: 1002.*$gdb_prompt $" {
411         pass "print value of UI"
412       }
413     -re ".*$gdb_prompt $" { fail "print value of rUI" }
414     timeout           { fail "(timeout) print value of rUI" }
415   }
416
417
418 send_gdb "print rL\n"
419 gdb_expect {
420     -re ".\[0-9\]* = \\(long &\\) @$hex: -234.*$gdb_prompt $" {
421         pass "print value of rL"
422     }
423     -re ".\[0-9\]* = \\(long int &\\) @$hex: -234.*$gdb_prompt $" {
424         pass "print value of rL"
425     }
426     -re ".*$gdb_prompt $" { fail "print value of rL" }
427     timeout           { fail "(timeout) print value of rL" }
428   }
429
430
431
432 send_gdb "print rUL\n"
433 gdb_expect {
434     -re ".\[0-9\]* = \\(unsigned long &\\) @$hex: 234.*$gdb_prompt $" {
435         pass "print value of rUL"
436     }
437     -re ".\[0-9\]* = \\(long unsigned int &\\) @$hex: 234.*$gdb_prompt $" {
438         pass "print value of rUL"
439     }
440     -re ".*$gdb_prompt $" { fail "print value of rUL" }
441     timeout           { fail "(timeout) print value of rUL" }
442   }
443
444
445 send_gdb "print rF\n"
446 gdb_expect {
447     -re ".\[0-9\]* = \\(float &\\) @$hex: 1.2\[0-9\]*e\\+10.*$gdb_prompt $" {
448         pass "print value of rF"
449       }
450     -re ".*$gdb_prompt $" { fail "print value of rF" }
451     timeout           { fail "(timeout) print value of rF" }
452   }
453
454
455 send_gdb "print rD\n"
456 gdb_expect {
457     -re ".\[0-9\]* = \\(double &\\) @$hex: -1.375e-123.*$gdb_prompt $" {
458         pass "print value of rD"
459       }
460     -re ".*$gdb_prompt $" { fail "print value of rD" }
461     timeout           { fail "(timeout) print value of rD" }
462   }
463