8daa743554020f04bd336f32fc0f64459c2299d9
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.chill / tests2.exp
1 # Copyright (C) 1992, 1995 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 if $tracelevel then {
21 strace $tracelevel
22 }
23
24 set prms_id 0
25 set bug_id 0
26
27 # Set the current language to chill. This counts as a test. If it
28 # fails, then we skip the other tests.
29
30 set testfile "tests2"
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}"
35 return -1
36 }
37
38 proc set_lang_chill {} {
39 global prompt
40 global binfile objdir subdir
41
42 if ![file exists $objdir/$subdir/$binfile] then {
43 return 0
44 }
45 verbose "loading file '$objdir/$subdir/$binfile'"
46 gdb_load $objdir/$subdir/$binfile
47
48 send "set language chill\n"
49 expect {
50 -re ".*$prompt $" {}
51 timeout { fail "set language chill (timeout)" ; return 0 }
52 }
53
54 send "show language\n"
55 expect {
56 -re ".* source language is \"chill\".*$prompt $" {
57 pass "set language to \"chill\""
58 send "break dummyfunc\n"
59 expect {
60 -re ".*$prompt $" {
61 send "run\n"
62 expect -re ".*$prompt $" {}
63 return 1
64 }
65 timeout {
66 fail "can't set breakpoint (timeout)"
67 return 0
68 }
69 }
70 }
71 -re ".*$prompt $" {
72 fail "setting language to \"chill\""
73 return 0
74 }
75 timeout {
76 fail "can't show language (timeout)"
77 return 0
78 }
79 }
80 }
81
82 # checks if structure was accessed correctly
83 proc test_write { args } {
84 global prompt
85
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]
93 set extended ""
94 } elseif [llength $args]==3 then {
95 set message [lindex $args 2]
96 set extended ""
97 } else {
98 warning "test ($args) write called with wrong number of arguments"
99 return
100 }
101
102 set location [lindex $args 0]
103 set value [lindex $args 1]
104 if ![info exists matchval] then {
105 set matchval $value
106 }
107 verbose "loc: $location, val: $value, msg: $message, ext: $extended, match: $matchval"
108
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\[\]\]"\
114 "$message"
115 }
116
117 # test write access from gdb (setvar x:=y) from gdb
118 proc write_access { } {
119
120 verbose "testing write access to locations"
121
122 # discrete modes
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.
152 setup_xfail "*-*-*"
153 test_write nse1 nb "numbered set write 1"
154 setup_xfail "*-*-*"
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"
159
160 # powerset modes
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\]} \
168 "powerset write 7"
169 test_write p2 {[]} {\[\]} "powerset write 8"
170
171 # Fixme: this should be rejected by gnuchill
172 # test_write p3 {[-2147483648:2147483647]} {\[-2147483648:2147483647\]} \
173 # "powerset write 9"
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"
180
181 # reference modes
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"
186
187 # procedure modes
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"
192
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"
197
198 # real modes
199 # This ones
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} \
203 "real write 3"
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"
209
210 # array modes
211 test_write arrl1 {[(1:3): [(1:2): -128]]} {\[\(1:3\): \[\(1:2\): -128\]\]}\
212 "array write 1"
213 test_write arrl1 {[(1:3): [(1:2): 0]]} {\[\(1:3\): \[\(1:2\): 0\]\]}\
214 "array write 2"
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\]\]}\
216 "array write 3"
217 test_write arrl1 {[(1:3): [(1:2): 0]]} {\[\(1:3\): \[\(1:2\): 0\]\]}\
218 "array write 4"
219 setup_xfail "*-*-*"
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\]\]}\
223 "array write 6"
224
225 # structure modes
226 test_write strul1 {[.a: -32768, .b: 32767, .ch: "ZZZZ"]} \
227 {\[\.a: -32768, \.b: 32767, \.ch: \"ZZZZ\"\]} \
228 "structure write 1"
229 test_write strul1 {[.a: 0, .b: 0, .ch: "0000"]} \
230 {\[\.a: 0, \.b: 0, \.ch: \"0000\"\]} \
231 "structure write 2"
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\"\]} \
236 "structure write 4"
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\"\]} \
241 "structure write 6"
242 test_write strul1 \"HUGO\" {\[\.a: 0, \.b: 0, \.ch: \"HUGO\"\]} \
243 {.ch} "structure write 7"
244 }
245
246 # Start with a fresh gdb.
247
248 set binfile "tests2.exe"
249
250 gdb_exit
251 gdb_start
252 gdb_reinitialize_dir $srcdir/$subdir
253
254 send "set print sevenbit-strings\n" ; expect -re ".*$prompt $"
255
256 if [set_lang_chill] then {
257 write_access
258 } else {
259 warning "$test_name tests suppressed."
260 }
This page took 0.039276 seconds and 3 git commands to generate.