]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - gdb/testsuite/gdb.base/crossload.exp
* config/sh/tm-sh.h (BELIEVE_PCC_PROMOTION): Define, so that
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.base / crossload.exp
CommitLineData
fa5864d5 1# Copyright (C) 1992, 1997 Free Software Foundation, Inc.
ef44eed1
SS
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
fa5864d5 15# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
ef44eed1
SS
16
17# Please email any bugs, comments, and/or additions to this file to:
18# bug-gdb@prep.ai.mit.edu
19
20# This file was written by Fred Fish. (fnf@cygnus.com)
21# Rob Savoye changed it to use gdb_test (rob@cygnus.com)
22
23if $tracelevel then {
24 strace $tracelevel
25}
26
27set prms_id 0
28set bug_id 0
29
30# FIXME: The configure.in for this test should look for --with-targets
31# and deal accordingly. Until that has been done, skip the whole thing.
32# With a minimal bfd (the default), few if any of these tests work.
33
34verbose "FIXME: all the crossload tests ignored"
782445c7
FF
35return
36
37foreach i "m68k-elf m68k-aout m68k-aout2 mips-ecoff i486-elf sparc-aout i860-elf sparc-elf" {
05a21390 38 remote_exec build "cd ${objdir}/${subdir} ; uudecode ${srcdir}/${subdir}/$i.u "
782445c7 39}
ef44eed1
SS
40
41# FIXME: These tests don't work for the i960, because
42# bfd/config/i960-bout.mt sets SELECT_VECS. I could use setup_xfail
43# for each test, but rebooting the board between each one takes a long
44# time so I'm just punting the whole file.
45if [istarget "i960-*-*"] then {
46 if $verbose>1 then {
47 warning "FIXME: crossload test case doesn't run on the i960."
48 }
49 continue
50}
51
52# FIXME: These tests don't work for the a29k, because SELECT_VECS is
53# used when compiling bfd. It would be nice if there were some better
54# way of detecting this case.
55if [istarget "a29k-*-*"] then {
56 if $verbose>1 then {
57 warning "FIXME: crossload test case doesn't run on the a29k."
58 }
59 continue
60}
61
62# Test if gdb can automatically determine the bfd format of an
63# executable and read it's symbols.
64
65proc bfddefault {} {
66 global GDB
67 global GDBFLAGS
85fbaa74 68 global gdb_prompt
ef44eed1
SS
69 global objdir
70 global subdir
71 global binfile
72 global bfdformat
73 global file_loaded
74
75 gdb_unload
76 set file_loaded 0
787f6220 77 send_gdb "file $objdir/$subdir/$binfile\n"
40ac1624 78 gdb_expect {
ef44eed1 79 -re "A program is being debugged already. Kill it.*y or n." {
787f6220 80 send_gdb "y\n"
ef44eed1
SS
81 exp_continue
82 }
85fbaa74 83 -re "Reading symbols from $objdir/$subdir/$binfile\[.\]+done\..*$gdb_prompt $" {
ef44eed1
SS
84 pass "$binfile ($bfdformat) auto format"
85 }
85fbaa74 86 -re "Reading symbols from $objdir/$subdir/$binfile\[.\]+.no debugging symbols found.\[.\]+done\..*$gdb_prompt $" {
ef44eed1
SS
87 pass "$binfile ($bfdformat) auto format (but no symbols found)"
88 }
85fbaa74 89 -re "File format not recognized.*$gdb_prompt $" {
ef44eed1
SS
90 fail "$binfile ($bfdformat) auto format (format not recognized)"
91 return
92 }
85fbaa74 93 -re "File format is ambiguous.*$gdb_prompt $" {
ef44eed1
SS
94 fail "$binfile ($bfdformat) auto format (format is ambiguous)"
95 return
96 }
85fbaa74 97 -re "$gdb_prompt $" {
ef44eed1
SS
98 fail "$binfile ($bfdformat) auto format"
99 return
100 }
101 timeout {
102 fail "(timeout) $binfile ($bfdformat) auto format"
103 return
104 }
105 }
106
107 if [gdb_test "info target" ".*file type $bfdformat" ""]==0 then {
108 set file_loaded 1
109 } else {
110 fail "$binfile ($bfdformat) wrong format found"
111 }
112}
113
114# Test if gdb can read symbols from an executable when the bfd format
115# is explicitly set via the environment variable GNUTARGET.
116
117proc bfdexplicit {} {
118 global GDB
119 global GDBFLAGS
85fbaa74 120 global gdb_prompt
ef44eed1
SS
121 global subdir
122 global objdir
123 global det_file
124 global binfile
125 global bfdformat
126 global file_loaded
127
128 gdb_unload
129 set file_loaded 0
130
131 # Once GDB 4.10 (the last to lack `set gnutarget') is forgotten,
132 # change this to use set gnutarget.
133 if [gdb_test "set env GNUTARGET=$bfdformat" "" ""]!=0 then {
134 fail "setting GNUTARGET=$bfdformat in environment"
135 return
136 }
137
787f6220 138 send_gdb "file $objdir/$subdir/$binfile\n"
40ac1624 139 gdb_expect {
ef44eed1 140 -re "A program is being debugged already. Kill it.*y or n." {
787f6220 141 send_gdb "y\n"
ef44eed1
SS
142 exp_continue
143 }
85fbaa74 144 -re "Reading symbols from $objdir/$subdir/$binfile\[.\]+done\..*$gdb_prompt $" {
ef44eed1
SS
145 pass "$binfile ($bfdformat) explicit format"
146 }
85fbaa74 147 -re "Invalid target.*$gdb_prompt $" {
ef44eed1
SS
148 fail "$binfile ($bfdformat) explicit format (invalid target)"
149 return
150 }
85fbaa74 151 -re "$gdb_prompt $" {
ef44eed1
SS
152 fail "$binfile ($bfdformat) explicit format"
153 return
154 }
155 timeout {
156 fail "(timeout) $binfile ($bfdformat) explicit format"
157 return
158 }
159 }
160
161 set file_loaded 1
162}
163
164proc test_ptype_functions {} {
85fbaa74 165 global gdb_prompt
ef44eed1
SS
166 global binfile
167 global bfdformat
168 global det_file
787f6220 169 send_gdb "ptype main\n"
40ac1624 170 gdb_expect {
85fbaa74 171 -re "type = int \[)(\]+\r\n$gdb_prompt $" {}
7d03ae5e 172 timeout { fail "(timeout) $binfile ($bfdformat) function main" ; return }
ef44eed1
SS
173 }
174
175 # set up a list of lists of command and patterns
176 set command [list { "ptype v_char_func" "type =(\ unsigned\ |\ signed\ |\ )char \[)(\]+" }\
177 { "ptype v_short_func" "type = (short|short int) \[)(\]+" } \
178 { "ptype v_int_func" "type = int \[)(\]+" } \
179 { "ptype v_long_func" "type = (long|long int|int) \[)(\]+" } \
180 { "ptype v_float_func" "type = float \[)(\]+" } \
181 { "ptype v_double_func" "type = double \[)(\]+" } ]
182
183 foreach i $command {
184 if [gdb_test [lindex $i 0] [lindex $i 1] ""] then {
185 fail "$binfile ($bfdformat) \"[lindex $i 0]\" function types"
186 return
187 }
188 }
189 pass "$binfile ($bfdformat) ptype function types"
190}
191
192# Note that plain chars can be either signed or unsigned.
193
194proc test_ptype_plain_types {} {
85fbaa74 195 global gdb_prompt
ef44eed1
SS
196 global binfile
197 global bfdformat
198
199 # set up a list of lists of command and patterns
200 set command [list { "ptype v_char" "type =(\ unsigned\ |\ signed\ |\ )char" }\
201 { "ptype v_short" "type = short" } \
202 { "ptype v_int" "type = int" } \
203 { "ptype v_long" "type = long" } \
204 { "ptype v_float" "type = float" } \
205 { "ptype v_double" "type = double" } ]
206
207 foreach i $command {
208 if [gdb_test [lindex $i 0] [lindex $i 1] ""] then {
209 fail "$binfile ($bfdformat) \"[lindex $i 0]\" plain C types"
210 return
211 }
212 }
213 pass "$binfile ($bfdformat) ptype plain C types"
214}
215
216# Note that if compiled with pre-ANSI compilers, the "signed" keywords are
217# defined away and the variables default to plain types. So accept either.
218
219proc test_ptype_signed_types {} {
85fbaa74 220 global gdb_prompt
ef44eed1
SS
221 global binfile
222 global bfdformat
223 global det_file
224
225 # set up a list of lists of command and patterns
226 set command [list { "ptype v_signed_char" "type =(\ signed\ |\ )char" }\
227 { "ptype v_signed_short" "type =(\ signed\ |\ )short" } \
228 { "ptype v_signed_int" "type =(\ signed\ |\ )int" } \
229 { "ptype v_signed_long" "type =(\ signed\ |\ )long" } ]
230
231 foreach i $command {
232 if [gdb_test [lindex $i 0] [lindex $i 1] ""] then {
233 if [expr [string match "ecoff-bigmips" $bfdformat]+[string match "ptype v_signed_char" [lindex $i 0]]]==2 then {
234 setup_xfail "*-*-*"
235 }
236 fail "$binfile ($bfdformat) \"[lindex $i 0]\" signed C types"
237 return
238 }
239 }
240 pass "$binfile ($bfdformat) ptype signed C types"
241}
242
243proc test_ptype_unsigned_types {} {
85fbaa74 244 global gdb_prompt
ef44eed1
SS
245 global binfile
246 global bfdformat
247 global det_file
248
249 # set up a list of lists of command and patterns
250 set command [list { "ptype v_unsigned_char" "type = unsigned char" }\
251 { "ptype v_unsigned_short" \
252 "type = (unsigned short|short unsigned int)" } \
253 { "ptype v_unsigned_int" "type = unsigned int" } \
254 { "ptype v_unsigned_long" \
255 "type = (unsigned long|long unsigned int)" } ]
256
257 foreach i $command {
258 if [gdb_test [lindex $i 0] [lindex $i 1] ""] then {
259 fail "$binfile ($bfdformat) \"[lindex $i 0]\" unsigned C types"
260 return
261 }
262 }
263 pass "$binfile ($bfdformat) ptype unsigned C types"
264}
265
266# Note that plain chars can be either signed or unsigned.
267
268proc test_ptype_array_types {} {
85fbaa74 269 global gdb_prompt
ef44eed1
SS
270 global binfile
271 global bfdformat
272 global det_file
273
274 # set up a list of lists of command and patterns
275 set command [list { "ptype v_char_array" "type =(\ unsigned\ |\ signed\ |\ )char \\\[2\\\]" }\
276 { "ptype v_short_array" \
277 "type = (short|short int) \\\[2\\\]" } \
278 { "ptype v_int_array" "type = int \\\[2\\\]" } \
279 { "ptype v_long_array" "type = (long|long int) \\\[2\\\]" } \
280 { "ptype v_float_array" "type = float \\\[2\\\]" } \
281 { "ptype v_double_array" "type = double \\\[2\\\]" } ]
282
283 foreach i $command {
284 if [gdb_test [lindex $i 0] [lindex $i 1] ""] then {
285 fail "$binfile ($bfdformat) \"[lindex $i 0]\" C array types"
286 return
287 }
288 }
289 pass "$binfile ($bfdformat) ptype C array types"
290}
291
292proc test_ptype_pointer_types {} {
85fbaa74 293 global gdb_prompt
ef44eed1
SS
294 global binfile
295 global bfdformat
296 global det_file
297
298 # set up a list of lists of command and patterns
299 set command [list { "ptype v_char_pointer" "type =(\ unsigned\ |\ signed\ |\ )char \*" }\
300 { "ptype v_short_pointer" "type = (short|short int) \*" } \
301 { "ptype v_int_pointer" "type = int \*" } \
302 { "ptype v_long_pointer" "type = (long|long int) \*" } \
303 { "ptype v_float_pointer" "type = float \*" } \
304 { "ptype v_double_pointer" "type = double \*" } ]
305
306 foreach i $command {
307 if [gdb_test [lindex $i 0] [lindex $i 1] ""] then {
308 fail "$binfile ($bfdformat) \"[lindex $i 0]\" C pointer types"
309 return
310 }
311 }
312 pass "$binfile ($bfdformat) ptype C pointer types"
313}
314
315proc loadandtest { args } {
316 global verbose
317 global GDB
318 global GDBFLAGS
85fbaa74 319 global gdb_prompt
ef44eed1
SS
320 global subdir
321 global objdir
322 global binfile
323 global bfdformat
324 global file_loaded
325
326 set binfile [ lindex $args 0 ]
327 set bfdformat [ lindex $args 1 ]
328 set fixme [ lindex $args 2 ]
329
330 if ![file exists $objdir/$subdir/$binfile] then {
331 perror "$objdir/$subdir/$binfile does not exist"
332 return 0
333 }
334 gdb_exit
335 gdb_start
336 if $fixme then { setup_xfail "*-*-*" }
337 bfddefault
338 if $fixme then { setup_xfail "*-*-*" }
339 if [string match $bfdformat "elf-big"] then {
340 if [string match $binfile "i860-elf"] then {
341 setup_xfail "*-*-*"
342 }
343 }
344 bfdexplicit
345 if $file_loaded==1 then {
346 test_ptype_functions
347 if $fixme then { setup_xfail "*-*-*" }
348 test_ptype_plain_types
349 if $fixme then { setup_xfail "*-*-*" }
350 test_ptype_signed_types
351 if $fixme then { setup_xfail "*-*-*" }
352 test_ptype_unsigned_types
353 if $fixme then { setup_xfail "*-*-*" }
354 test_ptype_array_types
355 if $fixme then { setup_xfail "*-*-*" }
356 test_ptype_pointer_types
357 }
358}
359
360# Run tests for each of the test executables.
361# If the third argument is 1, the tests will be expected to fail.
362# We should extract the information about available tests and bfd formats
363# from the makefile or some other control file (FIXME).
364
365loadandtest m68k-elf "elf32-m68k" 0
366
367# I'm getting an XPASS for explicit format on this one
368loadandtest m68k-aout "a.out-newsos3" 1
369
370loadandtest m68k-aout2 "a.out-sunos-big" 0
371loadandtest mips-ecoff "ecoff-bigmips" 0
372loadandtest i486-elf "elf32-i386" 0
373loadandtest sparc-aout "a.out-sunos-big" 0
374loadandtest sparc-elf "elf32-sparc" 0
375
376#FIXME: i860 support is unlikely to be working in the near future
377# so suppress this test until it is working. -fnf
378#loadandtest i860-elf "elf32-i860" 0
379
380gdb_test "set gnutarget auto" ""