diff options
author | Rob Savoye <rob@welcomehome.org> | 2001-02-05 04:14:59 +0000 |
---|---|---|
committer | Rob Savoye <rob@welcomehome.org> | 2001-02-05 04:14:59 +0000 |
commit | 20f1185dd84bcadf4b238d1d2ca18f5ca79157d4 (patch) | |
tree | da300d5097593bc1d61123a8e32179914440e85f /config | |
download | dejagnu-20f1185dd84bcadf4b238d1d2ca18f5ca79157d4.zip dejagnu-20f1185dd84bcadf4b238d1d2ca18f5ca79157d4.tar.gz dejagnu-20f1185dd84bcadf4b238d1d2ca18f5ca79157d4.tar.bz2 |
Initial revision
Diffstat (limited to 'config')
40 files changed, 4470 insertions, 0 deletions
diff --git a/config/README b/config/README new file mode 100644 index 0000000..caedebd --- /dev/null +++ b/config/README @@ -0,0 +1,34 @@ +The files in this directory define a basic set of functionality for each +board. They are loaded by calling "load_generic_config", normally done +as part of the baseboard description for a given board. + +This functionality is a partial replacement for the tool-specific +configuration previously found in the testsuite/config directory. Note +that no tool-specific actions are defined here; they still need to be +defined by the tool-specific config files. However, for tools that +simply wish to download and execute programs on a board, the +functionality here should be sufficient. + +The functions that can be defined are: + +${board}_open +${board}_close +${board}_exec +${board}_binary +${board}_reboot +${board}_download +${board}_upload +${board}_transmit +${board}_send +${board}_file +${board}_spawn +${board}_load + +Normally these functions are invoked indirectly by the testcases when +they invoke the remote_xxx version of the function. + +The ${board}_xxx functions will be called in preference to the default +versions (or the ones specified by the "connect" protocol in the board +description). However, the version defined by the "connect" protocol +are still accessible by calling remote_raw_xxx, which will ignore any +board-specific or generic versions of these functions. diff --git a/config/arc.exp b/config/arc.exp new file mode 100644 index 0000000..3fffb06 --- /dev/null +++ b/config/arc.exp @@ -0,0 +1,20 @@ +# Copyright (C) 1997 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +# Please email any bugs, comments, and/or additions to this file to: +# DejaGnu@cygnus.com + +load_generic_config "gdb-comm"; diff --git a/config/arm-ice.exp b/config/arm-ice.exp new file mode 100644 index 0000000..3fffb06 --- /dev/null +++ b/config/arm-ice.exp @@ -0,0 +1,20 @@ +# Copyright (C) 1997 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +# Please email any bugs, comments, and/or additions to this file to: +# DejaGnu@cygnus.com + +load_generic_config "gdb-comm"; diff --git a/config/base-config.exp b/config/base-config.exp new file mode 100644 index 0000000..2cd9581 --- /dev/null +++ b/config/base-config.exp @@ -0,0 +1,48 @@ +# Copyright (C) 1997 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +# Please email any bugs, comments, and/or additions to this file to: +# DejaGnu@cygnus.com + +# +# reboot_hook -- called to reboot a target board. Returns 1 on +# success, 0 otherwise. +# +proc reboot_via_x10 { dest } { + if [board_info $dest exists name] { + set dest [board_info $dest name]; + } + + if [board_info $dest exists x10] { + set x10 [board_info $dest x10]; + verbose "rebooting x10 unit $x10" 1 + rsh_exec rtl "/usr/unsupported/bin/x10-hellcab unit $x10 off" + sleep 2 + rsh_exec rtl "/usr/unsupported/bin/x10-hellcab unit $x10 on" + sleep 2 + return 1; + } + return 0; +} + +proc ${board}_reboot { args } { + if { [llength $args] > 0} { + set dest [lindex $args 0]; + } else { + set dest target; + } + return [reboot_via_x10 $dest]; +} diff --git a/config/base68k.exp b/config/base68k.exp new file mode 100644 index 0000000..d105ce8 --- /dev/null +++ b/config/base68k.exp @@ -0,0 +1,323 @@ +# Copyright (C) 1994, 1996, 1997 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +# Please email any bugs, comments, and/or additions to this file to: +# DejaGnu@cygnus.com + +# This file was written by Bob Manson (manson@cygnus.com) +# based on earlier work by JT Conklin (jtc@cygnus.com) + +# +# base68k_load -- load the program and execute it +# + +proc base68k_ld { dest prog } { + global tmpdir + + set shell_prompt [board_info $dest shell_prompt] + + if ![file exists $prog] then { + verbose -log "$prog does not exist." + return "untested" + } + if [is_remote host] { + set prog [remote_download host $prog]; + if { $prog == "" } { + verbose -log "Unable to download $prog to host."; + return "untested"; + } + } + + if [board_info $dest exists objcopy] { + set OBJCOPY [board_info $dest objcopy]; + set exec_file "${prog}.srec" + set objcopy_args "" + if [board_info $dest exists use_vma_offset] { + set objcopy_args "--adjust-vma=[board_info $dest hex_startaddr]"; + } + set status [remote_exec host "$OBJCOPY $objcopy_args -O srec $prog ${prog}.srec"] + set result [lindex $status 1]; + regsub -all -- "\[\r\n\]*" $result "" result + if { $result != "" || [lindex $status 0] != 0 } { + warning "Got \"$result\" from $OBJCOPY" + verbose -log "Couldn't convert to srecord for downloading" + remote_close $dest; + return "untested" + } else { + verbose "Converted $prog to an srecord." 2 + } + } else { + set exec_file $prog + } + + set value 0; + if ![board_info $dest exists fileid] { + while { $value < 2 } { + set rom68k_shell_id [remote_open $dest] + if { $rom68k_shell_id < 0 } { + if { $value > 0 || ![remote_reboot $dest] } { + verbose -log "$prog not executed, couldn't connect to target." + return "untested" + } + incr value; + } else { + break; + } + } + # dbug has problems if we go into binary mode, so this allows us to + # disable entry into binary mode. + if ![board_info $dest exists no_binary_mode] { + remote_binary $dest; + } + } + + # if we built the srecord on a remote host, copy it back here so we + # can load it + if [is_remote host] { + global objdir + set exec_file [remote_upload host ${exec_file} "${objdir}/a.out"]; + } + + set got_p 0; + for { set tries 0; } { (! $got_p) && $tries < 5 } { incr tries } { + remote_send $dest "\r\n\r\n" + remote_expect $dest 5 { + -re "${shell_prompt}$" { + verbose "Got prompt." + set result 0 + set got_p 1; + } + timeout { + warning "Never got prompt." + } + } + if { ! $got_p } { + if $tries<=4 then { + if { $tries == 3 } then { + remote_reboot $dest; + } else { + remote_send $dest "\r\n" + } + } + } + } + + # We need to do this in case the connection to the remote side is + # scrogged -- the remote_expect above will fail in a lot of + # non-clean ways. + if { ! $got_p } { + remote_close $dest; + remote_reboot $dest; + return "unresolved"; + } else { + # Flush out any remaining cruft. + remote_expect $dest 2 { + timeout { } + -re ".+" { exp_continue } + default { } + } + } + + if [board_info $dest exists download_command] { + # Load the program. + remote_send $dest "\r\n"; + # dbug has problems sending download command immediately after a + # newline, so we wait for the prompt to come back first. + remote_expect $dest 5 { + -re "${shell_prompt}$" { + verbose -log "Got prompt." + } + timeout { + warning "Never got prompt." + } + } + remote_send $dest [board_info $dest download_command] + if [board_info $dest exists download_response] { + remote_expect $dest 5 { + [board_info $dest download_response] { } + timeout { + perror "Download command never responded." + return "unresolved"; + } + } + } + } + + verbose "Writing records to target..." + set status [remote_transmit $dest $exec_file]; + if { $exec_file != $prog } { + remote_file build delete $exec_file + } + if { $status != 0 } { + remote_close $dest; + verbose -log "Transmission of $exec_file to the target failed." 3 + return "unresolved" + } + verbose "Wrote records to target...waiting for prompt." + remote_send $dest "\n" + set got_p 0; + remote_expect $dest 50 { + -re "$shell_prompt$" { + verbose "Got prompt." + set got_p 1; + } + timeout { } + } + if { $got_p } { + # Flush any remaining cruft. 2 seconds may be too long, dunno. + remote_expect $dest 2 { + timeout { } + -re ".+" { exp_continue } + default { } + } + return "pass"; + } else { + remote_close $dest; + remote_reboot $dest; + return "unresolved"; + } + +} + + +proc base68k_spawn { dest prog args } { + set shell_prompt [board_info $dest shell_prompt]; + + set result [remote_ld $dest $prog]; + if { $result != "pass" } { + return [list $result ""]; + } + + if [board_info $dest exists startaddr] { + set go_command "[board_info $dest go_command] [board_info $dest startaddr]"; + } else { + set go_command "[board_info $dest go_command]"; + } + + verbose "Sending $go_command, waiting for results."; + remote_send $dest "${go_command}\n"; + return { "pass" "" }; +} + +proc base68k_wait { dest timeout } { + set shell_prompt [board_info $dest shell_prompt]; + set noappend 0; + set result -1; + + set output ""; + + remote_expect $dest $timeout { + -re [board_info $dest go_response] { + append output $expect_out(buffer); + set noappend 1; + set result 0; + exp_continue -continue_timer; + } + -re "$shell_prompt$" { + verbose "Got prompt."; + set result 0; + } + -re "\[\r\n\]+" { + if { ! $noappend } { + append output $expect_out(buffer); + if { [string length $output] < 512000 } { + exp_continue -continue_timer; + } else { + set result -1; + } + } + } + timeout { + warning "Nothing ever came back."; + set result -1; + } + } + + if [board_info $dest exists output_end] { + regsub "[board_info $dest output_end]" "$output" "\n" output; + } + + # There has got to be a better way. (We need to do this in order to remove + # the echoed "go command". + if [board_info $dest exists startaddr] { + set go_command "[board_info $dest go_command] [board_info $dest startaddr]"; + } else { + set go_command "[board_info $dest go_command]"; + } + + regsub "^.*$go_command\[\r\n\]*" "$output" "" output; + regsub "^.*$go_command\[\r\n\]*" "$output" "" output; + + # We always want to check for a status, even if there was a funky weird + # failure above. + set status [check_for_board_status output]; + if { $result == 0 } { + set result $status; + verbose -log "exit status was $status"; + } + # A negative value indicates that we should reboot. Otherwise, return + # the exit status from the program if we got one (and we should have). + return [list $result "$output"]; +} + +proc base68k_load { dest prog args } { + global base68k_retry + + set shell_prompt [board_info $dest shell_prompt]; + + if { [llength $args] > 0 } { + for { set x 0; } { $x < [llength $args] } { incr x ; } { + if { [lindex $args $x] != "" } { + verbose -log "Cannot pass parameters or input file to this target"; + return [list "unsupported" ""]; + } + } + } + + set result [remote_spawn $dest $prog]; + if { [lindex $result 0] != "pass" } { + return $result; + } + + # FIXME: The value 360 below should be a parameter. + + set result [remote_wait $dest 360]; + set output [lindex $result 1]; + set status [lindex $result 0]; + + verbose "output from board is $output" + + # Make sure there's a newline before the PASS/FAIL/whatever for the log. + send_log "\n" + + if { $status > 0 } { + return [list "fail" $output]; + } elseif { $status == 0 } { + return [list "pass" $output]; + } else { + if [info exists base68k_retry] { + return [list "fail" $output]; + } + set base68k_retry 1; + remote_reboot $dest; + set status [eval base68k_load \{$dest\} \{$prog\} $args]; + unset base68k_retry; + return $status; + } +} + +set_board_info protocol "base68k"; +set_board_info send_initial_cr 1 diff --git a/config/bug.exp b/config/bug.exp new file mode 100644 index 0000000..881eccc --- /dev/null +++ b/config/bug.exp @@ -0,0 +1,29 @@ +# Copyright (C) 1997 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +# Please email any bugs, comments, and/or additions to this file to: +# bug-dejagnu@prep.ai.mit.edu + +# This file was written by Bob Manson (manson@cygnus.com). + +load_generic_config "base68k"; + +set_board_info shell_prompt "\[0-9\]+Bug>" +set_board_info download_command "lo 0\r" +set_board_info download_response "lo 0.*" +set_board_info go_command "go" +set_board_info go_response "\*\*\*EXIT code.*" +set_board_info startaddr "10000" diff --git a/config/cfdbug.exp b/config/cfdbug.exp new file mode 100644 index 0000000..2db0ac7 --- /dev/null +++ b/config/cfdbug.exp @@ -0,0 +1,31 @@ +# Copyright (C) 1999 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +# Please email any bugs, comments, and/or additions to this file to: +# bug-dejagnu@prep.ai.mit.edu + +# This file was written by Bob Manson (manson@cygnus.com). + +load_generic_config "base68k"; + +set_board_info shell_prompt "dBUG> *" +set_board_info download_command "dl\r\n" +set_board_info download_response "*Escape to local*" +set_board_info go_command "go" +set_board_info go_response "\[*\]\[*\]\[*\] EXIT code \[^\r\n\]*\[\r\n\]" +set_board_info startaddr "10000" +set_board_info hex_startaddr "0x10000" +set_board_info no_binary_mode 1 diff --git a/config/cygmon.exp b/config/cygmon.exp new file mode 100644 index 0000000..2378a12 --- /dev/null +++ b/config/cygmon.exp @@ -0,0 +1,22 @@ +# Copyright (C) 1997, 1998 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +# Please email any bugs, comments, and/or additions to this file to: +# DejaGnu@cygnus.com + +load_generic_config "gdb-comm"; + +set_board_info send_initial_cr 1; diff --git a/config/d10v.exp b/config/d10v.exp new file mode 100644 index 0000000..3fffb06 --- /dev/null +++ b/config/d10v.exp @@ -0,0 +1,20 @@ +# Copyright (C) 1997 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +# Please email any bugs, comments, and/or additions to this file to: +# DejaGnu@cygnus.com + +load_generic_config "gdb-comm"; diff --git a/config/ddb-ether.exp b/config/ddb-ether.exp new file mode 100644 index 0000000..140c0d2 --- /dev/null +++ b/config/ddb-ether.exp @@ -0,0 +1,190 @@ +# Copyright (C) 1997, 1998 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +# Please email any bugs, comments, and/or additions to this file to: +# DejaGnu@cygnus.com + +# This file was written by Bob Manson (manson@cygnus.com) + +# Reset the prompt to what GDB needs. +proc ${board}_init { dest } { + global doing_ddb_init; + + if ![info exists doing_ddb_init] { + set doing_ddb_init 1; + + remote_close $dest; + for { set x 0; } { $x < 3 } { incr x; } { + set shell_id [remote_open $dest]; + if { $shell_id == "" || $shell_id < 0 } { + remote_reboot $dest; + } else { + break; + } + } + + set shell_prompt [board_info $dest shell_prompt]; + + remote_send $dest "\n"; + remote_expect $dest 10 { + -re ".*PMON> $" { + remote_send $dest "set prompt \"$shell_prompt\"\n"; + exp_continue; + } + -re ".*${shell_prompt}$" { } + } + remote_close $dest; + unset doing_ddb_init; + } else { + return; + } +} + +proc ddb_ether_load { dest prog args } { + for { set x 0; } { $x < 3 } { incr x } { + set result [eval remote_spawn \{$dest\} \{$prog\} $args]; + if { $result < 0 } { + remote_reboot $dest; + } else { + set result [remote_wait $dest 300]; + set status [lindex $result 0]; + set output [lindex $result 1]; + if { $status >= 0 } { + if { $status > 0 } { + return [list "fail" $output]; + } else { + return [list "pass" $output]; + } + } + } + } + return [list "fail" ""]; +} + +proc ddb_ether_ld { dest prog } { + if ![board_info $dest exists tftpdir] { + perror "Must set_board_info tftpdir for [board_info $dest name]"; + return "fail"; + } + + if ![board_info $dest exists fileid] { + set spawn_id [remote_open $dest]; + if { $spawn_id == "" || $spawn_id < 0 } { + return "retry"; + } + remote_binary $dest; + } + + set shell_prompt [board_info $dest shell_prompt]; + + remote_send $dest "\n"; + remote_expect $dest 10 { + -re ".*${shell_prompt}$" { } + default { + return "retry"; + } + } + set basename "a.out.[pid]"; + set file "[board_info $dest tftpdir]/$basename"; + set file [remote_download build $prog $file]; + if { $file == "" } { + perror "download to tftp area failed"; + return "fail"; + } + set state "pass"; + + remote_send $dest "boot /$basename\n"; + set tries 0; + remote_expect $dest 30 { + -re "Loading.*Entry address is.*${shell_prompt}$" { } + -re "invalid executable.*${shell_prompt}$" { + incr tries; + if { $tries < 3 } { + sleep 2; + remote_send $dest "boot /$basename\n"; + exp_continue; + } + } + -re ".*${shell_prompt}$" { + set state "fail"; + } + default { + set state "fail"; + } + } + remote_file build delete $file; + if { $state == "fail" } { + return $state; + } + return "pass"; +} + +proc ddb_ether_spawn { dest prog args } { + set state [ddb_ether_ld $dest $prog]; + + if { $state != "pass" } { + return -1; + } + remote_send $dest "g\n"; + remote_expect $dest 5 { + -re "g\[\r\n\]\[\r\n\]?" { } + default { } + } + + return [board_info $dest fileid]; +} + +proc ddb_ether_wait { dest timeout } { + set output ""; + set shell_prompt [board_info $dest shell_prompt]; + + remote_expect $dest $timeout { + -re "^g\[\r\n\]\[\r\n\]?" { + if { $output != "" } { + append output $expect_out(buffer); + } + exp_continue; + } + -re "(.*)$shell_prompt" { + append output $expect_out(1,string); + set status [check_for_board_status output]; + if { $status > 0 } { + return [list $status $output]; + } else { + if [regexp "Exception Cause=" $output] { + remote_reboot $dest; + return [list -1 $output]; + } + return [list 0 $output]; + } + } + -re "\[\r\n\]+" { + append output $expect_out(buffer); + if { [string length $output] < 512000 } { + exp_continue; + } else { + return [list -1 ""]; + } + } + default { + return [list -1 ""]; + } + } +} + +set_board_info send_initial_cr 1 +set_board_info protocol "ddb_ether" +set_board_info shell_prompt "NEC010> " diff --git a/config/ddb.exp b/config/ddb.exp new file mode 100644 index 0000000..13a18e0 --- /dev/null +++ b/config/ddb.exp @@ -0,0 +1,96 @@ +# Copyright (C) 1997 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +# Please email any bugs, comments, and/or additions to this file to: +# DejaGnu@cygnus.com + +# This file was written by Bob Manson (manson@cygnus.com) + +# We use GDB to talk to a vr4300 board. +load_generic_config "base68k"; + +set_board_info shell_prompt "NEC010> "; +set_board_info download_command "load tty0\n"; +set_board_info download_response "Downloading from"; +set_board_info go_command "g -e"; +set_board_info startaddr "a0100000" +set_board_info hex_startaddr "0xa0100000" +set_board_info go_response "(^|\[\r\n\])(Exception Cause|\[0-9a-z\]+ \[0-9a-z\]+ break|\\*\\*\\*EXIT code )\[^\r\n\]*\[\r\n\]" +set_board_info output_end "\[\r\n\](Exception Cause|\[0-9a-z\]+ \[0-9a-z\]+ break).*$" + +# Reset the prompt to what GDB needs. +proc ${board}_init { dest } { + global doing_ddb_init; + if [is_remote host] { + return; + } + + if ![info exists doing_ddb_init] { + set doing_ddb_init 1; + + for { set i 1; } { $i <= 3 } {incr i } { + remote_close $dest; + for { set x 0; } { $x < 3 } { incr x; } { + set shell_id [remote_open $dest]; + if { $shell_id == "" || $shell_id < 0 } { + remote_reboot $dest; + } else { + break; + } + } + + set count 0; + remote_send $dest "\n"; + remote_expect $dest 20 { + -re ".*PMON> $" { + remote_send $dest "set prompt \"NEC010> \"\n"; + exp_continue; + } + -re "NEC010> $" { + set i 10; + } + timeout { } + -re "0x0" { + count++; + if(count<5) { + exp_continue; + } + } + } + if { $i < 3 } { + remote_reboot $dest; + } + } + remote_close $dest; + unset doing_ddb_init; + } else { + return; + } +} + +set_board_info send_initial_cr 1 +set_board_info dont_wait_for_prompt 1 + +# If no output format is specified, use objcopy. +if ![board_info $board exists output_format] { + set tempfil [lookfor_file $tool_root_dir binutils/objcopy]; + if { $tempfil != "" } { + set_board_info objcopy $tempfil + } else { + set_board_info objcopy [transform objcopy] + } + unset tempfil +} diff --git a/config/dos.exp b/config/dos.exp new file mode 100644 index 0000000..d1b440d --- /dev/null +++ b/config/dos.exp @@ -0,0 +1,484 @@ +# Copyright (C) 1997, 1998, 1999 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +# Please email any bugs, comments, and/or additions to this file to: +# DejaGnu@cygnus.com + +# This file was written by Bob Manson (manson@cygnus.com) + +# +# Open a connection to the remote DOS host. +# +proc dos_open { dest args } { + global destbat_num + + if ![info exists destbat_num] { + set destbat_num [pid]; + } + if { [board_info $dest conninfo] == "" } { + global board_info; + set name [board_info $dest name]; + + set board_info($name,conninfo) "b${destbat_num}.bat"; + incr destbat_num; + } + + if [board_info $dest exists fileid] { + return [board_info $dest fileid]; + } + + verbose "doing a dos_open to $dest" + + set shell_prompt [board_info $dest shell_prompt]; + + set shell_id [remote_raw_open $dest]; + + if { $shell_id == "" || $shell_id < 0 } { + return -1; + } + + if [board_info $dest exists init_command] { + remote_send $dest "[board_info $dest init_command]\n"; + remote_expect $dest 10 { + -re "$shell_prompt" { } + default { + perror "failed connection to DOS on $dest." + return -1; + } + } + } + + if [board_info $dest exists ftp_directory] { + set dir [board_info $dest ftp_directory]; + regsub -all "/" "$dir" "\\" dir; + remote_send $dest "cd $dir\n"; + remote_expect $dest 10 { + -re "$shell_prompt" { } + default { + perror "failed connection to DOS on $dest." + return -1; + } + } + } + + if [board_info $dest exists dos_dir] { + set dos_dir [board_info $dest dos_dir]; + regsub -all "^(\[a-zA-Z]:).*$" "$dos_dir" "\\1" drive; + regsub -all "^\[a-zA-Z]:" "$dos_dir" "" dos_dir; + remote_send $dest "${drive}\n"; + remote_expect $dest 10 { + -re "$shell_prompt" { } + default { + perror "failed connection to DOS on $dest." + return -1; + } + } + remote_send $dest "cd $dos_dir\n"; + remote_expect $dest 10 { + -re "$shell_prompt" { } + default { + perror "failed connection to DOS on $dest." + return -1; + } + } + } + + global target_alias + if [info exists target_alias] { + set talias $target_alias; + } else { + set talias "foo-bar" + } + + global board_info; + if [board_info $dest exists name] { + set n [board_info $dest name]; + } else { + set n $dest; + } + set board_info($n,fileid) $shell_id; + + if [board_info $dest exists init_script] { + remote_exec $dest "[board_info $dest init_script] $talias" + } + + verbose "Succeeded in connecting to DOS." + return $shell_id; +} + +# +# Close the connection to the remote host. If we're telnetting there, we +# need to exit the connection first (ataman telnetd gets confused otherwise). +# +proc dos_close { dest args } { + if [board_info $dest exists fileid] { + if { [board_info $dest connect] == "telnet" } { + remote_send $dest "exit\n"; + sleep 2; + } + return [remote_raw_close $dest]; + } +} + +proc dos_prep_command { dest cmdline } { + global board_info; + + set name [board_info $dest name]; + set shell_id [remote_open "$dest"]; + + set localbat "/tmp/b[pid].bat"; + set remotebat [board_info $dest conninfo]; + + verbose "opened" + if { $shell_id != "" && $shell_id >= 0 } { + set fileid [open "$localbat" "w"]; + puts -nonewline $fileid "@echo off\r\n$cmdline\r\nif errorlevel 1 echo *** DOSEXIT code 1\r\nif not errorlevel 1 echo *** DOSEXIT code 0\r\n"; + close $fileid; + set result [remote_download $dest $localbat $remotebat]; + } else { + set result "" + } + remote_file build delete $localbat; + return $result; +} + +# +# Run CMDLINE on DESTHOST. We handle two cases; one is where we're at +# a DOS prompt, and the other is where we're in GDB. +# We run CMDLINE by creating a batchfile, downloading it, and then +# executing it; this handles the case where the commandline is too +# long for command.com to deal with. +# + +proc dos_exec { dest program pargs inp outp } { + set cmdline "$program $pargs" + + set shell_prompt [board_info $dest shell_prompt]; + + if { $inp != "" } { + set inp [remote_download $dest $inp inpfile]; + if { $inp != "" } { + set inp " < $inp"; + } + } + + if { $outp != "" } { + set outpf " > tempout"; + } else { + set outpf ""; + } + + verbose "cmdline is $cmdline$inp." 2 + + # Make a DOS batch file; we use @echo off so we don't have to see + # the DOS command prompts and such. + for { set i 0; } { $i < 2 } { incr i } { + set exit_status -1; + verbose "calling open" + set batfile [dos_prep_command $dest "$cmdline$inp$outpf"]; + if { $batfile != "" } { + if { [dos_start_command $batfile $dest] == "" } { + # FIXME: The 300 below should be a parameter. + set result [remote_wait $dest 300]; + set exit_status [lindex $result 0]; + set output [lindex $result 1]; + } + } + if { $exit_status >= 0 } { + if { $outp != "" } { + remote_upload $dest tempout $outp; + remote_file $dest delete tempout; + } + return [list $exit_status $output]; + } + if { $exit_status != -2 } { + remote_close $dest; + remote_reboot $dest; + } + } + return [list -1 "program execution failed"]; +} + +# +# Start CMDLINE executing on DEST. +# There are two cases that we handle, one where we're at a DOS prompt +# and the other is when the remote machine is running GDB. +# + +proc dos_start_command { cmdline dest } { + set shell_prompt [board_info $dest shell_prompt]; + set prefix "" + set ok 0; + for {set i 0;} {$i <= 2 && ! $ok} {incr i;} { + set shell_id [remote_open $dest]; + if { $shell_id != "" && $shell_id > 0 } { + remote_send $dest "echo k\r"; + remote_expect $dest 20 { + -re "\\(gdb\\)" { + set shell_prompt "\\(gdb\\)"; + # gdb uses 'shell command'. + set prefix "shell "; + set ok 1; + } + -re "$shell_prompt" { + set ok 1; + } + default { } + } + } + if { ! $ok } { + remote_close $dest; + remote_reboot $dest; + } + } + if { ! $ok } { + return "unable to start command" + } else { + remote_send $dest "${prefix}${cmdline}\n"; + remote_expect $dest 2 { + -re "${cmdline}\[\r\n\]\[\r\n\]?" { } + timeout { } + } + return ""; + } +} + +# +# Send STRING to DEST, translating all LFs to CRs first, and sending one +# line at a time because of strangeness with telnet in some circumstances. +# + +proc dos_send { dest string } { + verbose "Sending '$string' to $dest" 2 + # Convert LFs to CRs, 'cause that is what DOS wants to see. + set first 1 + set string [string trimright $string "\r\n"] + foreach line [split $string "\r\n"] { + if {$first} { + set first 0 + } else { + # small delay between lines, to keep from + # overwhelming the stupid telnet server. + sleep 1.0 + } + remote_raw_send $dest "$line\r" + } +} + +# +# Spawn PROGRAM on DEST, and return the spawn_id associated with the +# connection; we can only spawn one command at a time. +# + +proc dos_spawn { dest program args } { + verbose "running $program on $dest" + set remotebat [dos_prep_command $dest $program]; + + for { set x 0; } { $x < 3 } { incr x } { + if { [dos_start_command $remotebat $dest] == "" } { + return [board_info $dest fileid]; + } + remote_close $dest; + remote_reboot $dest; + } + return -1; +} + +proc dos_wait { dest timeout } { + set output ""; + set shell_prompt [board_info $dest shell_prompt]; + set status 1; + + verbose "waiting in dos_wait"; + remote_expect $dest $timeout { + -re "(.*)\[*\]\[*\]\[*\] DOSEXIT code (\[0-9\]+)\[\r\n\]\[\r\n\]?" { + verbose "got exit status"; + append output $expect_out(1,string); + set status $expect_out(2,string); + exp_continue; + } + + -re "(.*)${shell_prompt}" { + append output $expect_out(1,string); + verbose "output from dos is:'$output'"; + return [list $status $output]; + } + + -re "(.*)\\(gdb\\)" { + append output $expect_out(1,string); + return [list $status $output]; + } + + -re "In.*cygwin.*except" { + remote_close $dest; + remote_reboot $dest; + return [list -2 $output]; + } + + -re "\[\r\n\]+" { + # This is a bit obscure. We only want to put whole + # lines into the output string, because otherwise we + # might miss a prompt because we only got 1/2 of it the + # first time 'round. The other tricky bit is that + # expect_out(buffer) will contain everything before and including + # the matched pattern. + append output $expect_out(buffer); + exp_continue -continue_timer; + } + + timeout { + warning "timeout in dos_wait"; + if { [dos_interrupt_job $dest] == "" } { + return [list 1 $output]; + } + } + + eof { + warning "got EOF from dos host."; + } + } + + remote_close $dest; + + return [list -1 $output]; +} + +proc dos_load { dest prog args } { + global dos_dll_loaded; + set progargs ""; + set inpfile ""; + if { [llength $args] > 0 } { + set progargs [lindex $args 1]; + } + if { [llength $args] > 1 } { + set inpfile [lindex $args 1]; + } + if ![info exists dos_dll_loaded] { + if ![is_remote host] { + global target_alias; + + set comp [get_multilibs]; + if [file exists "${comp}/winsup/new-cygwin1.dll"] { + set dll "${comp}/winsup/new-cygwin1.dll"; + set dll_name "cygwin1.dll"; + } elseif [file exists "${comp}/winsup/new-cygwin.dll"] { + set dll "${comp}/winsup/new-cygwin.dll"; + set dll_name "cygwin.dll"; + } elseif [file exists ${comp}/lib/cygwin1.dll] { + set dll "${comp}/lib/cygwin1.dll"; + set dll_name "cygwin1.dll"; + } elseif [file exists ${comp}/lib/cygwin.dll] { + set dll "${comp}/lib/cygwin.dll"; + set dll_name "cygwin.dll"; + } else { + error "couldn't find cygwin.dll:$comp" + return "fail"; + } + remote_download $dest $dll $dll_name + } + set dos_dll_loaded 1; + } + set remote_prog [remote_download $dest $prog "aout.exe"]; + set result [remote_exec $dest $remote_prog $progargs $inpfile]; + set status [lindex $result 0]; + set output [lindex $result 1]; + set status2 [check_for_board_status output]; + if { $status2 >= 0 } { + set status $status2; + } + if { $status != 0 } { + set status "fail"; + } else { + set status "pass"; + } + return [list $status $output]; +} + +proc dos_file { dest op args } { + switch $op { + delete { + foreach x $args { + remote_exec $dest "del" "$x"; + } + return; + + } + default { + return [eval standard_file \{$dest\} \{$op\} $args]; + } + } +} + +# +# Interrupt the current spawned command being run; the only tricky +# part is that we have to handle the "Terminate batch job" prompt. +# +proc dos_interrupt_job { host } { + set shell_prompt [board_info $host shell_prompt]; + + remote_send $host "\003"; + remote_expect $host 10 { + -re "Terminate batch job.*Y/N\[)\]\[?\] *$" { + remote_send $host "n\n"; + exp_continue; + } + -re "$shell_prompt" { + return ""; + } + -re ">" { + remote_send $host "\n"; + exp_continue; + } + } + return "fail"; +} + +proc dos_copy_download { host localfile remotefile } { + remote_file build delete "[board_info $host local_dir]/$remotefile"; + if [remote_file build exists $localfile] { + set result [remote_download build $localfile "[board_info $host local_dir]/$remotefile"]; + if { $result != "" } { + remote_exec build "chmod" "a+rw $result"; + return $remotefile; + } + } else { + return "" + } +} + +proc dos_copy_upload { host remotefile localfile } { + remote_file build delete $localfile; + if [file exists "[board_info $host local_dir]/$remotefile"] { + set result [remote_download build "[board_info $host local_dir]/$remotefile" $localfile]; + } else { + set result ""; + } + if { $result != "" } { + remote_exec build "chmod" "a+rw $result"; + return $result; + } +} + +proc dos_copy_file { dest op args } { + if { $op == "delete" } { + set file "[board_info $dest local_dir]/[lindex $args 0]"; + remote_file build delete $file; + } +} + +set_board_info protocol "dos"; +set_board_info shell_prompt "(^|\[\r\n\])\[a-zA-Z\]:\[^\r\n\]*>\[ \t\]*$"; +set_board_info needs_status_wrapper 1 diff --git a/config/dve.exp b/config/dve.exp new file mode 100644 index 0000000..3582b5b --- /dev/null +++ b/config/dve.exp @@ -0,0 +1,22 @@ +# Copyright (C) 1998 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +# Please email any bugs, comments, and/or additions to this file to: +# bug-gcc@prep.ai.mit.edu + +# For Densan MIPS boards we use gdb to load and execute programs. + +load_generic_config "gdb-comm"; diff --git a/config/gdb-comm.exp b/config/gdb-comm.exp new file mode 100644 index 0000000..3f4fffc --- /dev/null +++ b/config/gdb-comm.exp @@ -0,0 +1,566 @@ +# Copyright (C) 1996, 1997, 1998 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +# Please email any bugs, comments, and/or additions to this file to: +# DejaGnu@cygnus.com + +# Note: some of this was cribbed from the gdb testsuite since we need +# to use some pretty standard gdb features (breakpoints in particular). + +# Load up some standard junk. +load_lib remote.exp + +if ![info exists board] { + perror "$board must be set before loading gdb-comm" +} + +# The number of times we've tried to download/execute this executable. +set try_again 0 + +# +# Delete all breakpoints and verify that they were deleted. If anything +# goes wrong, return -1. +# +proc gdb_comm_delete_breakpoints {} { + global gdb_prompt + + remote_send host "delete breakpoints\n"; + remote_expect host 10 { + -re "Delete all breakpoints.*y or n. $" { + remote_send host "y\n" + exp_continue + } + -re ".*$gdb_prompt $" { } + timeout { perror "Delete all breakpoints (timeout)" ; return -1} + } + remote_send host "info breakpoints\n" + remote_expect host 10 { + -re "No breakpoints or watchpoints..*$gdb_prompt $" {} + -re ".*$gdb_prompt $" { perror "breakpoints not deleted" ; return -1} + timeout { perror "info breakpoints (timeout)" ; return -1} + } + return 0; +} + +# +# Inform the debugger that we have a new exec file. +# return a -1 if anything goes wrong, 0 on success. +# +proc gdb_comm_file_cmd { arg } { + global verbose + global loadpath + global loadfile + global GDB + global gdb_prompt + upvar timeout timeout + + # The "file" command loads up a new symbol file for gdb, deal with + # the various messages it might spew out. + if [is_remote host] { + set arg [remote_download host $arg a.out]; + } + remote_send host "file $arg\n" + remote_expect host 60 { + -re "Reading symbols from.*done.*$gdb_prompt $" { + verbose "\t\tLoaded $arg into the $GDB" + return 0 + } + -re "has no symbol-table.*$gdb_prompt $" { + perror "$arg wasn't compiled with \"-g\"" + return -1 + } + -re "A program is being debugged already.*Kill it.*y or n. $" { + remote_send host "y\n" + verbose "\t\tKilling previous program being debugged" + exp_continue + } + -re "Load new symbol table from \".*\".*y or n.*$" { + remote_send host "y\n" + remote_expect host 60 { + -re "Reading symbols from.*done.*$gdb_prompt $" { + verbose "\t\tLoaded $arg with new symbol table into $GDB" + return 0 + } + timeout { + perror "(timeout) Couldn't load $arg, other program already loaded." + return -1 + } + } + } + -re ".*No such file or directory.*$gdb_prompt $" { + perror "($arg) No such file or directory\n" + return -1 + } + -re "$gdb_prompt $" { + perror "couldn't load $arg into $GDB." + return -1 + } + timeout { + perror "couldn't load $arg into $GDB (timed out)." + return -1 + } + eof { + # This is an attempt to detect a core dump, but seems not to + # work. Perhaps we need to match .* followed by eof, in which + # expect does not seem to have a way to do that. + perror "couldn't load $arg into $GDB (end of file)." + return -1 + } + } + return 0; +} + +# Disconnect from the target and forget that we have an executable. Returns +# -1 on failure, 0 on success. + +proc gdb_comm_go_idle { } { + global gdb_prompt; + + if ![board_info host exists fileid] { + return -1; + } + + remote_send host "target exec\n"; + remote_expect host 10 { + -re "Kill it.*y or n.*$" { + remote_send host "y\n" + exp_continue; + } + -re "No exec.* file now.*$gdb_prompt $" { + return 0; + } + default { + remote_close host; + return -1; + } + } +} + +# Start GDB running with target DEST. +proc gdb_comm_start { dest } { + global GDB + global gdb_prompt + global tool_root_dir + + # The variable gdb_prompt is a regexp which matches the gdb prompt. Set it + # if it is not already set. + if ![board_info $dest exists gdb_prompt] then { + set gdb_prompt "\\(gdb\\)" + } else { + set gdb_prompt [board_info $dest gdb_prompt]; + } + # Similarly for GDB. Look in the object directory for gdb if we aren't + # provided with one. + if ![info exists GDB] then { + set GDB "[lookfor_file ${tool_root_dir} gdb/gdb]" + if { $GDB == "" } { + set GDB [transform gdb] + } + } + if [board_info host exists gdb_opts] { + set gdb_opts [board_info host gdb_opts]; + } else { + set gdb_opts "" + } + # Start up gdb (no startfiles, no windows) and wait for a prompt. + remote_spawn host "$GDB $gdb_opts -nw -nx"; + remote_expect host 60 { + -re ".*$gdb_prompt $" { } + } + remote_send host "set height 0\n"; + remote_expect host 10 { + -re ".*$gdb_prompt $" {} + } + remote_send host "set width 0\n"; + remote_expect host 10 { + -re ".*$gdb_prompt $" {} + } +} + +# Add a breakpoint at function FUNCTION. We assume that GDB has already been +# started. +proc gdb_comm_add_breakpoint { function } { + global gdb_prompt + + remote_send host "break $function\n" + remote_expect host 60 { + -re "Breakpoint.*$gdb_prompt $" { return "" } + -re "Function.*not defined.*$gdb_prompt $" { return "undef" } + -re "No symbol table.*$gdb_prompt $" { return "undef" } + default { + return "untested" + } + } +} + +# +# quit_gdb -- try to quit GDB gracefully +# + +proc quit_gdb { } { + global gdb_prompt; + + set spawn_id [board_info host fileid]; + + if { $spawn_id != "" && $spawn_id > -1 } { + if { [remote_send host "quit\n"] == "" } { + remote_expect host 10 { + -re ".*y or n.*$" { + remote_send host "y\n"; + exp_continue; + } + -re ".*\[*\]\[*\]\[*\].*EXIT code" { } + default { } + } + } + } + if ![is_remote host] { + remote_close host; + } +} + +proc gdb_comm_leave { } { + if [is_remote host] { + quit_gdb; + } else { + gdb_comm_go_idle; + } +} +# +# gdb_comm_load -- load the program and execute it +# +# PROG is a full pathname to the file to load, no arguments. +# Result is "untested", "pass", "fail", etc. +# + +proc gdb_comm_load { dest prog args } { + global GDB + global GDBFLAGS + global gdb_prompt + global timeout + set argnames { "command-line arguments" "input file" "output file" } + + for { set x 0; } { $x < [llength $args] } { incr x } { + if { [lindex $args $x] != "" } { + return [list "unsupported" "no support for [lindex $argnames $x] on this target"]; + } + } + # Make sure the file we're supposed to load really exists. + if ![file exists $prog] then { + perror "$prog does not exist." + return [list "untested" ""]; + } + + if { [is_remote host] || ![board_info host exists fileid] } { + gdb_comm_start $dest; + } + + # Remove all breakpoints, then tell the debugger that we have + # new exec file. + if { [gdb_comm_delete_breakpoints] != 0 } { + gdb_comm_leave; + return [gdb_comm_reload $dest $prog $args]; + } + if { [gdb_comm_file_cmd $prog] != 0 } { + gdb_comm_leave; + return [gdb_comm_reload $dest $prog $args]; + } + if [board_info $dest exists gdb_sect_offset] { + set textoff [board_info $dest gdb_sect_offset]; + remote_send host "sect .text $textoff\n"; + remote_expect host 10 { + -re "(0x\[0-9a-z]+) - 0x\[0-9a-z\]+ is \\.data" { + set dataoff $expect_out(1,string); + exp_continue; + } + -re "(0x\[0-9a-z\]+) - 0x\[0-9a-z\]+ is \\.bss" { + set bssoff $expect_out(1,string); + exp_continue; + } + -re "$gdb_prompt" { } + } + set dataoff [format 0x%x [expr $dataoff + $textoff]]; + set bssoff [format 0x%x [expr $bssoff + $textoff]]; + remote_send host "sect .data $dataoff\n"; + remote_expect host 10 { + -re "$gdb_prompt" { } + } + remote_send host "sect .bss $bssoff\n"; + remote_expect host 10 { + -re "$gdb_prompt" { } + } + } + + # Now set up breakpoints in exit, _exit, and abort. These + # are used to determine if a c-torture test passed or failed. More + # work would be necessary for things like the g++ testsuite which + # use printf to indicate pass/fail status. + + if { [gdb_comm_add_breakpoint _exit] != "" } { + gdb_comm_add_breakpoint exit; + } + gdb_comm_add_breakpoint abort; + + set protocol [board_info $dest gdb_protocol]; + if [board_info $dest exists gdb_serial] { + set targetname [board_info $dest gdb_serial]; + } elseif [board_info $dest exists netport] { + set targetname [board_info $dest netport]; + } else { + if [board_info $dest exists serial] { + set targetname [board_info $dest serial]; + } else { + set targetname "" + } + } + if [board_info $dest exists baud] { + remote_send host "set remotebaud [board_info $dest baud]\n" + remote_expect host 10 { + -re ".*$gdb_prompt $" {} + default { + warning "failed setting baud rate"; + } + } + } + remote_send host "target $protocol $targetname\n"; + remote_expect host 60 { + -re "Couldn.t establish conn.*$gdb_prompt $" { + warning "Unable to connect to $targetname with GDB." + quit_gdb; + return [gdb_comm_reload $dest $prog $args] + } + -re "Ending remote.*$gdb_prompt $" { + warning "Unable to connect to $targetname with GDB." + quit_gdb; + return [gdb_comm_reload $dest $prog $args] + } + -re "Remote target $protocol connected to.*$gdb_prompt $" { } + -re "Remote target $targetname connected to.*$gdb_prompt $" { } + -re "Connected to ARM RDI target.*$gdb_prompt $" { } + -re "Connected to the simulator.*$gdb_prompt $" { } + -re "Remote.*using $targetname.*$gdb_prompt $" { } + -re "$gdb_prompt $" { + warning "Unable to connect to $targetname with GDB." + quit_gdb; + return [gdb_comm_reload $dest $prog $args] + } + -re ".*RDI_open.*should reset target.*" { + warning "RDI Open Failed" + quit_gdb; + return [gdb_comm_reload $dest $prog $args] + } + default { + warning "Unable to connect to $targetname with GDB." + quit_gdb; + return [gdb_comm_reload $dest $prog $args] + } + } + + if [target_info exists gdb_init_command] { + remote_send host "[target_info gdb_init_command]\n"; + remote_expect host 10 { + -re ".*$gdb_prompt $" { } + default { + gdb_comm_leave; + return [list "fail" ""]; + } + } + } + # Now download the executable to the target board. If communications + # with the target are very slow the timeout might need to be increased. + if [board_info $dest exists gdb_load_offset] { + remote_send host "load $prog [board_info $dest gdb_load_offset]\n"; + } else { + remote_send host "load\n" + } + remote_expect host 600 { + -re "text.*data.*$gdb_prompt $" { } + -re "data.*text.*$gdb_prompt $" { } + -re "$gdb_prompt $" { + warning "Unable to send program to target board." + gdb_comm_leave; + return [gdb_comm_reload $dest $prog $args]; + } + default { + warning "Unable to send program to target board." + gdb_comm_leave; + return [gdb_comm_reload $dest $prog $args]; + } + } + + set output "" + + # Now start up the program and look for our magic breakpoints. + # And a whole lot of other magic stuff too. + + if [board_info $dest exists gdb_run_command] { + remote_send host "[board_info $dest gdb_run_command]\n"; + } else { + remote_send host "run\n" + } + # FIXME: The value 300 below should be a parameter. + if [board_info $dest exists testcase_timeout] { + set testcase_timeout [board_info $dest testcase_timeout]; + } else { + set testcase_timeout 300; + } + remote_expect host $testcase_timeout { + -re "Line.*Jump anyway.*.y or n.*" { + remote_send host "y\n"; + exp_continue; + } + -re "Continuing( at |\\.| with no signal\\.)\[^\r\n\]*\[\r\n\]" { + exp_continue; + } + -re ".*Start it from the beginning?.*y or n.*" { + remote_send host "n\n"; + remote_expect host 10 { + -re ".*$gdb_prompt $" { + remote_send host "signal 0\n"; + remote_expect host 10 { + -re "signal 0\[\r\n\]+" { exp_continue; } + -re "Continuing(\\.| with no signal\\.)\[\r\n\]" {} + } + } + } + exp_continue + } + -re "(run\[\r\n\]*|)Starting program: \[^\r\n\]*\[\r\n\]" { + exp_continue + } + -re "$gdb_prompt (signal 0|continue)\[\r\n\]+Continuing(\\.| with no signal\\.)\[\r\n\]" { + exp_continue + } + -re "(.*)Breakpoint.*exit.*=0.*$gdb_prompt $" { + append output $expect_out(1,string); + set result [check_for_board_status output]; + gdb_comm_leave; + if { $result > 0 } { + return [list "fail" $output]; + } + return [list "pass" $output]; + } + -re "(.*)Breakpoint.*exit.*=\[1-9\]\[0-9\]*.*$gdb_prompt $" { + append output $expect_out(1,string); + set result [check_for_board_status output]; + gdb_comm_leave; + if { $result == 0 } { + return [list "pass" $output]; + } + if [board_info $dest exists exit_statuses_bad] { + return [list "pass" $output]; + } + return [list "fail" $output]; + } + -re "(.*)Breakpoint.*exit.*$gdb_prompt $" { + append output $expect_out(1,string); + set status [check_for_board_status output]; + gdb_comm_leave; + if { $status > 0 } { + return [list "fail" $output]; + } + return [list "pass" $output]; + } + -re "(.*)Breakpoint.*abort.*$gdb_prompt $" { + append output $expect_out(1,string); + check_for_board_status output; + gdb_comm_leave; + return [list "fail" $output]; + } + -re "SIGTRAP.*$gdb_prompt $" { + return [gdb_comm_reload $dest $prog $args]; + } + -re "(.*)Program (received |terminated ).*$gdb_prompt $" { + set output $expect_out(1,string); + check_for_board_status output; + gdb_comm_leave; + remote_reboot $dest; + return [list "fail" $output]; + } + -re "(.*)Program exited with code \[0-9\]+.*$gdb_prompt $" { + set output $expect_out(1,string); + set status [check_for_board_status output]; + gdb_comm_leave; + if { $status > 0 } { + return [list "fail" $output]; + } + return [list "pass" $output]; + } + default { + gdb_comm_leave; + if [board_info $dest exists unreliable] { + if { [board_info $dest unreliable] > 0 } { + global board_info; + set name [board_info $dest name]; + incr board_info($name,unreliable) -1; + set result [gdb_comm_reload $dest $prog $args]; + incr board_info($name,unreliable); + return $result; + } + } + return [list "fail" ""]; + } + } + gdb_comm_leave; + return [list "fail" ""]; +} + +# If we've tried less than 4 times to load PROG, reboot the target, restart GDB +# and try again. Otherwise, return "untested". +proc gdb_comm_reload { dest prog aargs } { + global try_again; + + # how many times have we done this? + set n_reloads [board_info $dest n_reloads] + if {$n_reloads == ""} { + set n_reloads 0 + } + + # increment it + global board_info + set name [board_info $dest name] + set board_info($dest,n_reloads) [expr {$n_reloads + 1}] + + # how many times are we allowed to do this? + set max [board_info $dest max_reload_reboots] + if {$max == ""} { + set max 15 + } + + # if we've been doing this too much, something's very + # wrong. just give up, to reduce stress on boards. + if {$max == $n_reloads} { + perror "Too many reboots. Giving up." + } + if {$max <= $n_reloads} { + return {untested {}} + } + + if { $try_again < 4 } { + global GDB; + remote_reboot $dest; + remote_close host; + incr try_again; + set result [eval remote_load \"$dest\" \"$prog\" $aargs] + set try_again 0; + return "$result"; + } else { + set try_again 0; + return [list "untested" ""]; + } +} + +set_board_info protocol "gdb_comm"; diff --git a/config/gdb_stub.exp b/config/gdb_stub.exp new file mode 100644 index 0000000..127c6eb --- /dev/null +++ b/config/gdb_stub.exp @@ -0,0 +1,638 @@ +# Copyright (C) 1996-98, 1999 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +# Please email any bugs, comments, and/or additions to this file to: +# DejaGnu@cygnus.com + +# This file was written by Michael Snyder <msnyder@cygnus.com>. + +# +# Stub remote run command. +# + +proc gdb_stub_init { dest args } { + global gdb_prompt + global GDB + global tool_root_dir + + if ![info exists GDB] then { + set GDB "[lookfor_file ${tool_root_dir} gdb/gdb]" + if { $GDB == "" } { + set GDB [transform gdb] + } + } + + if [board_info $dest exists gdb_prompt] { + set gdb_prompt [board_info $dest gdb_prompt]; + } else { + set gdb_prompt "\\(gdb\\)" + } + + return 1; +} + +proc gdb_stub_restart { dest } { + global gdb_prompt + global GDB + + gdb_stub_init $dest; + + for {set x 1;} { $x < 4 } {incr x} { + remote_close $dest; + sleep 2; + set command "$GDB -nw -nx"; + if [host_info exists gdb_opts] { + append command " [host_info gdb_opts]"; + } + set spawn_id [remote_spawn host $command]; + remote_expect host 30 { + -re "$gdb_prompt" { } + } + if { $spawn_id >= 0 } { + if [board_info $dest exists baud] { + remote_send host "set remotebaud [board_info $dest baud]\n"; + remote_expect host 5 { + -re "$gdb_prompt" { } + default { + warning "Error setting baud rate." + return -1; + } + } + } + + + set value [gdb_stub_startup $dest]; + if { $value > 0 } { + break; + } + verbose "got $value from gdb_stub_startup"; + remote_send host "quit\n"; + } + remote_reboot $dest; + } + if { ${x} < 4 } { + global board_info; + set name [board_info $dest name]; + + set board_info($name,gdb_is_running) 1; + return 1; + } else { + return 0; + } +} + +proc gdb_stub_remote_check { dest } { + global gdb_prompt + + if [board_info $dest exists gdb_serial] { + set serial [board_info $dest gdb_serial]; + } elseif [board_info $dest exists serial] { + set serial [board_info $dest serial]; + } else { + set serial [board_info $dest netport]; + } + remote_send host "target remote $serial\n"; + remote_expect host 10 { + -re "Couldn't establish connection.*$gdb_prompt" { + return 0; + } + -re "Remote debugging.*$gdb_prompt" { + verbose "stub is already running" + return 1; + } + -re "$gdb_prompt" { + return 0; + } + timeout { + remote_send host "\003"; + remote_expect host 10 { + -re "$gdb_prompt" { } + } + return 0; + } + default { + return 0; + } + } +} + +proc gdb_stub_startup { dest } { + global gdb_prompt + global GDB + + set is_running_stub 0; + + if [gdb_stub_remote_check $dest] { + set is_running_stub 1; + } + + if [board_info $dest exists serial] { + set serial [board_info $dest serial]; + } else { + set serial [board_info $dest netport]; + } + + if { ! $is_running_stub } { + set command "target [board_info $dest gdb_protocol] $serial\n"; + remote_send host $command; + remote_expect host 5 { + -re "already.*y or n." { + remote_send host "y\n"; + exp_continue; + } + -re "appears to be alive.*$gdb_prompt" { } + -re "Remote target.*connected to.*$gdb_prompt" { } + default { + return -1; + } + } + } + if { $is_running_stub == 0 } { + global libdir + + verbose "building loader"; + set loader "loader"; + if ![file exists $loader] { + if [board_info $dest exists gdb_stub_offset] { + set result [target_compile "${libdir}/stub-loader.c" $loader executable "libs=-Wl,-Ttext,[board_info $dest gdb_stub_offset]"]; + } else { + set result [target_compile "${libdir}/stub-loader.c" $loader executable "ldscript=[board_info $dest gdb_stub_ldscript]"]; + } + verbose "result is $result"; + if [is_remote host] { + set loader [remote_download host $loader]; + } + } + remote_send host "file $loader\n"; + remote_expect host 20 { + -re "A program is being debug.*Kill it.*y or n. $" { + remote_send host "y\n" + exp_continue + } + -re "Load new symbol table.*y or n. $" { + remote_send host "y\n" + exp_continue + } + -re "Reading symbols from.*done..*$gdb_prompt $" {} + -re "$gdb_prompt $" { warning "GDB couldn't find loader" } + timeout { + warning "(timeout) read symbol file" ; + return -1 + } + } + + if [board_info $dest exists serial] { + set serial [board_info $dest serial]; + } else { + set serial [board_info $dest netport]; + } + remote_send host "target [board_info $dest gdb_protocol] $serial\n"; + remote_expect host 60 { + -re "appears to be alive.*$gdb_prompt" { } + -re "Remote target.*connected to.*$gdb_prompt" { } + -re "$gdb_prompt" { + warning "Error reconnecting to stub."; + return -1; + } + default { + warning "Error reconnecting to stub."; + return -1; + } + } + + # We only send the offset if gdb_load_offset is set. Otherwise, we + # assume that sending the offset isn't needed. + if [board_info $dest exists gdb_load_offset] { + remote_send host "load $loader [board_info $dest gdb_stub_offset]\n" + } else { + remote_send host "load $loader\n"; + } + verbose "Loading $loader into $GDB" 2 + global verbose + set no_run_command 0; + # FIXME: The value 1200 below should be a parameter. + remote_expect host 1200 { + -re "Transfer rate:.*Switching to remote protocol.*Remote debugging" { + set no_run_command 1; + remote_send host ""; + sleep 2; + remote_send host ""; + sleep 1; + } + -re "Loading.*Starting.*at.*$gdb_prompt $" { + verbose "Loaded $loader into $GDB" 1 + set no_run_command 1; + } + -re "Loading.*$gdb_prompt $" { + verbose "Loaded $loader into $GDB" 1 + } + -re "$gdb_prompt $" { + if $verbose>1 then { + warning "GDB couldn't load." + } + } + timeout { + if $verbose>1 then { + warning "Timed out trying to load $arg." + } + } + } + + if { ! $no_run_command } { + remote_send host "run\n"; + remote_expect host 60 { + -re "A program is being debug.*Kill it.*y or n. $" { + remote_send host "y\n" + exp_continue + } + -re "The program being debugged .*y or n. $" { + remote_send host "y\n" + exp_continue + } + -re "Starting program:.*loader.*$" { + verbose "Starting loader succeeded" + } + timeout { + warning "(timeout) starting the loader" ; + return -1 + } + default { + warning "error starting the loader"; + } + } + sleep 2; + remote_send host "" + sleep 1; + remote_send host "" + verbose "Sent ^C^C" + remote_expect host 30 { + -re "Give up .and stop debugging it.*$" { + remote_send host "y\n" + exp_continue + } + -re "$gdb_prompt $" { + verbose "Running loader succeeded" + } + timeout { + warning "(timeout) interrupting the loader" ; + return -1 + } + default { + warning "error interrupting the loader"; + } + } + } + remote_send host "quit\n"; + return [gdb_stub_restart $dest]; + } + return 1; +} + +# +# Delete all breakpoints and verify that they were deleted. If anything +# goes wrong we just exit. +# +proc gdb_stub_delete_breakpoints {} { + global gdb_prompt + + remote_send host "delete breakpoints\n" + remote_expect host 10 { + -re "Delete all breakpoints.*y or n. $" { + remote_send host "y\n" + exp_continue + } + -re "$gdb_prompt $" { } + timeout { warning "Delete all breakpoints (timeout)" ; return -1} + } + remote_send host "info breakpoints\n" + remote_expect host 10 { + -re "No breakpoints or watchpoints..*$gdb_prompt $" {} + -re "$gdb_prompt $" { warning "breakpoints not deleted" ; return -1} + timeout { warning "info breakpoints (timeout)" ; return -1} + } + return 0; +} + +proc gdb_stub_go_idle { dest } { + gdb_stub_delete_breakpoints +} + +proc gdb_stub_add_breakpoint { function args } { + global gdb_prompt + + remote_send host "break $function\n" + remote_expect host 60 { + -re "Breakpoint (\[0-9\]+).*$gdb_prompt $" { return $expect_out(1,string) } + -re "Function.*not defined.*$gdb_prompt $" { return "undef" } + -re "No symbol table.*$gdb_prompt $" { return "undef" } + default { + return "undef" + } + } +} + +proc gdb_stub_start { dest } { + global gdb_prompt; + + set exit_brnum [gdb_stub_add_breakpoint _exit]; + if { $exit_brnum == "undef" || [board_info $dest exists always_break_exit] } { + set exit_brnum [gdb_stub_add_breakpoint exit]; + } + set abort_brnum [gdb_stub_add_breakpoint abort]; + + upvar #0 gdb_stub_info I + set I($dest,exit_brnum) $exit_brnum + set I($dest,abort_brnum) $abort_brnum + + remote_send host "set \$fp=0\n"; + remote_expect host 10 { + -re "$gdb_prompt" { } + } + # This is needed for the SparcLite. Whee. + if [board_info $dest exists gdb,start_symbol] { + set start_comm "jump *[board_info $dest gdb,start_symbol]\n"; + } else { + set start_comm "jump *start\n"; + } + remote_send host "break copyloop\n"; + remote_expect host 10 { + -re "Breakpoint.*$gdb_prompt $" { + set start_comm "continue\n"; + } + -re "Function.*not defined.*$gdb_prompt $" { } + default { } + } + remote_send host $start_comm; + remote_expect host 10 { + -re "y or n. $" { + remote_send host "y\n" + exp_continue; + } + -re "Breakpoint.*in copyloop.*$gdb_prompt $" { + remote_send host "jump relocd\n"; + exp_continue; + } + -re "Continuing at.*\[\r\n\]" { } + default { + return { "fail" "" }; + } + } + return { "pass" "" }; +} + +proc gdb_stub_spawn { dest prog args } { + for { set x 0; } { $x < 3 } { incr x } { + if { [remote_ld $dest $prog] != 1 } { + return [list "fail" "remote_ld failed"]; + } + + set result [gdb_stub_start $dest]; + if { [lindex $result 0] != "pass" } { + remote_reboot target; + } else { + return 666; # does anyone use this value? + } + } + return -1; +} + +proc gdb_stub_wait { dest timeout } { + global gdb_prompt + + + upvar #0 gdb_stub_info I + set exit_brnum $I($dest,exit_brnum) + set abort_brnum $I($dest,abort_brnum) + + remote_expect host $timeout { + -re "Breakpoint.*exit.*=0.*$gdb_prompt $" { + gdb_stub_go_idle $dest + return [list 0 ""]; + } + -re "Breakpoint.*exit.*=\[1-9\]\[0-9\]*.*$gdb_prompt $" { + gdb_stub_go_idle $dest + return [list 0 ""]; + } + -re "Breakpoint.*exit.*$gdb_prompt $" { + gdb_stub_go_idle $dest + return [list 0 ""]; + } + -re "Breakpoint.*abort.*$gdb_prompt $" { + gdb_stub_go_idle $dest + return [list 1 ""]; + } + -re " EXIT code 0.*$gdb_prompt $" { + gdb_stub_go_idle $dest; + return [list 0 ""]; + } + -re " EXIT code \[1-9]\[0-9]*.*$gdb_prompt $" { + gdb_stub_go_idle $dest; + return [list 0 ""]; + } + -re " EXIT code 4242.*$gdb_prompt $" { + gdb_stub_go_idle $dest; + return [list 1 ""]; + } + -re "Program received.*$gdb_prompt $" { + gdb_stub_go_idle $dest + return [list 1 ""]; + } + -re "Program exited.*$gdb_prompt $" { + gdb_stub_go_idle $dest + return [list 1 ""]; + } + -re "Breakpoint $exit_brnum.*$gdb_prompt $" { + gdb_stub_go_idle $dest; + return [list 0 ""]; + } + -re "Breakpoint $abort_brnum.*$gdb_prompt $" { + gdb_stub_go_idle $dest; + return [list 1 ""]; + } + default { + remote_close $dest; + remote_reboot $dest; + return [list -1 ""]; + } + } + return [list -1 ""]; +} + +proc gdb_stub_load { dest prog args } { + global gdb_prompt + set argnames { "command-line arguments" "input file" "output file" } + + for { set x 0; } { $x < [llength $args] } { incr x } { + if { [lindex $args $x] != "" } { + return [list "unsupported" "no support for [lindex $argnames $x] on this target"]; + } + } + + set result [remote_spawn $dest $prog]; + + if { $result < 0 } { + return [list "fail" "remote_spawn failed"]; + } + + # FIXME: The value 120 should be a parameter. + set result [remote_wait $dest 120]; + set status [lindex $result 0]; + set output [lindex $result 1]; + + if { $status == 0 } { + return [list "pass" $output]; + } elseif { $status > 0 } { + return [list "fail" $output]; + } else { + global gdb_stub_retry; + + if ![info exists gdb_stub_retry] { + set gdb_stub_retry 1; + + set result [eval gdb_stub_load \{$dest\} \{$prog\} $args]; + unset gdb_stub_retry; + return $result; + } else { + return [list "fail" $output]; + } + } +} + + +# +# gdb_stub_ld -- load PROG into the board; +# Returns a 0 if there was an error, +# 1 if it loaded successfully. +# +proc gdb_stub_ld { dest prog } { + global gdb_prompt + global GDB + + if ![board_info $dest exists gdb_is_running] { + if ![gdb_stub_restart $dest] { + return 0; + } + } + + set loadfile [file tail $prog] + set loadpath [file dirname $prog] + + remote_send host "file $prog\n" + remote_expect host 30 { + -re "A program is being debug.*Kill it.*y or n. $" { + remote_send host "y\n" + exp_continue + } + -re "Load new symbol table.*y or n. $" { + remote_send host "y\n" + exp_continue + } + -re "Reading symbols from.*done..*$gdb_prompt $" {} + -re "$gdb_prompt $" { + # Hmmm...is retrying going to help? I kinda doubt it. + warning "GDB couldn't read file" + return [gdb_stub_retry_ld "$dest" "$prog"]; + } + timeout { + warning "(timeout) read symbol file"; + return [gdb_stub_retry_ld "$dest" "$prog"]; + } + } + + # just in case there are old breakpoints lying around. + gdb_stub_delete_breakpoints + + if [board_info $dest exists gdb_serial] { + set serial [board_info $dest gdb_serial]; + } elseif [board_info $dest exists serial] { + set serial [board_info $dest serial]; + } else { + set serial [board_info $dest netport]; + } + + remote_send host "target remote $serial\n" + remote_expect host 60 { + -re "Kill it?.*y or n.*" { + remote_send host "y\n"; + exp_continue + } + -re "$gdb_prompt $" { + verbose "Set remote target to $serial" 2 + } + timeout { + warning "Couldn't set remote target." + return 0 + } + } + + if [board_info $dest exists gdb_load_offset] { + set offset "[board_info $dest gdb_load_offset]"; + } else { + set offset ""; + } + remote_send host "load $prog $offset\n" + verbose "Loading $prog into $GDB" 2 + global verbose; + remote_expect host 1200 { + -re "Loading.*$gdb_prompt $" { + verbose "Loaded $prog into $GDB" 1 + } + -re "$gdb_prompt $" { + if $verbose>1 then { + warning "GDB couldn't load." + } + } + timeout { + if $verbose>1 then { + perror "Timed out trying to load $prog." + } + } + } + return 1 +} + +# +# Retry the ld operation, but only once. +# + +proc gdb_stub_retry_ld { dest prog } { + global gdb_stub_retry_ld; + + remote_reboot $dest; + if [info exists gdb_stub_retry_ld] { + unset gdb_stub_retry_ld; + return 0; + } else { + set gdb_stub_retry_ld 1; + } + gdb_stub_restart $dest; + set status [gdb_stub_ld $dest $prog]; + if [info exists gdb_stub_retry_ld] { + unset gdb_stub_retry_ld; + } + return $status; +} + +proc gdb_stub_close { dest } { + global board_info + set name [board_info $dest name]; + if [info exists board_info($name,gdb_is_running)] { + unset board_info($name,gdb_is_running); + } + return [remote_close host]; +} + +set_board_info protocol "gdb_stub" diff --git a/config/h8300.exp b/config/h8300.exp new file mode 100644 index 0000000..3fffb06 --- /dev/null +++ b/config/h8300.exp @@ -0,0 +1,20 @@ +# Copyright (C) 1997 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +# Please email any bugs, comments, and/or additions to this file to: +# DejaGnu@cygnus.com + +load_generic_config "gdb-comm"; diff --git a/config/i386-bozo.exp b/config/i386-bozo.exp new file mode 100644 index 0000000..563da32 --- /dev/null +++ b/config/i386-bozo.exp @@ -0,0 +1,46 @@ +# Copyright (C) 1997 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +# Please email any bugs, comments, and/or additions to this file to: +# DejaGnu@cygnus.com + +load_generic_config "gdb-comm"; + +proc ${board}_init { args } { + set linux_box [target_info linux_box]; + set bozo_server [target_info bozo_server]; + remote_spawn $linux_box "$bozo_server unknown"; + remote_expect $linux_box 60 { + -re "port is (\[0-9\]+)" { + set_currtarget_info netport "${linux_box}:$expect_out(1,string)"; + } + } +} + +proc ${board}_close { board } { + set linux_box [board_info $board linux_box]; + if [board_info $linux_box exists fileid] { + remote_send $linux_box "\003"; + remote_close $linux_box; + } + standard_close $board; +} + +proc ${board}_reboot { board args } { + remote_close $board; + unset_currtarget_info netport; + return 1; +} diff --git a/config/i960.exp b/config/i960.exp new file mode 100644 index 0000000..dcca835 --- /dev/null +++ b/config/i960.exp @@ -0,0 +1,221 @@ +# Copyright (C) 1997, 1998, 1999 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +# Please email any bugs, comments, and/or additions to this file to: +# DejaGnu@cygnus.com + +# +# Initialize the board on initial connection or after rebooting. +# Since the board autobauds, we have to be a bit aggressive about +# getting a valid prompt. +# +proc ${board}_init { dest } { + global i960_try_count; + + set prompt [board_info $dest shell_prompt]; + set done 0; + + if ![info exists i960_try_count] { + set i960_try_count 1; + } + + remote_close $dest; + if { [remote_open $dest] != "" } { + for { set tries 0; } { $tries < 7 && ! $done } { incr tries } { + remote_send $dest "\n"; + remote_expect $dest 1 { + -re "${prompt}" { + set done 1; + } + -re ".+" { exp_continue } + timeout { } + } + } + } + + remote_close $dest; + if { ! $done } { + if { $i960_try_count == 3 } { + perror "Couldn't connect to board."; + } else { + incr i960_try_count; + remote_close $dest; + remote_reboot $dest; + } + } + if [info exists i960_try_count] { + unset i960_try_count; + } +} + +proc i960_ld { dest prog } { + if ![file exists $prog] { + perror "$prog does not exist." + return "untested" + } + set shell_prompt [board_info $dest shell_prompt]; + set strip [board_info $dest strip]; + set rprog [remote_download host $prog a.out]; + if { $strip != "" } { + remote_exec host $strip $rprog; + } + remote_upload host $rprog a.out; + + set id [remote_open $dest]; + if { $id < 0 } { + return -1; + } + remote_binary $dest; + remote_send $dest "\n"; + remote_expect $dest 5 { + -re $shell_prompt { } + } + remote_send $dest "do\n"; + remote_expect $dest 5 { + -re "Downloading" { } + } + # Nasty. + if { [board_info $dest connect] == "telnet" } { + global board_info; + + remote_close $dest; + set hp [split [board_info $dest netport] ":"]; + set host [lindex $hp 0]; + set port [lindex $hp 1]; + set status -1; + while { $status != 0 } { + set status [catch "socket $host $port" id2]; + if { $status != 0 } { + sleep 5; + } + } + } else { + set id2 [exp_open -leaveopen -i $id]; + } + if [catch "exec sx -bX a.out <@$id2 >@$id2 2>/dev/null" error] { + perror "exec sx failed: $error" + } + if { [board_info $dest connect] == "telnet" } { + close $id2; + sleep 2; + remote_open $dest; + remote_binary $dest; + } + set result 1; + remote_send $dest "\n"; + remote_expect $dest 1 { + -re "$shell_prompt" { + set result 0; + exp_continue; + } + timeout { } + } + return $result; +} + +proc i960_spawn { dest prog args } { + set shell_prompt [board_info $dest shell_prompt]; + + for { set tries 0 ; } { $tries < 3 } { incr tries } { + set result [remote_ld $dest $prog]; + if { $result == 0 } { + set comm "go [board_info $dest start_addr]"; + remote_send $dest "$comm\n"; + remote_expect $dest 10 { + -re "$comm\[\r\n\]\[\r\n\]?" { } + default { } + } + return [board_info $dest fileid]; + } else { + remote_reboot $dest; + } + } + return -1; +} + +proc i960_wait { dest timeout } { + set output ""; + set shell_prompt [board_info $dest shell_prompt]; + + remote_expect $dest $timeout { + -re " fault at \[0-9a-h\]+, subtype \[0-9a-h\]+" { + set status -1; + exp_continue; + } + -re "(.*)(\[\r\n\]|^)Program Exit: (\[0-9\]+)\[\r\n\]" { + append output $expect_out(1,string); + set status $expect_out(3,string); + exp_continue; + } + -re "(.*)$shell_prompt" { + append output $expect_out(1,string); + set bstatus [check_for_board_status output]; + if { $bstatus >= 0 } { + set status $bstatus; + } + } + -re "\[\r\n\]+" { + # Sometimes the board goes wacky in the head, and we have + # to shoot it. + append output $expect_out(buffer); + if { [string length $output] < 512000 } { + exp_continue; + } else { + set status -1; + } + } + default { + set status -1; + } + } + return [list $status $output]; +} + +proc i960_load { dest prog args } { + for { set x 0; } { $x < 3 } { incr x; } { + set id [eval remote_spawn \{$dest\} \{$prog\} $args]; + if { $id < 0 } { + return [list "fail" ""]; + } + set result [remote_wait $dest 120]; + set status [lindex $result 0]; + set output [lindex $result 1]; + + if { $status == 0 } { + return [list "pass" $output]; + } else { + global i960_retry; + + if { [board_info $dest exists unreliable] && ![info exists i960_retry] } { + set i960_retry 1; + remote_reboot $dest; + set result [eval i960_load \{$dest\} \{$prog\} $args]; + unset i960_retry; + return $result; + } else { + if { $status < 0 } { + remote_reboot $dest; + } + return [list "fail" $output]; + } + } + } +} + +set_board_info shell_prompt "=>"; +set_board_info send_initial_cr 1; +# We take care of getting a prompt in ${board}_init. +set_board_info dont_wait_for_prompt 1; diff --git a/config/m32r-stub.exp b/config/m32r-stub.exp new file mode 100644 index 0000000..7cdfd23 --- /dev/null +++ b/config/m32r-stub.exp @@ -0,0 +1,20 @@ +# Copyright (C) 1997 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +# Please email any bugs, comments, and/or additions to this file to: +# DejaGnu@cygnus.com + +load_generic_config "gdb_stub"; diff --git a/config/m32r.exp b/config/m32r.exp new file mode 100644 index 0000000..3fffb06 --- /dev/null +++ b/config/m32r.exp @@ -0,0 +1,20 @@ +# Copyright (C) 1997 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +# Please email any bugs, comments, and/or additions to this file to: +# DejaGnu@cygnus.com + +load_generic_config "gdb-comm"; diff --git a/config/m68k-emc.exp b/config/m68k-emc.exp new file mode 100644 index 0000000..852453c --- /dev/null +++ b/config/m68k-emc.exp @@ -0,0 +1,52 @@ +proc ${board}_init { dest } { + global doing_emc_init; + + if [info exists doing_emc_init] { + return; + } + set doing_emc_init 1; + remote_close $dest; + set dos_host [board_info $dest dos_host]; + remote_reboot $dos_host; + unset doing_emc_init; +} + +proc m68k_emc_board_connect { dest } { + global board_info; + set tname [board_info $dest name]; + + set board_info($tname,m68k_connected) 1; + set dos_host [board_info $dest dos_host]; + + for { set x 0; } { $x < 3 } { incr x; } { + set shell_id [remote_open $dos_host]; + if { $shell_id == "" || $shell_id < 0 } { + remote_reboot $dos_host; + } else { + break; + } + } + remote_send $dos_host "c:\\symetrix.bat\n"; + remote_expect $dos_host 300 { + -re "SymmComm.*Installed.*\033.2J.*\033.2J" { } + default { + warning "Never got clear screen sequence from remote side." + } + } + # Flush the buffer. + remote_expect $dos_host 2 { + -re ".+" { exp_continue; } + } + # Get past first menu. + remote_send $dos_host "\n"; + remote_expect $dos_host 10 { + -re "\033.07;02H" { } + default { } + } + # We don't want a log file. + remote_send $dos_host "\n"; + remote_expect $dos_host 10 { + -re "\033.02;24H" { } + default { } + } +} diff --git a/config/mips-idt.exp b/config/mips-idt.exp new file mode 100644 index 0000000..eacdb4d --- /dev/null +++ b/config/mips-idt.exp @@ -0,0 +1,24 @@ +# Copyright (C) 1997 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +# Please email any bugs, comments, and/or additions to this file to: +# bug-gcc@prep.ai.mit.edu + +# For MIPS/IDT we use gdb to load and execute programs. + +load_generic_config "gdb-comm"; + +set_board_info gdb_init_command "set syn-garbage-limit 0"; diff --git a/config/mn10200-eval.exp b/config/mn10200-eval.exp new file mode 100644 index 0000000..9af6ae5 --- /dev/null +++ b/config/mn10200-eval.exp @@ -0,0 +1,22 @@ +# Copyright (C) 1998 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +# Please email any bugs, comments, and/or additions to this file to: +# bug-gcc@prep.ai.mit.edu + +# For MN10200 evaluation boards we use gdb to load and execute programs. + +load_generic_config "gdb-comm"; diff --git a/config/mn10300-eval.exp b/config/mn10300-eval.exp new file mode 100644 index 0000000..1070b42 --- /dev/null +++ b/config/mn10300-eval.exp @@ -0,0 +1,22 @@ +# Copyright (C) 1998 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +# Please email any bugs, comments, and/or additions to this file to: +# bug-gcc@prep.ai.mit.edu + +# For MN10300 evaluation boards we use gdb to load and execute programs. + +load_generic_config "gdb-comm"; diff --git a/config/netware.exp b/config/netware.exp new file mode 100644 index 0000000..75d8149 --- /dev/null +++ b/config/netware.exp @@ -0,0 +1,214 @@ +# Copyright (C) 1994, 1996, 1997 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +# Please email any bugs, comments, and/or additions to this file to: +# bug-gcc@prep.ai.mit.edu + +# This file was written by J.T. Conklin. (jtc@cygnus.com) + +# +# load support libraries +# +load_lib remote.exp + +# set target variables only if needed + +proc ${board}_init { args } { + global NLMCONV + if ![info exists NLMCONV] then { + set NLMCONV [findfile "$rootme/../binutils/nlmconv"] + } + global LD + if ![info exists LD] then { + set LD [findfile "$rootme/../ld/ld-new" "$rootme/../ld/ld-new" [transform "ld"]] + } + + set shell_prompt "Password:" + set shell_id [remote_open target]; + if [target_info exists passwd] { + set passwd [target_info passwd]; + } else { + set passwd ""; + } + if $shell_id<0 then { + warning "Couldn't connect to target" + return -1 + } + + if [string match "" $passwd] then { + stty -echo + send_user "Password: " + expect_user -re "(.*)\n" + send_user "\n" + set passwd "$expect_out(1,string)" + stty echo + } + + send -i $shell_id "$passwd\n" + expect { + -i $shell_id ":" { + verbose "Got termtype prompt" 0 + } + + -i $shell_id timeout { + warning "Connection timed out" + return -1 + } + } + + # FIXME + set shell_prompt "[string toupper [target_info name]]:" + send -i $shell_id "1\n" + + expect { + -i $shell_id -re "$shell_prompt" {} + -i $shell_id timeout { + warning "Connection timed out" + return -1 + } + } +} + + +# +# ${board}_load -- load the program and execute it +# +# See default.exp for explanation of arguments and results. +# + +proc ${board}_load { dest prog args } { + global LD NLMCONV + global tmpdir + global errorCode + + if [board_info $dest exists fileid] { + set shell_id [board_info $dest fileid]; + } else { + set shell_id -1; + } + + set output "" + + if $shell_id<0 then { + verbose -log "$prog not executed because there is no target" 3 + return "untested" + } + + # + set exe [file tail $prog] + + # We can't blindly append a suffix to the object name, because the + # result may not be valid on netware's 8.3 filesystem. + set nlm "$tmpdir/x.nlm" + set lnk "$tmpdir/x.lnk" + + # build *.lnk file + set fd [open $lnk w] + puts $fd "description \"$exe\"" + puts $fd "screenname \"System Console\"" + puts $fd "module clib.nlm" + puts $fd "module mathlib.nlm" + puts $fd "stack 65536" + puts $fd "debug" + # FIXME: don't hardcode location of prelude.o + puts $fd "input /s1/cygnus/dejagnu/i386-netware/lib/prelude.o" + puts $fd "input $prog" + puts $fd "output $nlm" + close $fd + + # run nlmconv + verbose "Executing: $NLMCONV -l$LD -T$lnk" 1 + catch "exec $NLMCONV -l$LD -T$lnk" output + if ![string match "" $output] then { + verbose $output 1 + } + if ![string match "NONE" $errorCode] { + verbose -log "Can't link $prog" 3 + return "fail" + } + + # download + verbose "Downloading $nlm" 1 + catch "exec cp $nlm /.NetWare/[board_info $dest name].nws/sys.nwv/tmp/x.nlm" output + if ![string match "" $output] then { + verbose $output 1 + verbose -log "cp failed for $nlm" 3 + return "unresolved" + } + + # Wait a second for the file to "settle" on the NetWare server. + # I've encountered unexplained failures without this delay. +# sleep 1 + + + # The NetWare remote console expects to be connected to a vt100 + # compatible terminal. It isn't very efficent, and it seems to + # send screen repaints for no reason. So we have to clear the + # screen as we run each test, otherwise a shell prompt or abort + # message from a previous test could cause incorrect results. + send -i $shell_id "CLS\r\n" + set timeout 1 + expect { + -i $shell_id -re "$shell_prompt" { + exp_continue + } + } + set timeout 10 + + + # Netware does not support exit status. The best we can do to + # detect failures is to look for the "ABNORMAL NLM TERMINATION" + # message printed by abort(). + set ret 0 + send -i $shell_id "LOAD X.NLM\r\n" + expect { + -i $shell_id "ABNORMAL NLM TERMINATION" { + set ret 1 + exp_continue + } + -i $shell_id "Unable to find load file" { + perror "Couldn't execute program" + verbose -log "Couldn't execute program" 3 + return "unresolved" + } + -i $shell_id timeout { + perror "Couldn't execute program (timed out)" + verbose -log "Couldn't execute program (timed out)" 3 + return "unresolved" + } + -i $shell_id -re "[format "%sLOAD" $shell_prompt]" { + exp_continue + } + -i $shell_id -re "$shell_prompt" {} + } + + catch [exec rm -f $lnk] + catch [exec rm -f $nlm] + + if { $ret == 0 } { + return "pass" + } else { + return "fail" + } +} + +# +# ${tool}_exit -- shutdown the connection +# + +proc ${board}_exit {} { + remote_close target; +} diff --git a/config/powerpc-bug.exp b/config/powerpc-bug.exp new file mode 100644 index 0000000..3fffb06 --- /dev/null +++ b/config/powerpc-bug.exp @@ -0,0 +1,20 @@ +# Copyright (C) 1997 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +# Please email any bugs, comments, and/or additions to this file to: +# DejaGnu@cygnus.com + +load_generic_config "gdb-comm"; diff --git a/config/proelf.exp b/config/proelf.exp new file mode 100644 index 0000000..310af21 --- /dev/null +++ b/config/proelf.exp @@ -0,0 +1,27 @@ +# Copyright (C) 1997 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +# Please email any bugs, comments, and/or additions to this file to: +# DejaGnu@cygnus.com + +load_generic_config "base68k"; +set_board_info shell_prompt "#" +set_board_info download_command "r 0\n"; +set_board_info go_command "g" +set_board_info startaddr "40000" + +set_board_info go_response "\[\r\n\]+\[a-z \]+\\(\[0-9\]+\\) pc=\[0-9A-Ha-h\]+\[\r\n\]+\[0-9A-H\]+ \[0-9A-H\]+ \[^\r\n\]+\[\r\n\]+|\\*\\*\\*EXIT code " +set_board_info output_end "\[\r\n\]+\[a-z \]+\\(\[0-9\]+\\) pc=\[0-9A-Ha-h\]+\[\r\n\]+.*$" diff --git a/config/rom68k.exp b/config/rom68k.exp new file mode 100644 index 0000000..63721f8 --- /dev/null +++ b/config/rom68k.exp @@ -0,0 +1,32 @@ +# Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +# Please email any bugs, comments, and/or additions to this file to: +# DejaGnu@cygnus.com + +# This file was written by Bob Manson (manson@cygnus.com) +# based on earlier work by J.T. Conklin (jtc@cygnus.com) + +load_generic_config "base68k"; + +set_board_info shell_prompt "ROM68K :-> " +set_board_info download_command "DC\n"; +set_board_info download_response "Waiting for S-records from host... "; +set_board_info go_command "GO" +set_board_info startaddr "10000" +set_board_info hex_startaddr "0x10000" +set_board_info go_response "(Emul|RS Except|TRAP #\[1-9\]|\\*\\*\\*EXIT code ).*" +set_board_info output_end "\[\r\n\]((\[^\r\n\]*\[\r\n\]-----*)|Emul|RS Except|TRAP #|Bus/Address).*$" diff --git a/config/sh.exp b/config/sh.exp new file mode 100644 index 0000000..3fffb06 --- /dev/null +++ b/config/sh.exp @@ -0,0 +1,20 @@ +# Copyright (C) 1997 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +# Please email any bugs, comments, and/or additions to this file to: +# DejaGnu@cygnus.com + +load_generic_config "gdb-comm"; diff --git a/config/sim.exp b/config/sim.exp new file mode 100644 index 0000000..74edc6f --- /dev/null +++ b/config/sim.exp @@ -0,0 +1,124 @@ +# Copyright (C) 1993, 1994, 1996, 1997, 1998 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +# Please email any bugs, comments, and/or additions to this file to: +# bug-dejagnu@prep.ai.mit.edu + +# +# sim_load -- load the program and execute it +# +# See default.exp for explanation of arguments and results. +# + +proc sim_spawn { dest cmdline args } { + if ![board_info $dest exists sim] { + perror "no simulator defined for [board_info $dest name]" + exit 1 + } else { + set sim [board_info $dest sim]; + } + + if [board_info $dest exists sim,options] { + set simflags [board_info $dest sim,options] + } else { + set simflags "" + } + + if ![is_remote host] { + if { [which $sim] == 0 } { + verbose -log "Simulator $sim missing." 3 + return -1; + } + } + + if [is_remote host] { + # download the program to remote. + # we're assuming the program is the first word in the command. + # FIXME: "prog < infile" won't work until we download infile. + set prog [lindex $cmdline 0] + set prog [remote_download host $prog a.out]; + set cmdline [lreplace $cmdline 0 0 $prog] + } + + return [eval remote_spawn host \{ $sim $simflags $cmdline \} $args]; +} + +proc sim_wait { dest timeout } { + return [remote_wait host $timeout]; +} + +proc sim_load { dest prog args } { + set inpfile "" + if { [llength $args] > 1 } { + if { [lindex $args 1] != "" } { + set inpfile "[lindex $args 1]" + } + } + + if ![file exists $prog] then { + perror "sim.exp: $prog to be downloaded does not exist." + verbose -log "$prog to be downloaded does not exist." 3 + return [list "untested" ""]; + } + + if [board_info $dest exists sim_time_limit] { + set sim_time_limit [board_info $dest sim_time_limit]; + } else { + set sim_time_limit 240 + } + + set output ""; + + # Run the program with a limited amount of real time. While + # this isn't as nice as limiting the amount of CPU time, it + # will have to do. + if { $inpfile != "" } { + set res [remote_spawn target "${prog} < $inpfile" "readonly"]; + } else { + set res [remote_spawn target "${prog}"]; + } + + if { $res <= 0 } { + return [list "fail" "remote_spawn failed"]; + } + + set state [remote_wait target $sim_time_limit]; + set status [lindex $state 0]; + set output [lindex $state 1]; + verbose "Output is $output"; + + set status2 [check_for_board_status output]; + if { $status2 >= 0 } { + set status $status2 + } + + # FIXME: Do we need to examine $status? + # Yes, we do--what if the simulator itself gets an error and coredumps? + + verbose "Return status was: $status" 2 + if { $status == 0 } { + set result "pass" + } else { + set result "fail" + } + return [list $result $output]; +} + +set_board_info protocol "sim"; + +# By default, assume the simulator is slow. This causes some tests +# to either be simplified or skipped completely. +set_board_info slow_simulator 1 diff --git a/config/slite.exp b/config/slite.exp new file mode 100644 index 0000000..19bf612 --- /dev/null +++ b/config/slite.exp @@ -0,0 +1,20 @@ +# Copyright (C) 1996, 1997 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +# Please email any bugs, comments, and/or additions to this file to: +# DejaGnu@cygnus.com + +load_generic_config "gdb_stub"; diff --git a/config/sparclet.exp b/config/sparclet.exp new file mode 100644 index 0000000..3f86098 --- /dev/null +++ b/config/sparclet.exp @@ -0,0 +1,26 @@ +# Copyright (C) 1996, 1997 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +# Please email any bugs, comments, and/or additions to this file to: +# DejaGnu@cygnus.com + +# This file was written by Michael Snyder <msnyder@cygnus.com>. + +load_generic_config "gdb_stub"; + +# This is the old GDB prompt for the toolchain. +# Uncomment for old tests +#set_board_info gdb_prompt "\\(gdbslet\\)"; diff --git a/config/tic80.exp b/config/tic80.exp new file mode 100644 index 0000000..ef12778 --- /dev/null +++ b/config/tic80.exp @@ -0,0 +1,81 @@ +# +# Nasty ugly stuff. +# +# We have to maintain two connections to the DOS box where the board +# is being held. One of them runs an I/O monitor process, while the other +# is used to actually start the program under test running on the board. +# + +proc tic80_load { dest prog args } { + set dos_box [board_info $dest dos_host]; + + remote_spawn $dos_box [board_info $dest io_program]; + + set status [remote_ld $dest $prog]; + + if { $status != "pass" } { + return $status; + } + + set result [remote_wait $dos_box 300]; + set output [lindex $result 1]; + if { [lindex $result 0] < 0 } { + if [board_info $dos_box exists fileid] { + dos_interrupt_job $dos_box; + } else { + remote_close $dos_box; + } + } + + set status "fail"; + regsub "(\\*\\*\\* EXIT code \[0-9\]+\[\r\n]+).*$" "$output" "\\1" output; + verbose "board out is $output"; + set bstatus [check_for_board_status output]; + if { [lindex $result 0] >= 0 } { + if { $bstatus == 0 } { + set status "pass"; + } + } + remote_file build delete "a.fix"; + return [list $status $output]; +} + +proc tic80_ld { dest prog } { + set dos_box [board_info $dest dos_host]; + set dopush 0; + + if { [remote_swap_conn $dos_box] == "fail" } { + if { [remote_push_conn $dos_box] == "fail" } { + set dopush 1; + } + remote_open $dos_box; + } + set prog [remote_download $dos_box $prog "a.fix"]; + + remote_spawn $dos_box "[board_info $dest start_program] $prog"; + remote_expect $dos_box 10 { + -re "file\[(\]s\[)\] copied" {} + } + sleep 3; + dos_interrupt_job $dos_box; + if { $dopush } { + remote_push_conn $dos_box; + } else { + remote_swap_conn $dos_box; + } + return "pass"; +} +# +# Close the connection to the DOS box. +# +proc tic80_close { host } { + set dos_box [board_info $host dos_host]; + + return [remote_close $dos_box]; +} + +set_board_info protocol "tic80"; +set_board_info gdb,use_standard_load 1; +set_board_info gdb,no_push_conn 1; +set_board_info gdb,do_reload_on_run 1; +set_board_info gdb,use_breakpoint_for_stub 1 diff --git a/config/udi.exp b/config/udi.exp new file mode 100644 index 0000000..4e10c4f --- /dev/null +++ b/config/udi.exp @@ -0,0 +1,158 @@ +# Copyright (C) 1994, 1996, 1997 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +# Please email any bugs, comments, and/or additions to this file to: +# DejaGnu@cygnus.com + +# This file was originally written by Rob Savoye. (rob@cygnus.com) +# and modified by Bob Manson (manson@cygnus.com) + +# When using the simulator (-n iss) and running nice'd, things can naturally +# take a little longer, so increase the timeout. + +# +# udi_load -- load the program and execute it +# +# See default.exp for explanation of arguments and results. +# + +proc udi_load { dest prog args } { + set shell_prompt [board_info $dest shell_prompt]; + set output ""; + + if ![file exists $prog] then { + perror "$prog does not exist." + verbose -log "$prog does not exist." 3 + return [list "untested" ""]; + } + + # Load the program. + if ![board_info $dest exists fileid] then { + remote_open $dest; + if ![board_info $dest exists fileid] then { + verbose -log "$prog not executed, couldn't connect to $dest." 3 + return "untested" + } + } + + if { [remote_ld $dest $prog] == "" } { + verbose -log "$prog not executed, load failed." 3 + return [list "unresolved" ""]; + } + + # Execute it. + set result -1 + set output ""; + set noappend 0; + + verbose "Executing $prog." 2 + remote_send $dest "g\n" + # FIXME: The value 300 below should be a parameter. + remote_expect $dest 300 { + -re "(.*)Process exited with 0x0\[^\r\n\]*\[\r\n\]" { + append output $expect_out(1,string); + verbose "$prog executed successfully" 2 + set noappend 1; + set result 0; + exp_continue; + } + -re "(.*)Halt instruction encountered" { + append output $expect_out(1,string); + verbose "$prog got a HALT instruction" 2 + set result 1; + set noappend 1; + exp_continue; + } + -re "(^|\[\r\n\])$shell_prompt" { + if { $result == -1 } { + exp_continue; + } + } + -re "(^|\[\r\n\]+)g\[\r\n\]+" { + exp_continue; + } + -re "\[\r\n\]+" { + if { ! $noappend } { + append output $expect_out(buffer); + if { [string length $output] < 512000 } { + exp_continue; + } else { + set result 1; + } + } else { + exp_continue; + } + } + timeout { + warning "$prog timed out." + } + } + + # See what happened. + switch -- $result { + 0 { + set status [check_for_board_status output]; + if { $status < 0 } { + blammo + } + if { $status > 0 } { + set result "fail"; + } else { + set result "pass" + } + } + 1 - -1 { + warning "Resetting $dest." + remote_send $dest "r\n" + remote_expect $dest 5 { + -re "r.*$shell_prompt.*" { + verbose "Target reset." 2 + } + timeout { + # Get nastier. We want to leave the system in a state + # ready to run the next testcase. + remote_send $dest "q\n" + remote_close $dest; + set udi_shell_id [remote_open $dest] + if { $udi_shell_id < 0 } { + perror "Couldn't reset $dest." + } + } + } + if { $result == 1 } { + set result "fail" + } else { + set result "unresolved" + } + } + default { + set result "unresolved" + } + } + return [list $result $output]; +} + +# +# udi_exit -- shutdown the connection (or simulator) +# + +proc udi_exit {} { + remote_close target; +} + +set_board_info protocol "udi"; +set_board_info connect "mondfe"; +set_board_info shell_prompt "mondfe>"; diff --git a/config/unix.exp b/config/unix.exp new file mode 100644 index 0000000..d3e7fab --- /dev/null +++ b/config/unix.exp @@ -0,0 +1,134 @@ +# Copyright (C) 92, 1993, 1994, 1996, 1997, 1998 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +# Please email any bugs, comments, and/or additions to this file to: +# bug-gcc@prep.ai.mit.edu + +# This file was written by Rob Savoye. (rob@cygnus.com) + +if ![info exists board] { + error "must set $board before loading unix.exp" +} + +# For rcp_download, rsh_exec. +load_lib remote.exp + +# +# unix_load -- load the program and execute it +# +# See default.exp for explanation of arguments and results. +# + + +proc unix_load { dest prog args } { + global ld_library_path + set output ""; + + if { [llength $args] > 0 } { + set parg [lindex $args 0]; + } else { + set parg "" + } + + if { [llength $args] > 1 } { + set inp [lindex $args 1]; + } else { + set inp "" + } + + if ![file exists $prog] then { + # We call both here because this should never happen. + perror "$prog does not exist in unix_load." + verbose -log "$prog does not exist." 3 + return "untested" + } + verbose "loading to $dest" 2 + if ![is_remote $dest] { + if { "$inp" != "" } { + set command "$prog $parg < $inp" + } else { + set command "$prog $parg"; + } + + if [info exists ld_library_path] { + setenv LD_LIBRARY_PATH $ld_library_path + setenv SHLIB_PATH $ld_library_path + } + + set id [remote_spawn $dest "$command" "readonly"]; + if { $id < 0 } { + set output "remote_spawn failed" + set status -1; + } else { + set status [remote_wait $dest 300]; + set output [lindex $status 1]; + set status [lindex $status 0]; + } + # Unset them so we don't potentially get hosed when we try to run a + # non-testcase executable. (Setting LD_LIBRARY_PATH is the wrong + # fix in the first place; this just tries to minimize the resulting + # crap.) + if [info exists ld_library_path] { + unsetenv LD_LIBRARY_PATH + unsetenv SHLIB_PATH + } + } else { + set remotefile "/tmp/[file tail $prog].[pid]" + set remotefile [remote_download $dest $prog $remotefile]; + if { $remotefile == "" } { + verbose -log "Download of $prog to [board_info $dest name] failed." 3 + return [list "unresolved" ""]; + } + if [board_info $dest exists remote_link] { + if [[board_info $dest remote_link] $remotefile] { + verbose -log "Couldn't do remote link" + remote_exec $dest "\\rm -f $remotefile" + return [list "unresolved" ""] + } + + verbose "$prog linked ok" 3 + } else { + # rcp's to lynx seem not to get marked executable + set status [remote_exec $dest "chmod +x $remotefile"] + if { [lindex $status 0] != 0 } { + remote_file $dest delete ${remotefile}.o $remotefile + verbose -log "chmod +x of $prog on $dest failed." 3 + return [list "unresolved" ""]; + } + } + set status [remote_exec $dest "$remotefile" $parg $inp] + remote_file $dest delete $remotefile.o $remotefile; + if { [lindex $status 0] < 0 } { + verbose -log "Couldn't execute $prog, [lindex $status 1]" 3 + return [list "unresolved" ""] + } + set output [lindex $status 1] + set status [lindex $status 0] + } + + verbose "Executed $prog, status $status" 2 + if ![string match "" $output] { + verbose -- "$output" 2 + } + if { $status == 0 } { + set result "pass"; + } else { + set result "fail"; + } + return [list $result $output]; +} + +set_board_info protocol "unix"; diff --git a/config/vr4100.exp b/config/vr4100.exp new file mode 100644 index 0000000..16d20b8 --- /dev/null +++ b/config/vr4100.exp @@ -0,0 +1,21 @@ +# Copyright (C) 1997 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +# Please email any bugs, comments, and/or additions to this file to: +# DejaGnu@cygnus.com + +# We're using a ddb monitor. +load_generic_config "ddb"; diff --git a/config/vr4300.exp b/config/vr4300.exp new file mode 100644 index 0000000..16d20b8 --- /dev/null +++ b/config/vr4300.exp @@ -0,0 +1,21 @@ +# Copyright (C) 1997 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +# Please email any bugs, comments, and/or additions to this file to: +# DejaGnu@cygnus.com + +# We're using a ddb monitor. +load_generic_config "ddb"; diff --git a/config/vr5000.exp b/config/vr5000.exp new file mode 100644 index 0000000..01945cf --- /dev/null +++ b/config/vr5000.exp @@ -0,0 +1,21 @@ +# Copyright (C) 1997 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +# Please email any bugs, comments, and/or additions to this file to: +# DejaGnu@cygnus.com + +# We're using a ddb monitor, but we want to use the ethernet to load files. +load_generic_config "ddb-ether"; diff --git a/config/vrtx.exp b/config/vrtx.exp new file mode 100644 index 0000000..cff962c --- /dev/null +++ b/config/vrtx.exp @@ -0,0 +1,50 @@ +# Copyright (C) 1994, 1996, 1997 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +# Please email any bugs, comments, and/or additions to this file to: +# bug-gcc@prep.ai.mit.edu + +# This file was written by Rob Savoye. (rob@cygnus.com) + +# This file uses the xsh protocol. + +# +# load support libraries +# +load_lib remote.exp + +# +# ${tool}_load -- load the program and execute it +# +# See default.exp for explanation of arguments and results. +# + +proc vrtx_load { dest prog args } { + remote_open $dest; + + switch -- [remote_download $dest $prog] { + 0 { return "pass" } + 1 { return "fail" } + -1 { + # FIXME: This needs work (as does xsh_load). + verbose -log "Unable to run $prog, internal spectra error." 3 + return "unresolved" + } + } +} + +set_board_info protocol "vrtx" +set_board_info connect "xsh" diff --git a/config/vxworks.exp b/config/vxworks.exp new file mode 100644 index 0000000..3ab4a71 --- /dev/null +++ b/config/vxworks.exp @@ -0,0 +1,511 @@ +# Copyright (C) 92, 93, 94, 95, 1996, 1997 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +# Please email any bugs, comments, and/or additions to this file to: +# DejaGnu@cygnus.com + +# This file was originally written by Rob Savoye. (rob@cygnus.com) +# and modified by Bob Manson (manson@cygnus.com) + +# +# Try to boot the machine into the requested OS. +# +proc ${board}_init { dest } { + # This is not the right way to determine the required OS... + global target_os; + set shell_prompt [board_info $dest shell_prompt]; + set do_reboot 0; + + set desired_kernel [board_info $dest "kernel,$target_os"]; + + if { $desired_kernel == "" } { + vxworks_final_init $dest; + # Nothing to see here, nothing to do. Move along. + return; + } + + remote_raw_open $dest raw; + remote_send $dest "\n"; + remote_expect $dest 5 { + -re "$shell_prompt" { + set do_reboot 1; + } + -re "Press any key to stop auto-boot" { + remote_send $dest "\n"; + exp_continue; + } + -re "VxWorks Boot" { + set boot_mon 0; + set boot_mon_prompt "VxWorks Boot"; + } + -re "\[0-9\]\[\r\n\]+ *\[0-9\]\[\r\n\]" { + remote_send $dest "\n"; + exp_continue; + } + timeout { + set do_reboot 1; + } + } + + if { $do_reboot } { + remote_close $dest; + remote_reboot $dest; + return; + } + remote_binary $dest; + remote_send $dest "\n\n"; + remote_expect $dest 3 { + timeout {} + -re ".+" { exp_continue; } + } + remote_send $dest "p\n"; + remote_expect $dest 20 { + -re "file name\[ \t\]+: (\[^ \r\n\]+)\[ \r\n\]+" { + set curr_file $expect_out(1,string); + exp_continue; + } + -re "$boot_mon_prompt" { } + } + if ![info exists curr_file] { + remote_close $dest; + remote_reboot $dest; + return; + } + if { $curr_file != $desired_kernel } { + verbose "$curr_file != '$desired_kernel'"; + # Oh boy. + remote_send $dest "c\n"; + remote_expect $dest 20 { + -re "file name\[ \t\]+:.*$" { + remote_send $dest "$desired_kernel\n"; + exp_continue; + } + -re "\[a-z() \t\]+:.*$" { + remote_send $dest "\n"; + exp_continue; + } + -re "$boot_mon_prompt" {} + } + } + remote_send $dest "@\n"; + remote_expect $dest 30 { + -re "(^|\[\r\n\])$shell_prompt" {} + -re ".+" { + exp_continue; + } + } + vxworks_final_init $dest; + remote_close $dest; +} + +proc vxworks_final_init { dest } { + if [board_info $dest exists preload_obj] { + if { [target_compile [board_info $dest preload_obj] foo.out object [board_info $dest preload_obj_flags]] == "" } { + vxworks_ld $dest foo.out + } + remote_file build delete foo.out; + } +} +# +# Execute the command PROGRAM on VxWorks. +# + +proc vxworks_exec { dest program pargs inp outp } { + global decimal hex; + + set shell_id [vxworks_open $dest]; + if { $shell_id < 0 } { + return [list -1 "open failure"]; + } + + if { $inp != "" } { + set inp [remote_download $dest $inp]; + set suffix " < $inp"; + } else { + set suffix "" + } + + set shell_prompt [board_info $dest shell_prompt]; + remote_send $dest "${program} ${pargs}$suffix\n"; + # FIXME: The value 300 below should probably be a parameter passed in. + remote_expect $dest 300 { + -re "\\\[VxWorks Boot\\\]:" { + remote_send $dest "@\n"; + sleep 20; + exp_continue; + } + -re "(.*)value = (-*$decimal) = $hex\[^\r\n\]*\[\r\n\]+$shell_prompt" { + set result [list $expect_out(2,string) $expect_out(1,string)]; + } + -re "undefined symbol: .*$shell_prompt" { + set result [list 1 "unknown command"]; + } + -re "syntax error.*$shell_prompt" { + set result [list -1 "syntax error in command"]; + } + default { + set result [list -1 "unable to execute command"]; + } + } + if { $suffix != "" } { + remote_file $dest delete $inp; + } + return $result; +} + +proc vxworks_download { dest localfile remotefile } { + if [board_info $dest exists vxworks_homedir] { + set rfile "[board_info $dest vxworks_homedir]/$remotefile"; + remote_download build $localfile $rfile; + return $rfile; + } + return [remote_raw_download $dest $localfile $remotefile]; +} + +proc vxworks_file { dest op args } { + set file [lindex $args 0]; + if [board_info $dest exists vxworks_homedir] { + set dir "[board_info $dest vxworks_homedir]"; + switch $op { + exists { + set file "${dir}/[file tail $file]"; + return [file exists $file]; + } + delete { + foreach x $args { + set x "${dir}/[file tail $x]"; + if { [file exists $x] && [file isfile $x] } { + exec rm -f $x; + } + } + return; + } + } + } + return [eval remote_raw_file \"$dest\" \"$op\" $args]; +} + +proc vxworks_send { dest string } { + # Convert LFs to CRs, 'cause that is what VxWorks wants to see. + regsub -all "\n" $string "\r" string; + verbose "Sending '$string' to $dest" 2 + return [remote_raw_send $dest "$string"]; +} + +proc vxworks_open { dest args } { + if [board_info $dest exists fileid] { + return [board_info $dest fileid]; + } + + set shell_prompt [board_info $dest shell_prompt] + + set shell_id [remote_raw_open $dest]; + + if { $shell_id == "" || $shell_id < 0 } { + return -1; + } + + if [board_info $dest exists logname] { + set logname [board_info $dest logname]; + if [board_info $dest exists password] { + remote_send $dest "iam \"$logname\",\"[board_info $dest passwd]\"\r" + } else { + remote_send $dest "iam \"$logname\"\r" + } + + remote_expect $dest 30 { + "iam*value = 0 = 0x0*$shell_prompt" { + verbose "Set default user." 2 + } + timeout { + # ??? This is really an error. It's not clear whether `perror' + # or `warning' should be used here. There are *lots* of other + # cases like this. + perror "Couldn't set default user." + return -1; + } + } + } + + set dir ""; + if [board_info $dest exists ftp_directory] { + set dir [board_info $dest ftp_directory]; + } + if [board_info $dest exists vxworks_homedir] { + set dir [board_info $dest vxworks_homedir]; + } + if { $dir != "" } { + set status [remote_exec $dest "cd" "\"$dir\""]; + if [lindex $status 0] { + perror "Error in cd to $dir--[lindex $status 1]"; + return 1; + } + } + return $shell_id; +} +# +# Load a file into vxworks +# +# The result is: +# 0 - success +# 1 - failed (eg: link failed so testcase should fail) +# -1 - unresolved (eg: timeout), may be fixed by rebooting +# +proc vxworks_ld { dest prog } { + global decimal hex + global board_info + + if { $prog == "" } { + return 1; + } + + set shell_id [remote_open $dest]; + + if { $shell_id < 0 } { + return -1; + } + + set prog [remote_download $dest $prog]; + + set shell_prompt [board_info $dest shell_prompt]; + + # We always want to exit the program via the code at the end. + # If the load fails we want `expect_out' stored in the log and this + # saves duplicating that code. + + for { set x 0 ; } { $x < 3 } {incr x; } { + remote_send $dest "\n"; + remote_expect $dest 30 { + -re ".*$shell_prompt $" { set x 20; } + -re "\\\[VxWorks Boot\\\]:" { + remote_send $dest "@\n"; + sleep 20; + exp_continue; + } + timeout { return -1; } + } + } + + set tries 0 + set maxtries 3 + set result -7 ;# -7 is a local value meaning "not done" + + while { $result == -7 && $tries < $maxtries } { + verbose "Loading $prog into vxworks." + remote_send $dest "ld < $prog\n"; + incr tries + remote_expect $dest 300 { + -re "USER.*command not understood" { + perror "Need to set the user and password." + set result 1 + } + -re "Stale NFS file handle.*$shell_prompt $" { + # Need to retry. + } + -re "undefined symbol:.*$shell_prompt $" { + # This is an error in the testcase, don't call perror. + warning "Undefined symbol, $prog not loaded." + set result 1 + } + -re "memPartAlloc: block too.*$shell_prompt $" { + perror "Not enough memory to load $prog." + set result -1 + } + -re "can't open input.*$shell_prompt $" { + perror "Can't access $prog." + set result 1 + } + -re "value = (-*${decimal}) = ${hex}.*$shell_prompt $" { + verbose "Loaded $prog into vxworks." + set board_info([board_info $dest name],vx_module) $expect_out(1,string); + set result 0 + } + -re "(.*)$shell_prompt $" { + warning "Load failed: $expect_out(1,string)" + } + timeout { + warning "Timed out trying load $prog." + set result -1 + } + } + } + + if { $result && [info exists expect_out(buffer)] } { + send_log "$expect_out(buffer)" + } + + remote_file $dest delete $prog; + return $result +} + +# +# Start a thread (process) executing +# +# The result is: +# 0 - success +# 1 - failed (eg: testcase aborted) +# -1 - unresolved, may be fixed by rebooting +# +proc vxworks_run { dest function pargs inp outp } { + global hex decimal; + + set shell_prompt [board_info $dest shell_prompt]; + set output ""; + + # There isn't a command to wait for a thread to finish, so we have to keep + # polling. Instead, we expect the status wrapper to return an exit + # status. + + set status [remote_exec $dest "sp" "$function $pargs" $inp $outp]; + + set tid [lindex $status 0]; + + # Bad task id, reboot and try again. + if { $tid == -1 || $tid == 0 } { + return -1; + } + + set result 1; + # FIXME: The value 300 below should be a parameter. + remote_expect $dest 300 { + -re "task ${hex} - aborted.*$shell_prompt $" { + # FIXME: It's not clear we'll ever get here. + verbose "$function aborted" + set result 1 + } + -re "\[\r\n\]syntax error\[\r\n\]" { + verbose "weirdness after task started" + set result -1; + } + -re "(.*)\\*\\*\\* EXIT code ($decimal)\[\r\n\]" { + set output "$expect_out(1,string)"; + set exit_code "$expect_out(2,string)"; + if { ($exit_code + 0) != 0 } { + set result 1; + } else { + set result 0; + } + } + -re "Operation Fault.*fault type:" { + set result 1; + } + -re "Bus Error" { + # This is here to try to cope with apparently flaky h/w. + # This is potentially an error in the testcase, but we don't + # really know, do we? + warning "Bus Error." + set result 1; + set output "Bus Error"; + remote_reboot $dest; + } + timeout { + # Infinite loop? probably. + remote_exec $dest "td" "$tid"; + set result 1; + } + } + + return [list $result $output]; +} + +# +# Unload the last executable that we loaded, so we can free up its memory. +# +proc vxworks_unld { dest } { + global board_info; + + if [board_info $dest exists vx_module] { + # Vxworks5.0 does not have the unld command. + if { [board_info $dest os] != "vxworks5.0" } { + remote_exec $dest "unld" "[board_info $dest vx_module]"; + } + unset board_info([board_info $dest name],vx_module); + } +} + +# +# We loop around rebooting the box until either the load and run +# "work" or we give up. +# +proc vxworks_load {dest prog args} { + set result ""; + set output ""; + + if { [llength $args] > 0 } { + set pargs "[lindex $args 0]"; + } else { + set pargs "" + } + + if { [llength $args] > 1 } { + set inp "[lindex $args 1]"; + } else { + set inp "" + } + + if { [llength $args] > 2 } { + set outp "[lindex $args 2]"; + } else { + set outp "" + } + + for { set x 0; } { $x < 3 } { incr x } { + set status [vxworks_ld $dest $prog]; + if { $status >= 0 } { + if { $status > 0 } { + set result "fail"; + } else { + set out [vxworks_run $dest __wrap_main $pargs $inp $outp]; + set status [lindex $out 0]; + set output [lindex $out 1]; + # Get rid of the carriage returns, because they confuse + # callers that try to parse the result. + regsub -all "\r" $output "" output + if { $status != 0 } { + if { $status > 0 } { + set result "fail"; + } + } else { + set result "pass"; + } + } + } + if { $result != "" } { + vxworks_unld $dest; + return [list $result $output]; + } + remote_reboot $dest; + } + return [list "fail" ""]; +} + +set_board_info protocol "vxworks" +# -lm under vxworks isn't needed. +set_board_info mathlib "" +set_board_info shell_prompt "->" +set_board_info needs_status_wrapper 1 +# FTP doesn't work in passive mode to this board. +set_board_info ftp_no_passive 1 +# Wait 15 seconds after powercycling. +set_board_info reboot_delay 15 + +# We don't have sys/unistd.h. +set_board_info wrap_compile_flags "-DNO_UNISTD_H" + +set_board_info gdb_prompt "\[(\]vxgdb\[)\]" + +set_board_info is_vxworks 1; +set_board_info gdb,nosignals 1; |