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
|
# Copyright (C) 1992, 1995 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., 675 Mass Ave, Cambridge, MA 02139, USA. */
# Please email any bugs, comments, and/or additions to this file to:
# bug-gdb@prep.ai.mit.edu
if $tracelevel then {
strace $tracelevel
}
if [skip_chill_tests] then { continue }
set prms_id 0
set bug_id 0
# Set the current language to chill. This counts as a test. If it
# fails, then we skip the other tests.
set testfile "tests2"
set srcfile ${srcdir}/$subdir/${testfile}.ch
set binfile ${objdir}/${subdir}/${testfile}.exe
if { [compile "${srcfile} -g -w -o ${binfile} ${CHILL_RT0} ${CHILL_LIB}"] != "" } {
perror "Couldn't compile ${srcfile}"
return -1
}
global infinity
if [istarget "i*86-*-sysv4*"] then {
set infinity "inf"
} else {
set infinity "Infinity"
}
proc set_lang_chill {} {
global prompt
global binfile objdir subdir
if ![file exists $objdir/$subdir/$binfile] then {
return 0
}
verbose "loading file '$objdir/$subdir/$binfile'"
gdb_load $objdir/$subdir/$binfile
send "set language chill\n"
expect {
-re ".*$prompt $" {}
timeout { fail "set language chill (timeout)" ; return 0 }
}
send "show language\n"
expect {
-re ".* source language is \"chill\".*$prompt $" {
pass "set language to \"chill\""
send "break dummyfunc\n"
expect {
-re ".*$prompt $" {
send "run\n"
expect -re ".*$prompt $" {}
return 1
}
timeout {
fail "can't set breakpoint (timeout)"
return 0
}
}
}
-re ".*$prompt $" {
fail "setting language to \"chill\""
return 0
}
timeout {
fail "can't show language (timeout)"
return 0
}
}
}
# checks if structure was accessed correctly
proc test_write { args } {
global prompt
if [llength $args]==5 then {
set message [lindex $args 4]
set extended [lindex $args 3]
set matchval [lindex $args 2]
} elseif [llength $args]==4 then {
set message [lindex $args 3]
set matchval [lindex $args 2]
set extended ""
} elseif [llength $args]==3 then {
set message [lindex $args 2]
set extended ""
} else {
warning "test ($args) write called with wrong number of arguments"
return
}
set location [lindex $args 0]
set value [lindex $args 1]
if ![info exists matchval] then {
set matchval $value
}
verbose "loc: $location, val: $value, msg: $message, ext: $extended, match: $matchval"
verbose "setting var $value..."
send "set var $location.m$extended := $value\n"
expect -re ".*$prompt $" {}
gdb_test "print $location" \
".*= \[\[\]\\.p1: 2863311530, \\.m: $matchval, \\.p2: 1431655765\[\]\]"\
"$message"
}
# test write access from gdb (setvar x:=y) from gdb
proc write_access { } {
global infinity
verbose "testing write access to locations"
# discrete modes
test_write b1 127 "byte write 1"
test_write b1 -128 "byte write 2"
test_write b1 0 "byte write 3"
test_write ub1 255 "ubyte write 1"
test_write ub1 0 "ubyte write 2"
test_write ub1 42 "ubyte write 3"
test_write i1 32767 "int write 1"
test_write i1 -32768 "int write 2"
test_write i1 0 "int write 3"
test_write ui1 65535 "uint write 1"
test_write ui1 0 "uint write 2"
test_write ui1 123 "uint write 3"
test_write l1 2147483647 "long write 1"
test_write l1 -2147483648 "long write 2"
test_write l1 0 "long write 3"
test_write ul1 4294967295 "ulong write 1"
test_write ul1 0 "ulong write 2"
test_write ul1 1000000 "ulong write 3"
test_write bo1 FALSE "bool write 1"
test_write bo1 TRUE "bool write 2"
test_write c1 \"1234\" "char write 1"
test_write c2 \"1234567\" "char write 2"
test_write c3 \"654321\" "char write 3"
test_write c4 C'65' 'e' "char write 4"
test_write bi1 B'10100101' "bitstring write 1"
test_write bi2 B'0101001010' "bitstring write 2"
test_write se1 a "set write 1"
test_write se1 h "set write 2"
# The following two use numbered sets with too-large values.
setup_xfail "*-*-*"
test_write nse1 nb "numbered set write 1"
setup_xfail "*-*-*"
test_write nse1 nc "numbered set write 2"
test_write r1 127 "range write 1"
test_write r2 32767 "range write 2"
test_write r3 2147483647 "range write 3"
# powerset modes
test_write p1 {[pa:ph]} {\[pa:ph\]} "powerset write 1"
test_write p1 {[pa, pc:pf, ph]} {\[pa, pc:pf, ph\]} "powerset write 2"
test_write p1 {[pa, pc, pe, pg]} {\[pa, pc, pe, pg\]} "powerset write 3"
test_write p1 {[]} {\[\]} "powerset write 4"
test_write p2 {[1:32]} {\[1:32\]} "powerset write 5"
test_write p2 {[1, 3:30, 32]} {\[1, 3:30, 32\]} "powerset write 6"
test_write p2 {[1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31]} {\[1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31\]} \
"powerset write 7"
test_write p2 {[]} {\[\]} "powerset write 8"
# Fixme: this should be rejected by gnuchill
# test_write p3 {[-2147483648:2147483647]} {\[-2147483648:2147483647\]} \
# "powerset write 9"
# test_write p3 {[-2147483648, -1000000:1000000, 2147483647]} \
# {\[-2147483648, -1000000:1000000, 2147483647\]} \
# "powerset write 10"
# test_write p3 {[-99, -97, -95, 1001, 1003, 1005]} \
# {\[-99, -97, -95, 1001, 1003, 1005\]} "powerset write 11"
# test_write p3 {[]} {\[\]} "powerset write 12"
# reference modes
test_write ref1 ->ref1 {H'[0-9a-fA-F]+} "reference write 1"
test_write ref2 ->b1 {H'[0-9a-fA-F]+} "reference write 2"
test_write ref1 NULL "reference write 3"
test_write ref2 NULL "reference write 4"
# procedure modes
test_write pr1 NULL "procefure write 1"
# FIXME: remove when NULL is understood
test_write pr1 0 NULL "procefure write 2"
test_write pr1 dummyfunc {H'[0-9a-fA-F]+ <dummyfunc>} "procedure write 3"
# timing modes, FIXME when callbacks to timefunctions are implemented
#test_write ti1 abstime(1970, 3, 12, 10, 43, 0) {} "time write 1"
#test_write ti2 <set somehow a duration>
xfail "timing modes not implemented yet"
# real modes
# This ones
test_write re1 42.03 {42.0[0-9]*} "real write 1"
test_write re1 0 "real write 2"
test_write re1 "1e+38" {1e\+38|1\.0[0-9]*e\+38|9\.9[0-9]*e\+37} \
"real write 3"
setup_xfail "i*86-*-linux" "mips-sgi-irix*"
test_write re1 "1e+39" $infinity "real write 4"
test_write re2 42.03 {42.0[0-9]*} "real write 5"
test_write re2 0 "real write 6"
test_write re2 "1e+308" {1e\+308} "real write 7"
setup_xfail "i*86-*-linux" "mips-sgi-irix*"
test_write re2 "1e+309" $infinity "real write 8"
# array modes
test_write arrl1 {[(1:3): [(1:2): -128]]} {\[\(1:3\): \[\(1:2\): -128\]\]}\
"array write 1"
test_write arrl1 {[(1:3): [(1:2): 0]]} {\[\(1:3\): \[\(1:2\): 0\]\]}\
"array write 2"
test_write arrl1 {[(1): [(1:2): 127], (2): [(1:2): -128], (3): [(1:2): 127]]} {\[\(1\): \[\(1:2\): 127\], \(2\): \[\(1:2\): -128\], \(3\): \[\(1:2\): 127\]\]}\
"array write 3"
test_write arrl1 {[(1:3): [(1:2): 0]]} {\[\(1:3\): \[\(1:2\): 0\]\]}\
"array write 4"
setup_xfail "*-*-*"
# Bogus test case - type mismatch?
test_write arrl1 {[(1): 127, (2): -128]} "array write 5"
test_write arrl1 {[(1:3): [(1:2): 0]]} {\[\(1:3\): \[\(1:2\): 0\]\]}\
"array write 6"
# structure modes
test_write strul1 {[.a: -32768, .b: 32767, .ch: "ZZZZ"]} \
{\[\.a: -32768, \.b: 32767, \.ch: \"ZZZZ\"\]} \
"structure write 1"
test_write strul1 {[.a: 0, .b: 0, .ch: "0000"]} \
{\[\.a: 0, \.b: 0, \.ch: \"0000\"\]} \
"structure write 2"
test_write strul1 -32768 {\[\.a: -32768, \.b: 0, \.ch: \"0000\"\]} \
{.a} "structure write 3"
test_write strul1 {[.a: 0, .b: 0, .ch: "0000"]} \
{\[\.a: 0, \.b: 0, \.ch: \"0000\"\]} \
"structure write 4"
test_write strul1 -32768 {\[\.a: 0, \.b: -32768, \.ch: \"0000\"\]} \
{.b} "structure write 5"
test_write strul1 {[.a: 0, .b: 0, .ch: "0000"]} \
{\[\.a: 0, \.b: 0, \.ch: \"0000\"\]} \
"structure write 6"
test_write strul1 \"HUGO\" {\[\.a: 0, \.b: 0, \.ch: \"HUGO\"\]} \
{.ch} "structure write 7"
}
# Start with a fresh gdb.
set binfile "tests2.exe"
gdb_exit
gdb_start
gdb_reinitialize_dir $srcdir/$subdir
send "set print sevenbit-strings\n" ; expect -re ".*$prompt $"
if [set_lang_chill] then {
write_access
} else {
warning "$test_name tests suppressed."
}
|