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-gdb@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"
104 -re "has no symbol-table.*$prompt $" {
105 error "$arg wasn't compiled with \"-g\""
108 -re "A program is being debugged already..*Kill it\? \(y or n\) $" {
111 send_user "\t\tKilling previous program being debugged\n"
115 -re "Load new symbol table from.*\? \(y or n\) $" {
118 -re "Reading symbols from.*done.*$prompt $" {
120 send_user "\t\tLoaded $arg with new symbol table into $GDB\n"
125 error "(timeout) Couldn't load $arg, other program already loaded."
130 -re ".*No such file or directory.*$prompt $" {
131 error "($arg) No such file or directory\n"
135 error "couldn't load $arg into $GDB."
139 error "couldn't load $arg into $GDB (timed out)."
143 # This is an attempt to detect a core dump, but seems not to
144 # work. Perhaps we need to match .* followed by eof, in which
145 # expect does not seem to have a way to do that.
146 error "couldn't load $arg into $GDB (end of file)."
153 # start gdb -- start gdb running
164 send_user "Spawning $GDB $GDBFLAGS\n"
167 set oldtimeout $timeout
168 set timeout [expr "$timeout + 60"]
169 if [ llength $GDBFLAGS ] then {
170 if {[which $GDB] != 0} then {
173 error "$GDB does not exist."
177 IF {[WHICH $GDB] != 0} then {
180 error "$GDB does not exist."
187 send_user "GDB initialized for native mode\n"
191 error "GDB never initialized."
195 error "(timeout) GDB never initialized."
199 set timeout $oldtimeout
200 # force the height to "unlimited", so no pagers get used
201 send "set height 0\n"
205 send_user "Seting height to 0.\n"
209 warning "Couldn't set the height to 0."
212 # force the width to "unlimited", so no wraparound occurs
217 send_user "Seting width to 0.\n"
221 warning "Couldn't set the width to 0."
226 # These only need to be uncommented for debugging test cases. They exist
227 # mainly to catch programming errors
229 # "<return>" { send "\n"; error "Window too small." }
230 # -re "\(y or n\) " { send "n\n"; error "Got interactive prompt." }
231 # buffer_full { error "internal buffer is full." }
232 # eof { error "eof -- there is no child process" ; cleanup ; exit $exit_status}
233 # timeout { error "timeout." }
234 # "virtual memory exhausted" { error "virtual memory exhausted." }
235 # "Undefined command" { error "send string probably wrong." }
240 set binpath /s1/users/rob/vxworks/bin/somewhere-bogus-that-needs-configuring