]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blob - gdb/testsuite/gdb.chill/chillvars.exp
Initial creation of sourceware repository
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.chill / chillvars.exp
1 # Copyright (C) 1992, 1997 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 Fred Fish. (fnf@cygnus.com)
21
22 if $tracelevel then {
23 strace $tracelevel
24 }
25
26 if [skip_chill_tests] then { continue }
27
28 set testfile "chillvars"
29 set srcfile ${srcdir}/$subdir/${testfile}.ch
30 set binfile ${objdir}/${subdir}/${testfile}.exe
31 if { [compile "${srcfile} -g -o ${binfile} ${CHILL_RT0} ${CHILL_LIB}"] != "" } {
32 perror "Couldn't compile ${srcfile}"
33 return -1
34 }
35
36 proc do_tests {} {
37 global prms_id bug_id subdir objdir srcdir binfile gdb_prompt
38
39 set prms_id 0
40 set bug_id 0
41
42 # Start with a fresh gdb.
43
44 gdb_exit
45 gdb_start
46 gdb_reinitialize_dir $srcdir/$subdir
47 gdb_load $binfile
48
49 gdb_test "set language chill" ""
50
51 # This is needed (at least on SunOS4) to make sure the
52 # the symbol table is read.
53 gdb_test "break chillvars.ch:3" ""
54 gdb_test "delete 1" ""
55
56 gdb_test "set width 0" ""
57 gdb_test "set print sevenbit-strings" ""
58 gdb_test "set print address off" ""
59
60 test_BOOL
61 test_CHAR
62 test_BYTE
63 test_UBYTE
64 test_INT
65 test_UINT
66 test_LONG
67 test_ULONG
68 test_REAL
69 test_LONG_REAL
70 test_POWERSET
71 test_arrays
72 test_strings
73 test_structs
74
75 test_ptr
76 }
77
78 proc test_BOOL {} {
79
80 gdb_test "ptype bool_true" "type = (BOOL|bool)"
81 gdb_test "ptype bool_false" "type = (BOOL|bool)"
82 gdb_test "whatis bool_true" "type = (BOOL|bool)"
83 gdb_test "whatis bool_false" "type = (BOOL|bool)"
84 gdb_test "print bool_false" " = FALSE"
85 gdb_test "print bool_true" " = TRUE"
86
87 }
88
89 proc test_CHAR {} {
90 gdb_test "ptype control_char" "type = (CHAR|char)"
91 gdb_test "whatis control_char" "type = (CHAR|char)"
92 gdb_test "print control_char" { = '\^[(]7[)]'}
93 gdb_test "ptype printable_char" "type = (CHAR|char)"
94 gdb_test "whatis printable_char" "type = (CHAR|char)"
95 gdb_test "print printable_char" " = 'a'"
96
97 gdb_test "print lower(char)" { = '\^[(]0[)]'}
98 gdb_test "print upper(char)" { = '\^[(]255[)]'}
99 }
100
101 proc test_BYTE {} {
102 gdb_test "ptype byte_low" "type = (BYTE|byte)"
103 gdb_test "whatis byte_low" "type = (BYTE|byte)"
104 gdb_test "print byte_low" " = -128"
105 gdb_test "ptype byte_high" "type = (BYTE|byte)"
106 gdb_test "whatis byte_high" "type = (BYTE|byte)"
107 gdb_test "print byte_high" " = 127"
108
109 gdb_test "print lower(byte)" " = -128"
110 gdb_test "print upper(byte)" " = 127"
111 gdb_test "print lower(byte_high)" " = -128"
112 gdb_test "print upper(byte_high)" " = 127"
113 }
114
115 proc test_UBYTE {} {
116 gdb_test "ptype ubyte_low" "type = (UBYTE|ubyte)"
117 gdb_test "whatis ubyte_low" "type = (UBYTE|ubyte)"
118 gdb_test "print ubyte_low" " = 0"
119 gdb_test "ptype ubyte_high" "type = (UBYTE|ubyte)"
120 gdb_test "whatis ubyte_high" "type = (UBYTE|ubyte)"
121 gdb_test "print ubyte_high" " = 255"
122 }
123
124 proc test_INT {} {
125 gdb_test "ptype int_low" "type = (INT|int)"
126 gdb_test "whatis int_low" "type = (INT|int)"
127 gdb_test "print int_low" " = -32768"
128 gdb_test "ptype int_high" "type = (INT|int)"
129 gdb_test "whatis int_high" "type = (INT|int)"
130 gdb_test "print int_high" " = 32767"
131 }
132
133 proc test_UINT {} {
134 gdb_test "ptype uint_low" "type = (UINT|uint)"
135 gdb_test "whatis uint_low" "type = (UINT|uint)"
136 gdb_test "print uint_low" " = 0"
137 gdb_test "ptype uint_high" "type = (UINT|uint)"
138 gdb_test "whatis uint_high" "type = (UINT|uint)"
139 gdb_test "print uint_high" " = 65535"
140 }
141
142 proc test_LONG {} {
143 gdb_test "ptype long_low" "type = (LONG|long)"
144 gdb_test "whatis long_low" "type = (LONG|long)"
145 gdb_test "print long_low" " = -2147483648"
146 gdb_test "ptype long_high" "type = (LONG|long)"
147 gdb_test "whatis long_high" "type = (LONG|long)"
148 gdb_test "print long_high" " = 2147483647"
149 }
150
151 proc test_ULONG {} {
152 gdb_test "ptype ulong_low" "type = (ULONG|ulong)"
153 gdb_test "whatis ulong_low" "type = (ULONG|ulong)"
154 gdb_test "print ulong_low" " = 0"
155 gdb_test "ptype ulong_high" "type = (ULONG|ulong)"
156 gdb_test "whatis ulong_high" "type = (ULONG|ulong)"
157 gdb_test "print ulong_high" " = 4294967295"
158 }
159
160 proc test_REAL {} {
161 gdb_test "ptype real1" "type = (FLOAT|float)"
162 gdb_test "whatis real1" "type = (FLOAT|float)"
163 gdb_test "print real1" " = 3.14159274"
164 }
165
166 proc test_LONG_REAL {} {
167 gdb_test "ptype long_real1" "type = (DOUBLE|double)"
168 gdb_test "whatis long_real1" "type = (DOUBLE|double)"
169 gdb_test "print long_real1" " = 3\\.1400000000000001e\\+300"
170 }
171
172 proc test_POWERSET {} {
173 }
174
175 proc test_arrays {} {
176 gdb_test "ptype booltable1" "type = ARRAY \\(+0:3\\)+ (BOOL|bool)"
177 gdb_test_exact "print booltable1" \
178 { = [(0): TRUE, (1:2): FALSE, (3): TRUE]}
179
180 gdb_test "ptype booltable2" "type = ARRAY \\(+4:7\\)+ (BOOL|bool)"
181 gdb_test_exact "print booltable2" { = [(4): TRUE, (5:6): FALSE, (7): TRUE]}
182
183 gdb_test "ptype chartable1" "type = ARRAY \\(+0:2\\)+ (CHAR|char)"
184 gdb_test_exact "print chartable1" {= [(0): '^(0)', (1): '^(1)', (2): '^(2)']}
185
186 gdb_test "ptype chartable2" "type = ARRAY \\(+3:5\\)+ (CHAR|char)"
187 gdb_test_exact "print chartable2" \
188 {= [(3): '^(0)', (4): '^(1)', (5): '^(2)']}
189
190 gdb_test "ptype bytetable1" "type = ARRAY \\(+0:4\\)+ (BYTE|byte)"
191 gdb_test_exact "print bytetable1" \
192 {= [(0): -2, (1): -1, (2): 0, (3): 1, (4): 2]}
193
194 gdb_test "ptype bytetable2" "type = ARRAY \\(+5:9\\)+ (BYTE|byte)"
195 gdb_test_exact "print bytetable2" \
196 {= [(5): -2, (6): -1, (7): 0, (8): 1, (9): 2]}
197
198 gdb_test "ptype bytetable3" \
199 "type = ARRAY \\(1:2\\) ARRAY \\('c':'d'\\) ARRAY \\(FALSE:TRUE\\) (BYTE|byte)"
200 gdb_test_exact "print bytetable3" \
201 {= [(1): [('c'): [(FALSE): 0, (TRUE): 1], ('d'): [(FALSE): 2, (TRUE): 3]], (2): [('c'): [(FALSE): 4, (TRUE): 5], ('d'): [(FALSE): 6, (TRUE): 7]]]}
202 gdb_test "ptype bytetable4" \
203 "type = ARRAY \\(1:2\\) ARRAY \\('c':'d'\\) ARRAY \\(FALSE:TRUE\\) (BYTE|byte)"
204 gdb_test_exact "print bytetable4" \
205 {= [(1): [('c'): [(FALSE): 0, (TRUE): 1], ('d'): [(FALSE): 2, (TRUE): 3]], (2): [('c'): [(FALSE): 4, (TRUE): 5], ('d'): [(FALSE): 6, (TRUE): 7]]]}
206
207 gdb_test "ptype ubytetable1" "type = ARRAY \\(+0:4\\)+ (UBYTE|ubyte)"
208 gdb_test_exact "print ubytetable1" \
209 {= [(0): 0, (1): 1, (2): 2, (3): 3, (4): 4]}
210
211 gdb_test "ptype ubytetable2" "type = ARRAY \\(+5:9\\)+ (UBYTE|ubyte)"
212 gdb_test_exact "print ubytetable2" \
213 {= [(5): 0, (6): 1, (7): 2, (8): 3, (9): 4]}
214
215 gdb_test "ptype inttable1" "type = ARRAY \\(+0:4\\)+ (INT|int)"
216 gdb_test_exact "print inttable1" \
217 {= [(0): -2, (1): -1, (2): 0, (3): 1, (4): 2]}
218
219 gdb_test "ptype inttable2" "type = ARRAY \\(+5:9\\)+ (INT|int)"
220 gdb_test_exact "print inttable2" \
221 {= [(5): -2, (6): -1, (7): 0, (8): 1, (9): 2]}
222
223 gdb_test "ptype uinttable1" "type = ARRAY \\(+0:4\\)+ (UINT|uint)"
224 gdb_test_exact "print uinttable1" \
225 {= [(0): 0, (1): 1, (2): 2, (3): 3, (4): 4]}
226
227 gdb_test "ptype uinttable2" "type = ARRAY \\(+5:9\\)+ (UINT|uint)"
228 gdb_test_exact "print uinttable2" \
229 {= [(5): 0, (6): 1, (7): 2, (8): 3, (9): 4]}
230
231 gdb_test "ptype longtable1" "type = ARRAY \\(+0:4\\)+ (LONG|long)"
232 gdb_test_exact "print longtable1" \
233 {= [(0): -2, (1): -1, (2): 0, (3): 1, (4): 2]}
234
235 gdb_test "ptype longtable2" "type = ARRAY \\(+5:9\\)+ (LONG|long)"
236 gdb_test_exact "print longtable2" \
237 {= [(5): -2, (6): -1, (7): 0, (8): 1, (9): 2]}
238
239 gdb_test "ptype ulongtable1" "type = ARRAY \\(+0:4\\)+ (ULONG|ulong)"
240 gdb_test_exact "print ulongtable1" \
241 {= [(0): 0, (1): 1, (2): 2, (3): 3, (4): 4]}
242
243 gdb_test "ptype ulongtable2" "type = ARRAY \\(+5:9\\)+ (ULONG|ulong)"
244 gdb_test_exact "print ulongtable2" \
245 {= [(5): 0, (6): 1, (7): 2, (8): 3, (9): 4]}
246
247 gdb_test "ptype realtable1" "type = ARRAY \\(+0:4\\)+ (FLOAT|float)"
248 gdb_test_exact "print realtable1" \
249 {= [(0): -2, (1): -1, (2): 0, (3): 1, (4): 2]}
250
251 gdb_test "ptype realtable2" "type = ARRAY \\(+5:9\\)+ (FLOAT|float)"
252 gdb_test_exact "print realtable2" \
253 {= [(5): -2, (6): -1, (7): 0, (8): 1, (9): 2]}
254
255 gdb_test "ptype longrealtable1" "type = ARRAY \\(+0:4\\)+ (DOUBLE|double)"
256 gdb_test_exact "print longrealtable1" \
257 {= [(0): -2, (1): -1, (2): 0, (3): 1, (4): 2]}
258
259 gdb_test "ptype longrealtable2" "type = ARRAY \\(+5:9\\)+ (DOUBLE|double)"
260 gdb_test_exact "print longrealtable2" \
261 {= [(5): -2, (6): -1, (7): 0, (8): 1, (9): 2]}
262
263 gdb_test "print length(longrealtable2)" {= 5}
264 gdb_test "print lower(longrealtable2)" {= 5}
265 gdb_test "print upper(longrealtable2)" {= 9}
266 }
267
268 proc test_strings {} {
269
270 gdb_test "ptype string1" "type = CHARS \[(\]4\[)\]+"
271 gdb_test "print string1" " = \"abcd\""
272
273 gdb_test "ptype string2" "type = CHARS \[(\]+5\[)\]+"
274 gdb_test "print string2" { = \"ef\^\(0\)gh\"}
275
276 gdb_test "ptype string3" "type = CHARS \[(\]+6\[)\]+"
277 gdb_test "print string3" " = \"efghij\""
278
279 gdb_test "ptype string4" "type = CHARS \[(\]+7\[)\]+"
280 gdb_test "print string4" { = \"zzzzzz\^\(0\)\"}
281
282 # These tests require a running process, so run to one of the procs
283 # and then do the tests.
284
285 if [runto scalar_arithmetic] then {
286 gdb_test "ptype string1//string2" "type = CHARS \\(9\\)"
287 gdb_test "print string1//string2" { = \"abcdef\^\(0\)gh\"}
288 gdb_test_exact {ptype "a chill string"} {type = CHARS (14)}
289 gdb_test "print 'a chill string'" " = \"a chill string\""
290 gdb_test "print \"ef\"//c'00'//\"gh\"" { = \"ef\^\(0\)gh\"}
291 gdb_test "print string1 // \"efgh\"" " = \"abcdefgh\""
292 gdb_test "print (6) 'z'" " = \"zzzzzz\""
293 gdb_test "ptype (6) 'z'" "type = CHARS \[(\]+6\[)\]+"
294 gdb_test "print (1+2*3) 'x'" " = \"xxxxxxx\""
295 gdb_test "ptype (1+2*3) 'x'" "type = CHARS \[(\]+7\[)\]+"
296 }
297
298 }
299
300 proc test_structs {} {
301 gdb_test "ptype struct1" \
302 "type = STRUCT \\(+.*abool (BOOL|bool),.*aint (INT|int),.*astring CHARS \\(+8\\)+.*\\)+"
303 gdb_test "print struct1" \
304 ".* = \\\[\.abool: TRUE, \.aint: 123, \.astring: \"a string\"\\\]"
305 gdb_test "ptype struct2" \
306 "type = STRUCT \\(+.*abool (BOOL|bool),.*nstruct simple_struct,.*aint (INT|int).*\\)+"
307 gdb_test "print struct2" \
308 ".* = \\\[.abool: TRUE, \.nstruct: \\\[\.abool: FALSE, \.aint: 456, \.astring: \"deadbeef\"\\\], \.aint: 789\\\]"
309 }
310
311 proc test_ptr {} {
312 # This is to test Cygnus PR 6932
313 gdb_test "print xptr->int" ".* = 32767"
314 }
315
316 do_tests