1 # Copyright (C) 1992, 1995 Free Software Foundation, Inc.
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.
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.
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. */
17 # Please email any bugs, comments, and/or additions to this file to:
18 # bug-gdb@prep.ai.mit.edu
27 # Set the current language to chill. This counts as a test. If it
28 # fails, then we skip the other tests.
31 set srcfile ${srcdir}/$subdir/${testfile}.ch
32 set binfile ${objdir}/${subdir}/${testfile}.exe
33 if { [compile "${srcfile} -g -w -o ${binfile} ${CHILL_RT0} ${CHILL_LIB}"] != "" } {
34 perror "Couldn't compile ${srcfile}"
38 proc set_lang_chill {} {
40 global binfile objdir subdir
42 if ![file exists $objdir/$subdir/$binfile] then {
45 verbose "loading file '$objdir/$subdir/$binfile'"
46 gdb_load $objdir/$subdir/$binfile
48 send "set language chill\n"
51 timeout { fail "set language chill (timeout)" ; return 0 }
54 send "show language\n"
56 -re ".* source language is \"chill\".*$prompt $" {
57 pass "set language to \"chill\""
58 send "break dummyfunc\n"
62 expect -re ".*$prompt $" {}
66 fail "can't set breakpoint (timeout)"
72 fail "setting language to \"chill\""
76 fail "can't show language (timeout)"
82 # checks if structure was accessed correctly
83 proc test_write { args } {
86 if [llength $args]==5 then {
87 set message [lindex $args 4]
88 set extended [lindex $args 3]
89 set matchval [lindex $args 2]
90 } elseif [llength $args]==4 then {
91 set message [lindex $args 3]
92 set matchval [lindex $args 2]
94 } elseif [llength $args]==3 then {
95 set message [lindex $args 2]
98 warning "test ($args) write called with wrong number of arguments"
102 set location [lindex $args 0]
103 set value [lindex $args 1]
104 if ![info exists matchval] then {
107 verbose "loc: $location, val: $value, msg: $message, ext: $extended, match: $matchval"
109 verbose "setting var $value..."
110 send "set var $location.m$extended := $value\n"
111 expect -re ".*$prompt $" {}
112 gdb_test "print $location" \
113 ".*= \[\[\]\\.p1: 2863311530, \\.m: $matchval, \\.p2: 1431655765\[\]\]"\
117 # test write access from gdb (setvar x:=y) from gdb
118 proc write_access { } {
120 verbose "testing write access to locations"
123 test_write b1 127 "byte write 1"
124 test_write b1 -128 "byte write 2"
125 test_write b1 0 "byte write 3"
126 test_write ub1 255 "ubyte write 1"
127 test_write ub1 0 "ubyte write 2"
128 test_write ub1 42 "ubyte write 3"
129 test_write i1 32767 "int write 1"
130 test_write i1 -32768 "int write 2"
131 test_write i1 0 "int write 3"
132 test_write ui1 65535 "uint write 1"
133 test_write ui1 0 "uint write 2"
134 test_write ui1 123 "uint write 3"
135 test_write l1 2147483647 "long write 1"
136 test_write l1 -2147483648 "long write 2"
137 test_write l1 0 "long write 3"
138 test_write ul1 4294967295 "ulong write 1"
139 test_write ul1 0 "ulong write 2"
140 test_write ul1 1000000 "ulong write 3"
141 test_write bo1 FALSE "bool write 1"
142 test_write bo1 TRUE "bool write 2"
143 test_write c1 \"1234\" "char write 1"
144 test_write c2 \"1234567\" "char write 2"
145 test_write c3 \"654321\" "char write 3"
146 test_write c4 C'65' 'e' "char write 4"
147 test_write bi1 B'10100101' "bitstring write 1"
148 test_write bi2 B'0101001010' "bitstring write 2"
149 test_write se1 a "set write 1"
150 test_write se1 h "set write 2"
151 # The following two use numbered sets with too-large values.
153 test_write nse1 nb "numbered set write 1"
155 test_write nse1 nc "numbered set write 2"
156 test_write r1 127 "range write 1"
157 test_write r2 32767 "range write 2"
158 test_write r3 2147483647 "range write 3"
161 test_write p1 {[pa:ph]} {\[pa:ph\]} "powerset write 1"
162 test_write p1 {[pa, pc:pf, ph]} {\[pa, pc:pf, ph\]} "powerset write 2"
163 test_write p1 {[pa, pc, pe, pg]} {\[pa, pc, pe, pg\]} "powerset write 3"
164 test_write p1 {[]} {\[\]} "powerset write 4"
165 test_write p2 {[1:32]} {\[1:32\]} "powerset write 5"
166 test_write p2 {[1, 3:30, 32]} {\[1, 3:30, 32\]} "powerset write 6"
167 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\]} \
169 test_write p2 {[]} {\[\]} "powerset write 8"
171 # Fixme: this should be rejected by gnuchill
172 # test_write p3 {[-2147483648:2147483647]} {\[-2147483648:2147483647\]} \
174 # test_write p3 {[-2147483648, -1000000:1000000, 2147483647]} \
175 # {\[-2147483648, -1000000:1000000, 2147483647\]} \
176 # "powerset write 10"
177 # test_write p3 {[-99, -97, -95, 1001, 1003, 1005]} \
178 # {\[-99, -97, -95, 1001, 1003, 1005\]} "powerset write 11"
179 # test_write p3 {[]} {\[\]} "powerset write 12"
182 test_write ref1 ->ref1 {H'[0-9a-fA-F]+} "reference write 1"
183 test_write ref2 ->b1 {H'[0-9a-fA-F]+} "reference write 2"
184 test_write ref1 NULL "reference write 3"
185 test_write ref2 NULL "reference write 4"
188 test_write pr1 NULL "procefure write 1"
189 # FIXME: remove when NULL is understood
190 test_write pr1 0 NULL "procefure write 2"
191 test_write pr1 dummyfunc {H'[0-9a-fA-F]+ <dummyfunc>} "procedure write 3"
193 # timing modes, FIXME when callbacks to timefunctions are implemented
194 #test_write ti1 abstime(1970, 3, 12, 10, 43, 0) {} "time write 1"
195 #test_write ti2 <set somehow a duration>
196 xfail "timing modes not implemented yet"
200 test_write re1 42.03 {42.0[0-9]*} "real write 1"
201 test_write re1 0 "real write 2"
202 test_write re1 "1e+38" {1e\+38|1\.0[0-9]*e\+38|9\.9[0-9]*e\+37} \
204 test_write re1 "1e+39" Infinity "real write 4"
205 test_write re2 42.03 {42.0[0-9]*} "real write 5"
206 test_write re2 0 "real write 6"
207 test_write re2 "1e+308" {1e\+308} "real write 7"
208 test_write re2 "1e+309" Infinity "real write 8"
211 test_write arrl1 {[(1:3): [(1:2): -128]]} {\[\(1:3\): \[\(1:2\): -128\]\]}\
213 test_write arrl1 {[(1:3): [(1:2): 0]]} {\[\(1:3\): \[\(1:2\): 0\]\]}\
215 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\]\]}\
217 test_write arrl1 {[(1:3): [(1:2): 0]]} {\[\(1:3\): \[\(1:2\): 0\]\]}\
220 # Bogus test case - type mismatch?
221 test_write arrl1 {[(1): 127, (2): -128]} "array write 5"
222 test_write arrl1 {[(1:3): [(1:2): 0]]} {\[\(1:3\): \[\(1:2\): 0\]\]}\
226 test_write strul1 {[.a: -32768, .b: 32767, .ch: "ZZZZ"]} \
227 {\[\.a: -32768, \.b: 32767, \.ch: \"ZZZZ\"\]} \
229 test_write strul1 {[.a: 0, .b: 0, .ch: "0000"]} \
230 {\[\.a: 0, \.b: 0, \.ch: \"0000\"\]} \
232 test_write strul1 -32768 {\[\.a: -32768, \.b: 0, \.ch: \"0000\"\]} \
233 {.a} "structure write 3"
234 test_write strul1 {[.a: 0, .b: 0, .ch: "0000"]} \
235 {\[\.a: 0, \.b: 0, \.ch: \"0000\"\]} \
237 test_write strul1 -32768 {\[\.a: 0, \.b: -32768, \.ch: \"0000\"\]} \
238 {.b} "structure write 5"
239 test_write strul1 {[.a: 0, .b: 0, .ch: "0000"]} \
240 {\[\.a: 0, \.b: 0, \.ch: \"0000\"\]} \
242 test_write strul1 \"HUGO\" {\[\.a: 0, \.b: 0, \.ch: \"HUGO\"\]} \
243 {.ch} "structure write 7"
246 # Start with a fresh gdb.
248 set binfile "tests2.exe"
252 gdb_reinitialize_dir $srcdir/$subdir
254 send "set print sevenbit-strings\n" ; expect -re ".*$prompt $"
256 if [set_lang_chill] then {
259 warning "$test_name tests suppressed."