* Makefile.in: Bunch of fixes so it actually works in this
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.chill / chillvars.exp
CommitLineData
16def8c8
SS
1# Copyright (C) 1992 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., 675 Mass Ave, Cambridge, MA 02139, 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
22if $tracelevel then {
23 strace $tracelevel
24}
25
26proc do_tests {} {
27 global prms_id bug_id subdir objdir srcdir binfile prompt
28
29 set prms_id 0
30 set bug_id 0
31
32 # Start with a fresh gdb.
33
34 gdb_exit
35 gdb_start
36 gdb_reinitialize_dir $srcdir/$subdir
37 gdb_load $objdir/$subdir/$binfile
38
39 send "set language chill\n" ; expect -re "$prompt $"
40
41 # This is needed (at least on SunOS4) to make sure the
42 # the symbol table is read.
43 send "break chillvars.ch:3\n" ; expect -re "$prompt $"
44 send "delete 1\n" ; expect -re "$prompt $"
45
46 send "set width 0\n" ; expect -re "$prompt $"
47 send "set print sevenbit-strings\n" ; expect -re "$prompt $"
48 send "set print address off\n" ; expect -re "$prompt $"
49
50 test_BOOL
51 test_CHAR
52 test_BYTE
53 test_UBYTE
54 test_INT
55 test_UINT
56 test_LONG
57 test_ULONG
58 test_REAL
59 test_LONG_REAL
60 test_POWERSET
61 test_arrays
62 test_strings
63 test_structs
64}
65
66proc test_BOOL {} {
67
68 gdb_test "ptype bool_true" "type = BOOL"
69 gdb_test "ptype bool_false" "type = BOOL"
70 gdb_test "whatis bool_true" "type = BOOL"
71 gdb_test "whatis bool_false" "type = BOOL"
72 gdb_test "print bool_false" " = FALSE"
73 gdb_test "print bool_true" " = TRUE"
74
75}
76
77proc test_CHAR {} {
78 gdb_test "ptype control_char" "type = CHAR"
79 gdb_test "whatis control_char" "type = CHAR"
80 gdb_test "print control_char" " = C'07'"
81 gdb_test "ptype printable_char" "type = CHAR"
82 gdb_test "whatis printable_char" "type = CHAR"
83 gdb_test "print printable_char" " = 'a'"
84}
85
86proc test_BYTE {} {
87 gdb_test "ptype byte_low" "type = BYTE"
88 gdb_test "whatis byte_low" "type = BYTE"
89 gdb_test "print byte_low" " = -128"
90 gdb_test "ptype byte_high" "type = BYTE"
91 gdb_test "whatis byte_high" "type = BYTE"
92 gdb_test "print byte_high" " = 127"
93}
94
95proc test_UBYTE {} {
96 gdb_test "ptype ubyte_low" "type = UBYTE"
97 gdb_test "whatis ubyte_low" "type = UBYTE"
98 gdb_test "print ubyte_low" " = 0"
99 gdb_test "ptype ubyte_high" "type = UBYTE"
100 gdb_test "whatis ubyte_high" "type = UBYTE"
101 gdb_test "print ubyte_high" " = 255"
102}
103
104proc test_INT {} {
105 gdb_test "ptype int_low" "type = INT"
106 gdb_test "whatis int_low" "type = INT"
107 gdb_test "print int_low" " = -32768"
108 gdb_test "ptype int_high" "type = INT"
109 gdb_test "whatis int_high" "type = INT"
110 gdb_test "print int_high" " = 32767"
111}
112
113proc test_UINT {} {
114 gdb_test "ptype uint_low" "type = UINT"
115 gdb_test "whatis uint_low" "type = UINT"
116 gdb_test "print uint_low" " = 0"
117 gdb_test "ptype uint_high" "type = UINT"
118 gdb_test "whatis uint_high" "type = UINT"
119 gdb_test "print uint_high" " = 65535"
120}
121
122proc test_LONG {} {
123 gdb_test "ptype long_low" "type = LONG"
124 gdb_test "whatis long_low" "type = LONG"
125 gdb_test "print long_low" " = -2147483648"
126 gdb_test "ptype long_high" "type = LONG"
127 gdb_test "whatis long_high" "type = LONG"
128 gdb_test "print long_high" " = 2147483647"
129}
130
131proc test_ULONG {} {
132 gdb_test "ptype ulong_low" "type = ULONG"
133 gdb_test "whatis ulong_low" "type = ULONG"
134 gdb_test "print ulong_low" " = 0"
135 gdb_test "ptype ulong_high" "type = ULONG"
136 gdb_test "whatis ulong_high" "type = ULONG"
137 gdb_test "print ulong_high" " = 4294967295"
138}
139
140proc test_REAL {} {
141 gdb_test "ptype real1" "type = FLOAT"
142 gdb_test "whatis real1" "type = FLOAT"
143 gdb_test "print real1" " = 3.14159274"
144}
145
146proc test_LONG_REAL {} {
147 gdb_test "ptype long_real1" "type = DOUBLE"
148 gdb_test "whatis long_real1" "type = DOUBLE"
149 gdb_test "print long_real1" " = 3\\.1400000000000001e\\+300"
150}
151
152proc test_POWERSET {} {
153}
154
155proc test_arrays {} {
156 gdb_test "ptype booltable1" "type = ARRAY \[(\]+0:3\[)\]+ BOOL"
157 gdb_test_exact "print booltable1" \
158 { = [(0): TRUE, (1:2): FALSE, (3): TRUE]}
159
160 gdb_test "ptype booltable2" "type = ARRAY \[(\]+4:7\[)\]+ BOOL"
161 gdb_test_exact "print booltable2" { = [(4): TRUE, (5:6): FALSE, (7): TRUE]}
162
163 gdb_test "ptype chartable1" "type = ARRAY \[(\]+0:2\[)\]+ CHAR"
164 gdb_test_exact "print chartable1" {= [(0): C'00', (1): C'01', (2): C'02']}
165
166 gdb_test "ptype chartable2" "type = ARRAY \[(\]+3:5\[)\]+ CHAR"
167 gdb_test_exact "print chartable2" \
168 {= [(3): C'00', (4): C'01', (5): C'02']}
169
170 gdb_test "ptype bytetable1" "type = ARRAY \[(\]+0:4\[)\]+ BYTE"
171 gdb_test_exact "print bytetable1" \
172 {= [(0): -2, (1): -1, (2): 0, (3): 1, (4): 2]}
173
174 gdb_test "ptype bytetable2" "type = ARRAY \[(\]+5:9\[)\]+ BYTE"
175 gdb_test_exact "print bytetable2" \
176 {= [(5): -2, (6): -1, (7): 0, (8): 1, (9): 2]}
177
178 gdb_test_exact "ptype bytetable3" \
179 {type = ARRAY (1:2) ARRAY ('c':'d') ARRAY (FALSE:TRUE) BYTE}
180 gdb_test_exact "print bytetable3" \
181 {= [(1): [('c'): [(FALSE): 0, (TRUE): 1], ('d'): [(FALSE): 2, (TRUE): 3]], (2): [('c'): [(FALSE): 4, (TRUE): 5], ('d'): [(FALSE): 6, (TRUE): 7]]]}
182 gdb_test_exact "ptype bytetable4" \
183 {type = ARRAY (1:2) ARRAY ('c':'d') ARRAY (FALSE:TRUE) BYTE}
184 gdb_test_exact "print bytetable4" \
185 {= [(1): [('c'): [(FALSE): 0, (TRUE): 1], ('d'): [(FALSE): 2, (TRUE): 3]], (2
186): [('c'): [(FALSE): 4, (TRUE): 5], ('d'): [(FALSE): 6, (TRUE): 7]]]}
187
188 gdb_test "ptype ubytetable1" "type = ARRAY \[(\]+0:4\[)\]+ UBYTE"
189 gdb_test_exact "print ubytetable1" \
190 {= [(0): 0, (1): 1, (2): 2, (3): 3, (4): 4]}
191
192 gdb_test "ptype ubytetable2" "type = ARRAY \[(\]+5:9\[)\]+ UBYTE"
193 gdb_test_exact "print ubytetable2" \
194 {= [(5): 0, (6): 1, (7): 2, (8): 3, (9): 4]}
195
196 gdb_test "ptype inttable1" "type = ARRAY \[(\]+0:4\[)\]+ INT"
197 gdb_test_exact "print inttable1" \
198 {= [(0): -2, (1): -1, (2): 0, (3): 1, (4): 2]}
199
200 gdb_test "ptype inttable2" "type = ARRAY \[(\]+5:9\[)\]+ INT"
201 gdb_test_exact "print inttable2" \
202 {= [(5): -2, (6): -1, (7): 0, (8): 1, (9): 2]}
203
204 gdb_test "ptype uinttable1" "type = ARRAY \[(\]+0:4\[)\]+ UINT"
205 gdb_test_exact "print uinttable1" \
206 {= [(0): 0, (1): 1, (2): 2, (3): 3, (4): 4]}
207
208 gdb_test "ptype uinttable2" "type = ARRAY \[(\]+5:9\[)\]+ UINT"
209 gdb_test_exact "print uinttable2" \
210 {= [(5): 0, (6): 1, (7): 2, (8): 3, (9): 4]}
211
212 gdb_test "ptype longtable1" "type = ARRAY \[(\]+0:4\[)\]+ LONG"
213 gdb_test_exact "print longtable1" \
214 {= [(0): -2, (1): -1, (2): 0, (3): 1, (4): 2]}
215
216 gdb_test "ptype longtable2" "type = ARRAY \[(\]+5:9\[)\]+ LONG"
217 gdb_test_exact "print longtable2" \
218 {= [(5): -2, (6): -1, (7): 0, (8): 1, (9): 2]}
219
220 gdb_test "ptype ulongtable1" "type = ARRAY \[(\]+0:4\[)\]+ ULONG"
221 gdb_test_exact "print ulongtable1" \
222 {= [(0): 0, (1): 1, (2): 2, (3): 3, (4): 4]}
223
224 gdb_test "ptype ulongtable2" "type = ARRAY \[(\]+5:9\[)\]+ ULONG"
225 gdb_test_exact "print ulongtable2" \
226 {= [(5): 0, (6): 1, (7): 2, (8): 3, (9): 4]}
227
228 gdb_test "ptype realtable1" "type = ARRAY \[(\]+0:4\[)\]+ FLOAT"
229 gdb_test_exact "print realtable1" \
230 {= [(0): -2, (1): -1, (2): 0, (3): 1, (4): 2]}
231
232 gdb_test "ptype realtable2" "type = ARRAY \[(\]+5:9\[)\]+ FLOAT"
233 gdb_test_exact "print realtable2" \
234 {= [(5): -2, (6): -1, (7): 0, (8): 1, (9): 2]}
235
236 gdb_test "ptype longrealtable1" "type = ARRAY \[(\]+0:4\[)\]+ DOUBLE"
237 gdb_test_exact "print longrealtable1" \
238 {= [(0): -2, (1): -1, (2): 0, (3): 1, (4): 2]}
239
240 gdb_test "ptype longrealtable2" "type = ARRAY \[(\]+5:9\[)\]+ DOUBLE"
241 gdb_test_exact "print longrealtable2" \
242 {= [(5): -2, (6): -1, (7): 0, (8): 1, (9): 2]}
243}
244
245proc test_strings {} {
246
247 gdb_test "ptype string1" "type = CHARS \[(\]4\[)\]+"
248 gdb_test "print string1" " = \"abcd\""
249
250 gdb_test "ptype string2" "type = CHARS \[(\]+5\[)\]+"
251 gdb_test "print string2" " = \"ef\"//c\"00\"//\"gh\""
252
253 gdb_test "ptype string3" "type = CHARS \[(\]+6\[)\]+"
254 gdb_test "print string3" " = \"efghij\""
255
256 gdb_test "ptype string4" "type = CHARS \[(\]+7\[)\]+"
257 gdb_test "print string4" " = \"zzzzzz\"//c\"00\""
258
259 # These tests require a running process, so run to one of the procs
260 # and then do the tests.
261
262 if [runto scalar_arithmetic] then {
263 gdb_test "ptype string1//string2" "type = CHARS \\(9\\)"
264 gdb_test "print string1//string2" " = \"abcdef\"//c\"00\"//\"gh\""
265 gdb_test_exact {ptype "a chill string"} {type = CHARS (14)}
266 gdb_test "print 'a chill string'" " = \"a chill string\""
267 gdb_test "print \"ef\"//c'00'//\"gh\"" " = \"ef\"//c\"00\"//\"gh\""
268 gdb_test "print string1 // \"efgh\"" " = \"abcdefgh\""
269 gdb_test "print (6) 'z'" " = \"zzzzzz\""
270 gdb_test "ptype (6) 'z'" "type = CHARS \[(\]+6\[)\]+"
271 gdb_test "print (1+2*3) 'x'" " = \"xxxxxxx\""
272 gdb_test "ptype (1+2*3) 'x'" "type = CHARS \[(\]+7\[)\]+"
273 }
274
275}
276
277proc test_structs {} {
278 gdb_test "ptype struct1" \
279 "type = STRUCT \[(\]+.*abool BOOL,.*aint INT,.*astring CHARS \[(\]+8\[)\]+.*\[)\]+"
280 gdb_test "print struct1" \
281 ".* = \\\[\.abool: TRUE, \.aint: 123, \.astring: \"a string\"\\\]"
282 gdb_test "ptype struct2" \
283 "type = STRUCT \[(\]+.*abool BOOL,.*nstruct simple_struct,.*aint INT.*\[)\]+"
284 gdb_test "print struct2" \
285 ".* = \\\[.abool: TRUE, \.nstruct: \\\[\.abool: FALSE, \.aint: 456, \.astring: \"deadbeef\"\\\], \.aint: 789\\\]"
286}
287
288# Check to see if we have an executable to test. If not, then either we
289# haven't tried to compile one, or the compilation failed for some reason.
290# In either case, just notify the user and skip the tests in this file.
291
605f94ba 292set binfile "chillvars.exe"
16def8c8
SS
293set srcfile $binfile.ch
294
295if ![file exists $objdir/$subdir/$binfile] then {
605f94ba 296 warning "$binfile does not exist; tests suppressed."
16def8c8
SS
297} else {
298 do_tests
299}
This page took 0.033427 seconds and 4 git commands to generate.