1 # Copyright (C) 1992 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
17 # Please email any bugs, comments, and/or additions to this file to:
18 # bug-gdb@prep.ai.mit.edu
20 # This file was written by Fred Fish. (fnf@cygnus.com)
21 # Rob Savoye changed it to use gdb_test (rob@cygnus.com)
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.
34 verbose "FIXME: all the crossload tests ignored"
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.
41 if [istarget "i960-*-*"] then {
43 warning "FIXME: crossload test case doesn't run on the i960."
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.
51 if [istarget "a29k-*-*"] then {
53 warning "FIXME: crossload test case doesn't run on the a29k."
58 # Test if gdb can automatically determine the bfd format of an
59 # executable and read it's symbols.
73 send "file $objdir/$subdir/$binfile\n"
75 -re "A program is being debugged already. Kill it.*y or n." {
79 -re "Reading symbols from $objdir/$subdir/$binfile\[.\]+done\..*$prompt $" {
80 pass "$binfile ($bfdformat) auto format"
82 -re "Reading symbols from $objdir/$subdir/$binfile\[.\]+.no debugging symbols found.\[.\]+done\..*$prompt $" {
83 pass "$binfile ($bfdformat) auto format (but no symbols found)"
85 -re "File format not recognized.*$prompt $" {
86 fail "$binfile ($bfdformat) auto format (format not recognized)"
89 -re "File format is ambiguous.*$prompt $" {
90 fail "$binfile ($bfdformat) auto format (format is ambiguous)"
94 fail "$binfile ($bfdformat) auto format"
98 fail "(timeout) $binfile ($bfdformat) auto format"
103 if [gdb_test "info target" ".*file type $bfdformat" ""]==0 then {
106 fail "$binfile ($bfdformat) wrong format found"
110 # Test if gdb can read symbols from an executable when the bfd format
111 # is explicitly set via the environment variable GNUTARGET.
113 proc bfdexplicit {} {
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"
134 send "file $objdir/$subdir/$binfile\n"
136 -re "A program is being debugged already. Kill it.*y or n." {
140 -re "Reading symbols from $objdir/$subdir/$binfile\[.\]+done\..*$prompt $" {
141 pass "$binfile ($bfdformat) explicit format"
143 -re "Invalid target.*$prompt $" {
144 fail "$binfile ($bfdformat) explicit format (invalid target)"
148 fail "$binfile ($bfdformat) explicit format"
152 fail "(timeout) $binfile ($bfdformat) explicit format"
160 proc test_ptype_functions {} {
167 -re "type = int \[)(\]+\r\n$prompt $" {}
168 timeout { fail "$binfile ($bfdformat) function main" ; return }
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 \[)(\]+" } ]
180 if [gdb_test [lindex $i 0] [lindex $i 1] ""] then {
181 fail "$binfile ($bfdformat) \"[lindex $i 0]\" function types"
185 pass "$binfile ($bfdformat) ptype function types"
188 # Note that plain chars can be either signed or unsigned.
190 proc test_ptype_plain_types {} {
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" } ]
204 if [gdb_test [lindex $i 0] [lindex $i 1] ""] then {
205 fail "$binfile ($bfdformat) \"[lindex $i 0]\" plain C types"
209 pass "$binfile ($bfdformat) ptype plain C types"
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.
215 proc test_ptype_signed_types {} {
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" } ]
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 {
232 fail "$binfile ($bfdformat) \"[lindex $i 0]\" signed C types"
236 pass "$binfile ($bfdformat) ptype signed C types"
239 proc test_ptype_unsigned_types {} {
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)" } ]
254 if [gdb_test [lindex $i 0] [lindex $i 1] ""] then {
255 fail "$binfile ($bfdformat) \"[lindex $i 0]\" unsigned C types"
259 pass "$binfile ($bfdformat) ptype unsigned C types"
262 # Note that plain chars can be either signed or unsigned.
264 proc test_ptype_array_types {} {
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\\\]" } ]
280 if [gdb_test [lindex $i 0] [lindex $i 1] ""] then {
281 fail "$binfile ($bfdformat) \"[lindex $i 0]\" C array types"
285 pass "$binfile ($bfdformat) ptype C array types"
288 proc test_ptype_pointer_types {} {
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 \*" } ]
303 if [gdb_test [lindex $i 0] [lindex $i 1] ""] then {
304 fail "$binfile ($bfdformat) \"[lindex $i 0]\" C pointer types"
308 pass "$binfile ($bfdformat) ptype C pointer types"
311 proc loadandtest { args } {
322 set binfile [ lindex $args 0 ]
323 set bfdformat [ lindex $args 1 ]
324 set fixme [ lindex $args 2 ]
326 if ![file exists $objdir/$subdir/$binfile] then {
327 perror "$objdir/$subdir/$binfile does not exist"
332 if $fixme then { setup_xfail "*-*-*" }
334 if $fixme then { setup_xfail "*-*-*" }
335 if [string match $bfdformat "elf-big"] then {
336 if [string match $binfile "i860-elf"] then {
341 if $file_loaded==1 then {
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
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).
361 loadandtest m68k-elf "elf32-m68k" 0
363 # I'm getting an XPASS for explicit format on this one
364 loadandtest m68k-aout "a.out-newsos3" 1
366 loadandtest m68k-aout2 "a.out-sunos-big" 0
367 loadandtest mips-ecoff "ecoff-bigmips" 0
368 loadandtest i486-elf "elf32-i386" 0
369 loadandtest sparc-aout "a.out-sunos-big" 0
370 loadandtest sparc-elf "elf32-sparc" 0
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
376 gdb_test "set gnutarget auto" ""