1 # Copyright (C) 1993 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
17 # Please email any bugs, comments, and/or additions to this file to:
22 # GDB support routines for a board using the MIPS remote debugging
23 # protocol. These are actually pretty generic.
25 # DejaGnu currently assumes that debugging is being done over the main
26 # console port. It would probably be more convenient for people using
27 # IDT boards to permit the debugging port and the connected port to be
28 # different, since an IDT board has two ports. This would require
29 # extending some of the tests in a fashion similar to that done for
30 # VxWorks, because the test output would appear on the other port,
31 # rather than being displayed by gdb.
37 # gdb_version -- extract and print the version number of gdb
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"
50 # gdb_load -- load a file into the GDB.
51 # Returns a 0 if there was an error,
52 # 1 if it load successfully.
54 proc gdb_load { arg } {
64 set loadfile [file tail $arg]
65 set loadpath [file dirname $arg]
69 -re "A program is being debugged already..*Kill it.*y or n. $" {
73 -re "Reading symbols from.*done..*$prompt $" {}
74 -re "$prompt $" { perror "GDB couldn't read file" }
75 timeout { perror "(timeout) read symbol file" ; return -1 }
78 send "target mips $targetname\n"
80 verbose "Timeout is now $timeout seconds" 2
82 -re "Remote MIPS debugging.*$prompt $" {
84 send_user "Set target to $targetname\n"
88 perror "Couldn't set MIPS target."
90 verbose "Timeout is now $timeout seconds" 2
97 send_user "Loading $arg into $GDB\n"
100 verbose "Timeout is now $timeout seconds" 2
102 -re "Loading.*$prompt $" {
104 send_user "Loaded $arg into $GDB\n"
107 verbose "Timeout is now $timeout seconds" 2
111 perror "GDB couldn't load."
116 perror "Timed out trying to load $arg."
121 verbose "Timeout is now $timeout seconds" 2
122 if [info exists expect_out(buffer)] then {
123 send_log $expect_out(buffer)
129 # gdb_start -- start GDB running.
143 # reboot the board to get a clean start
145 if ![info exists connectmode] then {
146 set connectmode "kermit"
148 if ![info exists baud] then {
151 set shell_id [ eval $connectmode "$targetname" ]
152 send -i $shell_id "\n"
154 -i $shell_id -re "<IDT>$" { }
156 send -i $shell_id "\CC"
158 -i $shell_id -re "<IDT>$" { }
160 perror "(timeout) board did not come up."; return -1
165 send -i $shell_id "go 0xbfc00000\n"
167 -i $shell_id -re "<IDT>$" { }
168 timeout { perror "(timeout) board did not come up."; return -1 }
170 verbose "about to exit kermit"
171 exit_remote_shell $shell_id
176 if [ llength $GDBFLAGS ] then {
182 -re ".*\r\n$prompt $" {
183 verbose "GDB initialized."
186 perror "GDB never initialized."
190 perror "(timeout) GDB never initialized."
195 # force the height to "unlimited", so no pagers get used
196 send "set height 0\n"
197 expect -re ".*$prompt $" {}
198 # force the width to "unlimited", so no wraparound occurs
200 expect -re ".*$prompt $" {}
202 # Don't use floating point instructions, in case the board doesn't
204 send "set mipsfpu off\n"
205 expect -re ".*$prompt $" {}
207 # if $verbose>1 then {
208 # send_user "Setting up target, please wait...\n"
210 # send "target mips $targetname\n"
212 # verbose "Timeout is now $timeout seconds" 2
214 # -re "Remote MIPS debugging.*$prompt $" {
215 # if $verbose>1 then {
216 # send_user "Set target to $targetname\n"
220 # perror "Couldn't set MIPS target."
222 # verbose "Timeout is now $timeout seconds" 2
227 verbose "Timeout is now $timeout seconds" 2
231 "<return>" { send "\n"; perror "Window too small." }
232 -re "\(y or n\) " { send "n\n"; perror "Got interactive prompt." }
233 buffer_full { perror "internal buffer is full." }
234 eof { perror "eof -- pty is hosed." }
235 timeout { perror "timeout." }
236 "virtual memory exhausted" { perror "virtual memory exhausted." }
237 "Undefined command" { perror "send string probably wrong." }
241 catch default_gdb_exit
246 # make sure gdb has actually started, otherwise if the first test
247 # timesout, DejaGnu crashes