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.
81 # return a -1 if anything goes wrong.
83 proc gdb_load { arg } {
90 set loadfile [file tail $arg]
91 set loadpath [file dirname $arg]
94 -re "Reading symbols from.*done.*$prompt $"\
95 { if $verbose>1 then {
96 send_user "\t\tLoaded $arg into the $GDB\n"
99 -re "has no symbol-table.*$prompt $" {
100 error "$arg wasn't compiled with \"-g\"\n"
103 -re "A program is being debugged already..*Kill it\? \(y or n\) $"\
106 send_user "\t\tKilling previous program being debugged\n"
110 -re "Load new symbol table from.*\? \(y or n\) $"\
113 -re "Reading symbols from.*done.*$prompt $"
114 { if $verbose>1 then {
115 send_user "\t\tLoaded $arg with new symbol table into $GDB\n"
118 timeout { error "(timeout) Couldn't load $arg, other program already loaded."; return -1 }
121 -re ".*No such file or directory.*$prompt $"\
122 { error "($arg) No such file or directory\n"; return -1 }
123 -re "$prompt $" { error "couldn't load $arg into $GDB."; return -1 }
124 timeout { error "couldn't load $arg into $GDB (timed out)."; return -1 }
129 # gdb_exit -- kills the gdb process currently running
138 send_user "Quitting $GDB $GDBFLAGS\n"
140 catch "send \"quit\n\"" result
141 if [string match "write\(spawn_id=\[0-9\]+\): Bad file number" $result] then {
148 send_user "Got EOF from $GDB\n"
153 send_user "Got TIMEOUT from $GDB\n"
157 -re "The program is running. Quit anyway? (y or n) $"\
160 send_user "\t\tKilling program being debugged\n"
168 send_user "Quitting $GDB $GDBFLAGS\n"
173 # start gdb -- start gdb running
184 send_user "Spawning $GDB $GDBFLAGS\n"
187 set oldtimeout $timeout
188 set timeout [expr "$timeout + 60"]
189 if [ llength $GDBFLAGS ] then {
195 -re ".*$prompt $" { if $verbose>1 then {
196 send_user "GDB initialized for native mode\n" }
198 -re "$prompt $" { error "GDB never initialized."; return -1 }
199 timeout { error "(timeout) GDB never initialized."; return -1 }
201 set timeout $oldtimeout
202 # force the height to "unlimited", so no pagers get used
203 send "set height 0\n"
204 expect -re ".*$prompt $" {}
205 # force the width to "unlimited", so no wraparound occurs
207 expect -re ".*$prompt $" {}
211 "<return>" { send "\n"; error "Window too small." }
212 -re "\(y or n\) " { send "n\n"; error "Got interactive prompt." }
213 buffer_full { error "internal buffer is full." }
214 eof { error "eof -- pty is hosed." }
215 timeout { error "timeout." }
216 "virtual memory exhausted" { error "virtual memory exhausted." }
217 "Undefined command" { error "send string probably wrong." }
222 set binpath /s1/users/rob/vxworks/bin/somewhere-bogus-that-needs-configuring