1 # Copyright (C) 1996, 1997 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 Michael Snyder <msnyder@cygnus.com>.
22 # GDB support routines for a board using the sparclet remote debugging
27 set gdb_prompt "\\(gdbslet\\)"
31 # Sparclet remote run command.
33 # This requires that we beep the user and ask him to push the board reset!
34 # Then we will switch to the monitor target, run the program, use 2 ^C's
35 # to interrupt the monitor target, and switch back to the remote target.
36 # Then we have to do a continue to get past the stub breakpoint.
43 if { [default_gdb_start] != 0 } {
47 if [target_info exists baud] {
48 send_gdb "set remotebaud [target_info baud]\n"
50 -re ".*$gdb_prompt" { }
52 perror "Error setting baud rate."
58 for {set x 1;} { $x < 4 } {incr x} {
59 if { [gdb_sparclet_startup] > 0 } {
67 proc gdb_sparclet_startup { } {
72 set is_running_stub 0;
74 send_gdb "target sparclet [target_info serial]\n";
76 -re ".*already.*y or n." {
80 -re "Remote target.*connected to.*$gdb_prompt" { }
82 verbose "timed out, checking if stub is already running"
89 perror "sparclet board isn't responding";
93 send_gdb "target remote [target_info gdb_serial]\n";
95 -re ".*Remote debugging.*$gdb_prompt" {
96 verbose "stub is already running"
97 set is_running_stub 1;
100 perror "sparclet board isn't responding";
107 if { $is_running_stub == 0 } {
110 if ![file exists loader] {
111 set result [target_compile "${srcdir}/config/sparclet-loader.c" "loader" executable "libs=-Wl,-Ttext,[target_info gdb_stub_offset]"];
114 send_gdb "file $loader\n";
116 -re "A program is being debug.*Kill it.*y or n. $" {
120 -re "Load new symbol table.*y or n. $" {
124 -re "Reading symbols from.*done..*$gdb_prompt $" {}
125 -re "$gdb_prompt $" { perror "GDB couldn't find loader" }
127 perror "(timeout) read symbol file" ;
132 send_gdb "target [target_info gdb_protocol] [target_info serial]\n";
134 -re "Remote target.*connected to.*$gdb_prompt" { }
136 perror "Error reconnecting to sparclet.";
141 send_gdb "load $loader [target_info gdb_stub_offset]\n"
142 verbose "Loading $loader into $GDB" 2
144 verbose "Timeout is now $timeout seconds" 2
146 -re "Loading.*$gdb_prompt $" {
147 verbose "Loaded $loader into $GDB" 1
149 verbose "Timeout is now $timeout seconds" 2
151 -re "$gdb_prompt $" {
153 perror "GDB couldn't load."
158 perror "Timed out trying to load $arg."
165 -re "A program is being debug.*Kill it.*y or n. $" {
169 -re "The program being debugged .*y or n. $" {
173 -re ".*Starting program:.*loader.*$" {
174 verbose "Starting loader succeeded"
177 perror "(timeout) starting the loader" ;
181 perror "error starting the loader";
190 -re ".*Give up .and stop debugging it.*$" {
194 -re ".*$gdb_prompt $" {
195 verbose "Running loader succeeded"
198 perror "(timeout) interrupting the loader" ;
202 perror "error interrupting the loader";
212 proc gdb_run_cmd { args } {
216 send_gdb "set \$fp=0\n";
218 -re ".*$gdb_prompt" { }
220 send_gdb "jump start\n";
225 -re "Continuing at.*\[\r\n\]" { }
235 # gdb_load -- load a file into the GDB.
236 # Returns a 0 if there was an error,
237 # 1 if it load successfully.
239 proc gdb_load { arg } {
247 set loadfile [file tail $arg]
248 set loadpath [file dirname $arg]
250 if [target_info exists gdb_protocol] {
251 set protocol [target_info gdb_protocol];
253 set protocol "sparclet"
256 send_gdb "file $arg\n"
258 -re "A program is being debug.*Kill it.*y or n. $" {
262 -re "Load new symbol table.*y or n. $" {
266 -re "Reading symbols from.*done..*$gdb_prompt $" {}
267 -re "$gdb_prompt $" { perror "GDB couldn't read file" }
269 perror "(timeout) read symbol file" ;
274 if [target_info exists gdb_serial] {
275 send_gdb "target remote [target_info gdb_serial]\n"
277 -re ".*Kill it?.*y or n.*" {
281 -re ".*$gdb_prompt $" {
282 verbose "Set remote target to [target_info serial]" 2
286 verbose "Timeout is now $timeout seconds" 2
287 perror "Couldn't set remote target."
292 if [target_info exists gdb_load_offset] {
293 set offset "[target_info gdb_load_offset]";
297 send_gdb "load $arg $offset\n"
298 verbose "Loading $arg into $GDB" 2
300 verbose "Timeout is now $timeout seconds" 2
302 -re "Loading.*$gdb_prompt $" {
303 verbose "Loaded $arg into $GDB" 1
305 verbose "Timeout is now $timeout seconds" 2
307 -re "$gdb_prompt $" {
309 perror "GDB couldn't load."
314 perror "Timed out trying to load $arg."
318 send_gdb "list main\n";
320 -re ".*$gdb_prompt" { }
322 perror "command for list main never completed";