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:
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 set tmp [exec echo "q" | $GDB]
43 set version [lindex $tmp [lsearch $tmp "\[0-9\]*"]]
44 set version [string range $version 0 [expr [string length $version]-2]]
45 clone_output "[which $GDB] version $version $GDBFLAGS\n"
49 # gdb_unload -- unload a file if one is loaded
58 -re "No exec file now\.\r" { continue -expect }
59 -re "No symbol file now\.\r" { continue -expect }
60 -re "A program is being debugged already..*Kill it\? \(y or n\) $"\
63 send_user "\t\tKilling previous program being debugged\n"
67 -re "Discard symbol table from .*\? \(y or n\) $" {
73 error "Couldn't unload file in $GDB (timed out)."
80 # gdb_load -- load a file into the debugger.
82 proc gdb_load { arg } {
89 set loadfile [file tail $arg]
90 set loadpath [file dirname $arg]
93 -re "Reinitialize source path to empty\? \(y or n\) $"\
97 timeout { fail "(timeout) reset directory path" ; return }
100 timeout { fail "(timeout) reset directory path" ; return }
102 send "directory $loadpath\n"
103 expect -re "$prompt $" {}
106 -re "Reading symbols from.*done.*$prompt $"\
107 { if $verbose>1 then {
108 send_user "\t\tLoaded $arg into the $GDB\n"
111 -re "has no symbol-table.*$prompt $" {
112 error "$arg wasn't compiled with \"-g\"\n"
115 -re "A program is being debugged already..*Kill it\? \(y or n\) $"\
118 send_user "\t\tKilling previous program being debugged\n"
122 -re "Load new symbol table from.*\? \(y or n\) $"\
125 -re "Reading symbols from.*done.*$prompt $"
126 { if $verbose>1 then {
127 send_user "\t\tLoaded $arg with new symbol table into $GDB\n"
130 timeout { error "(timeout) Couldn't load $arg, other program already loaded."; alldone }
133 -re ".*No such file or directory.*$prompt $"\
134 { error "($arg) No such file or directory\n"; alldone }
135 -re "$prompt $" { error "couldn't load $arg into $GDB."; alldone }
136 timeout { error "couldn't load $arg into $GDB (timed out)."; alldone }
141 # gdb_exit -- kills the gdb process currently running
149 catch "send \"quit\n\"" result
150 if [string match "write\(spawn_id=\[0-9\]+\): Bad file number" $result] then {
157 send_user "Got EOF from $GDB\n"
162 send_user "Got TIMEOUT from $GDB\n"
165 -re "The program is running. Quit anyway? (y or n) $"\
168 send_user "\t\tKilling program being debugged\n"
176 send_user "Quitting $GDB $GDBFLAGS\n"
181 # start gdb -- start gdb running
192 send_user "Spawning $GDB $GDBFLAGS\n"
195 set oldtimeout $timeout
196 set timeout [expr "$timeout + 60"]
197 if [ llength $GDBFLAGS ] then {
203 -re ".*$prompt $" { if $verbose>1 then {
204 send_user "GDB initialized for native mode\n" }
206 -re "$prompt $" { error "GDB never initialized."; alldone }
207 timeout { error "(timeout) GDB never initialized."; alldone }
209 set timeout $oldtimeout
210 # force the height to "unlimited", so no pagers get used
211 send "set height 0\n"
212 expect -re ".*$prompt $" {}
213 # force the width to "unlimited", so no wraparound occurs
215 expect -re ".*$prompt $" {}
219 "<return>" { send "\n"; error "Window too small." }
220 -re "\(y or n\) " { send "n\n"; error "Got interactive prompt." }
221 buffer_full { error "internal buffer is full." }
222 eof { error "eof -- pty is hosed." }
223 timeout { error "timeout." }
224 "virtual memory exhausted" { error "virtual memory exhausted." }
225 "Undefined command" { error "send string probably wrong." }
230 set binpath /s1/users/rob/vxworks/bin/somewhere-bogus-that-needs-configuring