Create tdep->rl78_psw_type lazily
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.base / all-architectures.exp.in
CommitLineData
f1b5deee
PA
1# Copyright (C) 2016 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 3 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, see <http://www.gnu.org/licenses/>.
15
16# This file is part of the gdb testsuite.
17
18# Test manually setting _all_ combinations of all supported bfd
19# architectures and OS ABIs. This ensures that gdbarch initialization
20# routines handle unusual combinations gracefully, at least without
21# crashing.
22
23# While at it, because the number of possible combinations is quite
24# large, embed other checks that might be useful to do with all
25# supported archs.
26
27# One such test is ensuring that printing float, double and long
28# double types works in cross/bi-arch scenarios. Some of GDB's float
29# format conversion routines used to fail to consider that even if
30# host and target floating formats match, their sizes may still
31# differ. E.g., on x86, long double is 80-bit extended precision on
32# both 32-bit vs 64-bit, but it's stored as 96 bit on 32-bit, and 128
33# bit on 64-bit. This resulted in GDB accessing memory out of bounds.
34# This test catches the issue when run against gdb linked with
35# libmcheck, or run under Valgrind.
36
37# Note: this test is actually split in several driver .exp files, in
38# order to be able to parallelize the work. Each driver .exp file
39# exercises a different slice of the supported architectures. See
40# all-architectures-*.exp and the TEST_SLICE variable.
41
42clean_restart
43
44# By default, preparation steps don't output a PASS message. This is
45# because the testcase has several thousand such steps.
46set want_tests_messages 0
47
48# Call this when an "internal" preparation-like step test passed.
49# Logs the pass in gdb.log, but not in gdb.sum.
50
51proc internal_pass {message} {
52 global want_tests_messages
53
54 if {$want_tests_messages} {
55 pass $message
56 } else {
57 # Skip the sum file, but still log an internal pass in the log
58 # file.
59 global pf_prefix
60
61 verbose -log "IPASS: $pf_prefix $message"
62 }
63}
64
65# The number of times gdb_test_internal was called, and the number of
66# time that resulted in an internal pass. If these don't match, then
67# some test failed.
68set test_count 0
69set internal_pass_count 0
70
71# Like gdb_test, but calls internal_pass instead of pass, on success.
72
73proc gdb_test_internal {cmd pattern {message ""}} {
74 global test_count internal_pass_count
75 global gdb_prompt
76
77 incr test_count
78
79 if {$message == ""} {
80 set message $cmd
81 }
82
83 gdb_test_multiple $cmd $message {
84 -re "$pattern\r\n$gdb_prompt $" {
85 internal_pass $message
86 incr internal_pass_count
87 }
88 }
89}
90
91gdb_test_internal "set max-completions unlimited" \
92 "^set max-completions unlimited"
93
94# Return a list of all the accepted values of "set WHAT".
95
96proc get_set_option_choices {what} {
97 global gdb_prompt
98
99 set values {}
100
101 set test "complete set $what"
102 gdb_test_multiple "complete set $what " "$test" {
103 -re "set $what (\[^\r\n\]+)\r\n" {
104 lappend values $expect_out(1,string)
105 exp_continue
106 }
107 -re "$gdb_prompt " {
108 internal_pass $test
109 }
110 }
111 return $values
112}
113
114set supported_archs [get_set_option_choices "architecture"]
115# There should be at least one more than "auto".
116gdb_assert {[llength $supported_archs] > 1} "at least one architecture"
117
118set supported_osabis [get_set_option_choices "osabi"]
119# There should be at least one more than "auto" and "default".
120gdb_assert {[llength $supported_osabis] > 2} "at least one osabi"
121
122if {[lsearch $supported_archs "mips"] >= 0} {
123 set supported_mipsfpu [get_set_option_choices "mipsfpu"]
124 set supported_mips_abi [get_set_option_choices "mips abi"]
125
126 gdb_assert {[llength $supported_mipsfpu] != 0} "at least one mipsfpu"
127 gdb_assert {[llength $supported_mips_abi] != 0} "at least one mips abi"
128}
129
130if {[lsearch $supported_archs "arm"] >= 0} {
131 set supported_arm_fpu [get_set_option_choices "arm fpu"]
132 set supported_arm_abi [get_set_option_choices "arm abi"]
133
134 gdb_assert {[llength $supported_arm_fpu] != 0} "at least one arm fpu"
135 gdb_assert {[llength $supported_arm_abi] != 0} "at least one arm abi"
136}
137
138# Exercise printing float, double and long double.
139
140proc print_floats {} {
141 gdb_test_internal "ptype 1.0L" "type = long double" "ptype, long double"
142 gdb_test_internal "print 1.0L" " = 1" "print, long double"
143
144 gdb_test_internal "ptype 1.0" "type = double" "ptype, double"
145 gdb_test_internal "print 1.0" " = 1" "print, double"
146
147 gdb_test_internal "ptype 1.0f" "type = float" "ptype, float"
148 gdb_test_internal "print 1.0f" " = 1" "print, float"
149}
150
151# Run tests on the current architecture.
152
153proc do_arch_tests {} {
154 print_floats
155}
156
157# Given we can't change arch, osabi, endianness, etc. atomically, we
158# need to silently ignore the case of the current OS ABI (not the one
159# we'll switch to) not having a handler for the arch.
160set osabi_warning \
161 [multi_line \
162 "warning: A handler for the OS ABI .* is not built into this configuration" \
163 "of GDB. Attempting to continue with the default .* settings." \
164 "" \
165 "" \
166 ]
167
168set endian_warning "(Little|Big) endian target not supported by GDB\r\n"
169
170# Like gdb_test_no_output, but use internal_pass instead of pass, and
171# ignore "no handler for OS ABI" warnings.
172
173proc gdb_test_no_output_osabi {cmd test} {
174 global osabi_warning
175 global gdb_prompt
176
177 gdb_test_multiple "$cmd" $test {
178 -re "^${cmd}\r\n(${osabi_warning})?$gdb_prompt $" {
179 internal_pass $test
180 }
181 }
182}
183
184# It'd be nicer/safer to restart GDB on each iteration, but, that
185# increases the testcase's run time several times fold. At the time
186# of writting, it'd jump from 20s to 4min on x86-64 GNU/Linux with
187# --enable-targets=all.
188
189set num_slices 8
190set num_archs [llength $supported_archs]
191set archs_per_slice [expr (($num_archs + $num_slices - 1) / $num_slices)]
192
193with_test_prefix "tests" {
194 foreach_with_prefix osabi $supported_osabis {
195
196 gdb_test_no_output_osabi "set osabi $osabi" \
197 "set osabi"
198
199 set arch_count 0
200 foreach_with_prefix arch $supported_archs {
201
202 incr arch_count
203
204 # Skip architectures outside our slice.
205 if {$arch_count < [expr $test_slice * $archs_per_slice]} {
206 continue
207 }
208 if {$arch_count >= [expr ($test_slice + 1) * $archs_per_slice]} {
209 continue
210 }
211
f1b5deee
PA
212 if {$arch == "rx"} {
213 if {$want_tests_messages} {
214 kfail "set architecture rx" "gdb/20954"
215 }
216 continue
217 }
218
219 if {$arch == "auto"} {
220 continue
221 }
222 set default_endian ""
223 foreach_with_prefix endian {"auto" "big" "little"} {
224
225 set test "set endian"
226 if {$endian == $default_endian} {
227 continue
228 } elseif {$endian == "auto"} {
229 gdb_test_multiple "set endian $endian" $test {
230 -re "^set endian $endian\r\n(${osabi_warning})?The target endianness is set automatically \\(currently .* endian\\)\r\n$gdb_prompt $" {
231 internal_pass $test
232 }
233 }
234 } else {
235 gdb_test_multiple "set endian $endian" $test {
236 -re "^set endian $endian\r\n${endian_warning}.*\r\n$gdb_prompt $" {
237 internal_pass $test
238 continue
239 }
240 -re "^set endian $endian\r\n(${osabi_warning})?The target is assumed to be $endian endian\r\n$gdb_prompt $" {
241 internal_pass $test
242 }
243 }
244 }
245
246 # Skip setting the same architecture again.
247 if {$endian == "auto"} {
248 set arch_re [string_to_regexp $arch]
249 set test "set architecture $arch"
250 gdb_test_multiple $test $test {
251 -re "^set architecture $arch_re\r\n(${osabi_warning})?The target architecture is assumed to be $arch_re\r\n$gdb_prompt $" {
252 internal_pass $test
253 }
254 -re "Architecture .* not recognized.*$gdb_prompt $" {
255 # GDB is missing support for a few
256 # machines that bfd supports.
257 if {$arch == "powerpc:EC603e"
258 || $arch == "powerpc:e500mc"
259 || $arch == "powerpc:e500mc64"
260 || $arch == "powerpc:vle"
261 || $arch == "powerpc:titan"
262 || $arch == "powerpc:e5500"
263 || $arch == "powerpc:e6500"} {
264 if {$want_tests_messages} {
265 kfail $test "gdb/19797"
266 }
267 } else {
268 fail "$test (arch not recognized)"
269 }
270 continue
271 }
272 }
273
274 # Record what is the default endianess. As an
275 # optimization, we'll skip testing the manual "set
276 # endian DEFAULT" case.
277 set test "show endian"
278 gdb_test_multiple "show endian" $test {
279 -re "currently little endian.*$gdb_prompt $" {
280 set default_endian "little"
281 internal_pass $test
282 }
283 -re "currently big endian.*$gdb_prompt $" {
284 set default_endian "big"
285 internal_pass $test
286 }
287 }
288 }
289
290 # Some architectures have extra settings that affect
291 # the ABI. Specify the extra testing axes in a
292 # declarative form.
293 #
294 # A list of {COMMAND, VAR, OPTIONS-LIST} elements.
295 set all_axes {}
296
297 if {$arch == "mips"} {
298 lappend all_axes [list "set mips abi" mips_abi $supported_mips_abi]
299 lappend all_axes [list "set mipsfpu" mipsfpu $supported_mipsfpu]
300 } elseif {$arch == "arm"} {
301 lappend all_axes [list "set arm abi" arm_abi $supported_arm_abi]
302 lappend all_axes [list "set arm fpu" arm_fpu $supported_arm_fpu]
303 }
304
305 # Run testing axis CUR_AXIS. This is a recursive
306 # procedure that tries all combinations of options of
307 # all the testing axes.
308 proc run_axis {all_axes cur_axis} {
309 if {$cur_axis == [llength $all_axes]} {
310 do_arch_tests
311 return
312 }
313
314 # Unpack the axis.
315 set axis [lindex $all_axes $cur_axis]
316 set cmd [lindex $axis 0]
317 set var [lindex $axis 1]
318 set options [lindex $axis 2]
319
320 foreach v $options {
321 with_test_prefix "$var=$v" {
322 gdb_test_no_output_osabi "$cmd $v" "$cmd"
323 run_axis $all_axes [expr $cur_axis + 1]
324 }
325 }
326 }
327
328 run_axis $all_axes 0
329 }
330 }
331 }
332}
333
334# A test that:
335#
336# - ensures there's a PASS if all internal tests actually passed
337#
338# - ensures there's at least one test that is interpreted as a
339# regression (a matching PASS->FAIL) if some of the internal tests
340# failed, instead of looking like it could be a new FAIL that could
341# be ignored.
342#
343gdb_assert {$internal_pass_count == $test_count} "all passed"
This page took 0.03839 seconds and 4 git commands to generate.