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