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