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