1 # Test Framework Driver
2 # Copyright (C) 1988, 1990, 1991, 1992 Free Software Foundation, Inc.
4 # This program is free software; you can redistribute it and/or modify
5 # it under the terms of the GNU General Public License as published by
6 # the Free Software Foundation; either version 2 of the License, or
7 # (at your option) any later version.
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
14 # You should have received a copy of the GNU General Public License
15 # along with this program; if not, write to the Free Software
16 # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
18 # Please email any bugs, comments, and/or additions to this file to:
21 # This file was written by Rob Savoye. (rob@cygnus.com)
24 # NOTE: these test assume that there is a udi_soc file in th
27 # these need to be initialized only if site.exp doesn't set them
30 if ![info exists prompt] then {
35 # gdb_version -- extract and print the version number of gdb
41 set tmp [exec echo "q" | $GDB]
42 set version [lindex $tmp [lsearch $tmp "\[0-9\]*"]]
43 set version [string range $version 0 [expr [string length $version]-2]]
44 clone_output "[which $GDB] version $version $GDBFLAGS\n"
48 # gdb_load -- load a file into the GDB.
49 # Returns a 0 if there was an error,
50 # 1 if it load successfully.
52 proc gdb_load { arg } {
63 send_user "Loading $arg into $GDB\n"
66 -re "Loading.*\.text.*\.data.*\.bss.*Reading symbols from $arg.+done.*$prompt $" {
68 send_user "Loaded $arg into $GDB\n"
74 error "GDB couldn't load."
79 error "Timed out trying to load $arg."
83 if [info exists expect_out(buffer)] then {
84 send_log $expect_out(buffer)
90 # gdb_exit -- exit the GDB
102 send_user "Got EOF from $GDB\n"
107 send_user "Got TIMEOUT from $GDB\n"
110 -re "The program is running. Quit anyway? (y or n) $"\
113 send_user "\t\tKilling program being debugged\n"
118 send_user "Quitting $GDB $GDBFLAGS\n"
124 # gdb_start -- start GDB running. This assumes that there the
125 # UDICONF enviroment variable is set.
137 if [ llength $GDBFLAGS ] then {
143 -re "GDB.*$prompt $" {
145 send_user "$GDB initialized for cross mode\n\n"
148 -re "$prompt $" { error "GDB never initialized."; alldone }
149 timeout { error "(timeout) GDB never initialized.";
153 # force the height to "unlimited", so no pagers get used
154 send "set height 0\n"
155 expect -re ".*$prompt $" {}
156 # force the width to "unlimited", so no wraparound occurs
158 expect -re ".*$prompt $" {}
159 # set the default arguments to "main", so that "run" with no
160 # arguments will work correctly.
161 send "set args main\n"
162 expect -re ".*$prompt $" {}
165 send_user "Setting up target, Please wait...\n"
167 catch "exec rm [glob -nocomplain *_soc]"
168 catch "exec rm [glob -nocomplain /tmp/*_soc]"
169 # set targets hostname
170 send "target udi $targetname\n"
173 -re "target udi.*TIP UDI 1.2 Conformant.*$prompt $" {
175 send_user "Set target to $targetname\n"
179 error "Couldn't set target for vxworks."
188 "<return>" { send "\n"; clone_output "ERROR: Window too small." }
189 -re "\(y or n\) " { send "n\n"; error "Got interactive prompt." }
190 buffer_full { error "internal buffer is full." }
191 eof { error "eof -- pty is hosed." }
192 timeout { error "timeout." }
193 "virtual memory exhausted" { error "virtual memory exhausted." }
194 "Undefined command" { error "send string probably wrong." }
201 # make sure gdb has actually started, otherwise if the first test
202 # timesout, DejaGnu crashes