1 # Copyright (C) 1988, 1990, 1991, 1992 Free Software Foundation, Inc.
3 # This program is free software; you can redistribute it and/or modify
4 # it under the terms of the GNU General Public License as published by
5 # the Free Software Foundation; either version 2 of the License, or
6 # (at your option) any later version.
8 # This program is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 # GNU General Public License for more details.
13 # You should have received a copy of the GNU General Public License
14 # along with this program; if not, write to the Free Software
15 # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
17 # Please email any bugs, comments, and/or additions to this file to:
18 # bug-dejagnu@prep.ai.mit.edu
20 # This file was written by Rob Savoye. (rob@cygnus.com)
22 # variables that need to set up
24 if ![info exists prompt] then {
27 # some convenience abbreviations
29 if ![info exists hex] then {
30 set hex "0x\[0-9A-Fa-f\]+"
32 if ![info exists decimal] then {
33 set decimal "\[0-9\]+"
37 # gdb_version -- extract and print the version number of gcc
42 if {[which $GDB] != 0} then {
43 set tmp [exec echo "q" | $GDB]
44 set version [lindex $tmp [lsearch $tmp "\[0-9\]*"]]
45 set version [string range $version 0 [expr [string length $version]-2]]
46 clone_output "[which $GDB] version $version $GDBFLAGS\n"
48 warning "$GDB does not exist"
53 # gdb_unload -- unload a file if one is loaded
62 -re "No exec file now\.\r" { continue -expect }
63 -re "No symbol file now\.\r" { continue -expect }
64 -re "A program is being debugged already..*Kill it\? \(y or n\) $"\
67 send_user "\t\tKilling previous program being debugged\n"
71 -re "Discard symbol table from .*\? \(y or n\) $" {
77 error "Couldn't unload file in $GDB (timed out)."
84 # gdb_load -- load a file into the debugger.
85 # return a -1 if anything goes wrong.
87 proc gdb_load { arg } {
94 set loadfile [file tail $arg]
95 set loadpath [file dirname $arg]
98 -re "Reading symbols from.*done.*$prompt $" {
100 send_user "\t\tLoaded $arg into the $GDB\n"
103 -re "has no symbol-table.*$prompt $" {
104 error "$arg wasn't compiled with \"-g\""
107 -re "A program is being debugged already..*Kill it\? \(y or n\) $" {
110 send_user "\t\tKilling previous program being debugged\n"
114 -re "Load new symbol table from.*\? \(y or n\) $" {
117 -re "Reading symbols from.*done.*$prompt $" {
119 send_user "\t\tLoaded $arg with new symbol table into $GDB\n"
124 error "(timeout) Couldn't load $arg, other program already loaded."
129 -re ".*No such file or directory.*$prompt $" {
130 error "($arg) No such file or directory\n"
134 error "couldn't load $arg into $GDB."
138 error "couldn't load $arg into $GDB (timed out)."
145 # gdb_exit -- kills the gdb process currently running
154 send_user "Quitting $GDB $GDBFLAGS\n"
156 catch "send \"quit\n\"" result
157 if [string match "write\(spawn_id=\[0-9\]+\):" $result] then {
165 send_user "Got EOF from $GDB\n"
170 send_user "Got TIMEOUT from $GDB\n"
174 -re "The program is running. Quit anyway? (y or n) $" {
177 send_user "\t\tKilling program being debugged\n"
186 send_user "Quitting $GDB $GDBFLAGS\n"
191 # start gdb -- start gdb running
202 send_user "Spawning $GDB $GDBFLAGS\n"
205 set oldtimeout $timeout
206 set timeout [expr "$timeout + 60"]
207 if [ llength $GDBFLAGS ] then {
208 if {[which $GDB] != 0} then {
211 error "$GDB does not exist."
215 IF {[WHICH $GDB] != 0} then {
218 error "$GDB does not exist."
225 send_user "GDB initialized for native mode\n"
229 error "GDB never initialized."
233 error "(timeout) GDB never initialized."
237 set timeout $oldtimeout
238 # force the height to "unlimited", so no pagers get used
239 send "set height 0\n"
243 send_user "Seting height to 0.\n"
247 warning "Couldn't set the height to 0."
250 # force the width to "unlimited", so no wraparound occurs
255 send_user "Seting width to 0.\n"
259 warning "Couldn't set the width to 0."
264 # These only need to be uncommented for debugging test cases. They exist
265 # mainly to catch programming errors
267 # "<return>" { send "\n"; error "Window too small." }
268 # -re "\(y or n\) " { send "n\n"; error "Got interactive prompt." }
269 # buffer_full { error "internal buffer is full." }
270 # eof { error "eof -- there is no child process" ; alldone}
271 # timeout { error "timeout." }
272 # "virtual memory exhausted" { error "virtual memory exhausted." }
273 # "Undefined command" { error "send string probably wrong." }
278 set binpath /s1/users/rob/vxworks/bin/somewhere-bogus-that-needs-configuring