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:
20 # This file was written by Ian Lance Taylor <ian@cygnus.com>.
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 "Load new symbol table.*y or n. $" {
77 -re "Reading symbols from.*done..*$prompt $" {}
78 -re "$prompt $" { perror "GDB couldn't read file" }
79 timeout { perror "(timeout) read symbol file" ; return -1 }
82 send "target sparclite $targetname\n"
84 verbose "Timeout is now $timeout seconds" 2
86 -re ".*SPARClite appears to be alive.*$prompt $" {
88 send_user "Set target to $targetname\n"
92 perror "Couldn't set SLITE target."
94 verbose "Timeout is now $timeout seconds" 2
101 send_user "Loading $arg into $GDB\n"
104 verbose "Timeout is now $timeout seconds" 2
106 -re "Loading.*$prompt $" {
108 send_user "Loaded $arg into $GDB\n"
111 verbose "Timeout is now $timeout seconds" 2
115 perror "GDB couldn't load."
120 perror "Timed out trying to load $arg."
125 verbose "Timeout is now $timeout seconds" 2
127 send "target remote $targetname\n"
129 verbose "Timeout is now $timeout seconds" 2
133 send_user "Set remote target to $targetname\n"
137 perror "Couldn't set remote target."
139 verbose "Timeout is now $timeout seconds" 2
144 if [info exists expect_out(buffer)] then {
145 send_log $expect_out(buffer)
151 # gdb_start -- start GDB running.
165 # reboot the board to get a clean start
167 if ![info exists connectmode] then {
168 set connectmode "kermit"
170 if ![info exists baud] then {
173 set shell_id [ eval $connectmode "$targetname" ]
174 send -i $shell_id "\n"
176 -i $shell_id -re ">$" { }
178 send -i $shell_id "\CC"
180 -i $shell_id -re ">$" { }
182 perror "(timeout) board did not come up."; return -1
187 send -i $shell_id "go 0xbfc00000\n"
189 -i $shell_id -re ">$" { }
190 timeout { perror "(timeout) board did not come up."; return -1 }
192 verbose "about to exit kermit"
193 exit_remote_shell $shell_id
198 if [ llength $GDBFLAGS ] then {
204 -re ".*\r\n$prompt $" {
205 verbose "GDB initialized."
208 perror "GDB never initialized."
212 perror "(timeout) GDB never initialized."
217 # force the height to "unlimited", so no pagers get used
218 send "set height 0\n"
219 expect -re ".*$prompt $" {}
220 # force the width to "unlimited", so no wraparound occurs
222 expect -re ".*$prompt $" {}
224 # Don't use floating point instructions, in case the board doesn't
226 # send "set mipsfpu off\n"
227 # expect -re ".*$prompt $" {}
229 # if $verbose>1 then {
230 # send_user "Setting up target, please wait...\n"
232 # send "target mips $targetname\n"
234 # verbose "Timeout is now $timeout seconds" 2
236 # -re "Remote MIPS debugging.*$prompt $" {
237 # if $verbose>1 then {
238 # send_user "Set target to $targetname\n"
242 # perror "Couldn't set MIPS target."
244 # verbose "Timeout is now $timeout seconds" 2
249 verbose "Timeout is now $timeout seconds" 2
253 "<return>" { send "\n"; perror "Window too small." }
254 -re "\(y or n\) " { send "n\n"; perror "Got interactive prompt." }
255 full_buffer { perror "internal buffer is full." }
256 eof { perror "eof -- pty is hosed." }
257 timeout { perror "timeout." }
258 "virtual memory exhausted" { perror "virtual memory exhausted." }
259 "Undefined command" { perror "send string probably wrong." }
263 catch default_gdb_exit
268 # make sure gdb has actually started, otherwise if the first test
269 # timesout, DejaGnu crashes