1 # Copyright 1993, 1997, 1998 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.
35 set gdb_prompt "\\(gdb\\)"
38 # gdb_load -- load a file into the GDB.
39 # Returns a 0 if there was an error,
40 # 1 if it load successfully.
42 proc gdb_load { arg } {
50 set loadfile [file tail $arg]
51 set loadpath [file dirname $arg]
55 if [target_info exists gdb_protocol] {
56 set protocol [target_info gdb_protocol];
58 set protocol "sparclite"
61 if [target_info exists serial] {
62 set targetname [target_info serial];
63 set command "target $protocol [target_info serial]\n";
65 if ![target_info exists netport] {
66 perror "Need either netport or gdb_serial entry for [target_info name].";
69 set targetname [target_info netport];
70 set command "target $protocol udp [target_info netport]\n";
73 verbose "Timeout is now $timeout seconds" 2
77 -re "Unknown response.*resetting the board.|remote timeout" {
79 if { $try_count > 3 } {
88 -re "Remote target.*$gdb_prompt $" { }
89 -re ".*SPARClite appears to be alive.*$gdb_prompt $" {
91 send_user "Set target to $targetname\n"
95 perror "Couldn't set SLITE target."
97 verbose "Timeout is now $timeout seconds" 2
102 if [target_info exists gdb_load_offset] {
103 set offset "[target_info gdb_load_offset]";
108 if [is_remote host] {
109 set arg [remote_download host $arg];
111 error "download failed"
115 send_gdb "load $arg $offset\n"
116 verbose "Loading $arg into $GDB" 2
118 verbose "Timeout is now $timeout seconds" 2
120 -re "Loading.*$gdb_prompt $" {
121 verbose "Loaded $arg into $GDB" 1
123 verbose "Timeout is now $timeout seconds" 2
125 -re "$gdb_prompt $" {
127 perror "GDB couldn't load."
132 perror "Timed out trying to load $arg."
137 # Some SPARClite boards automagically do a run after the program is
139 if [target_info exists need_monitor_run] {
141 verbose "Timeout is now $timeout seconds, doing monitor run" 2
142 send_gdb "monitor run\n";
146 -re ".*$gdb_prompt $" { verbose "Run command succeded" }
148 perror "error sending monitor run command";
155 if [target_info exists gdb_serial] {
156 set serial [target_info gdb_serial];
158 set serial [target_info serial];
160 send_gdb "target remote $serial\n"
162 verbose "Timeout is now $timeout seconds" 2
164 -re ".*Kill it?.*y or n.*" {
168 -re ".*$gdb_prompt $" {
169 verbose "Set remote target to [target_info serial]" 2
172 perror "Couldn't set remote target."
174 verbose "Timeout is now $timeout seconds" 2
179 if [info exists expect_out(buffer)] then {
180 send_log $expect_out(buffer)