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 # This file was written by Ian Lance Taylor <ian@cygnus.com>.
19 # GDB support routines for a board using the MIPS remote debugging
20 # protocol. These are actually pretty generic.
22 # DejaGnu currently assumes that debugging is being done over the main
23 # console port. It would probably be more convenient for people using
24 # IDT boards to permit the debugging port and the connected port to be
25 # different, since an IDT board has two ports. This would require
26 # extending some of the tests in a fashion similar to that done for
27 # VxWorks, because the test output would appear on the other port,
28 # rather than being displayed by gdb.
32 set gdb_prompt "\\(gdb\\)"
35 # gdb_load -- load a file into the GDB.
36 # Returns a 0 if there was an error,
37 # 1 if it load successfully.
39 proc gdb_load { arg } {
47 set loadfile [file tail $arg]
48 set loadpath [file dirname $arg]
52 if [target_info exists gdb_protocol] {
53 set protocol [target_info gdb_protocol];
55 set protocol "sparclite"
58 if [target_info exists serial] {
59 set targetname [target_info serial];
60 set command "target $protocol [target_info serial]\n";
62 if ![target_info exists netport] {
63 perror "Need either netport or gdb_serial entry for [target_info name].";
66 set targetname [target_info netport];
67 set command "target $protocol udp [target_info netport]\n";
70 verbose "Timeout is now $timeout seconds" 2
74 -re "Unknown response.*resetting the board.|remote timeout" {
76 if { $try_count > 3 } {
85 -re "Remote target.*$gdb_prompt $" { }
86 -re ".*SPARClite appears to be alive.*$gdb_prompt $" {
88 send_user "Set target to $targetname\n"
92 perror "Couldn't set SLITE target."
94 verbose "Timeout is now $timeout seconds" 2
99 if [target_info exists gdb_load_offset] {
100 set offset "[target_info gdb_load_offset]";
105 if [is_remote host] {
106 set arg [remote_download host $arg];
108 error "download failed"
112 send_gdb "load $arg $offset\n"
113 verbose "Loading $arg into $GDB" 2
115 verbose "Timeout is now $timeout seconds" 2
117 -re "Loading.*$gdb_prompt $" {
118 verbose "Loaded $arg into $GDB" 1
120 verbose "Timeout is now $timeout seconds" 2
122 -re "$gdb_prompt $" {
124 perror "GDB couldn't load."
129 perror "Timed out trying to load $arg."
134 # Some SPARClite boards automagically do a run after the program is
136 if [target_info exists need_monitor_run] {
138 verbose "Timeout is now $timeout seconds, doing monitor run" 2
139 send_gdb "monitor run\n";
143 -re ".*$gdb_prompt $" { verbose "Run command succeded" }
145 perror "error sending monitor run command";
152 if [target_info exists gdb_serial] {
153 set serial [target_info gdb_serial];
155 set serial [target_info serial];
157 send_gdb "target remote $serial\n"
159 verbose "Timeout is now $timeout seconds" 2
161 -re ".*Kill it?.*y or n.*" {
165 -re ".*$gdb_prompt $" {
166 verbose "Set remote target to [target_info serial]" 2
169 perror "Couldn't set remote target."
171 verbose "Timeout is now $timeout seconds" 2
176 if [info exists expect_out(buffer)] then {
177 send_log $expect_out(buffer)