1 # Copyright (C) 1996 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 Mitsubishi M32R remote debugging
30 # M32R remote run command.
32 # This requires that we beep the user and ask him to push the board reset!
33 # Then we will switch to the monitor target, run the program, use 2 ^C's
34 # to interrupt the monitor target, and switch back to the remote target.
35 # Then we have to do a continue to get past the stub breakpoint.
43 verbose "Timeout is now $timeout seconds, starting remote stub" 2
44 send_user "
\aPlease reset the board now...
\a\n"
52 # go back to monitor, run the program, interrupt it, and start remote.
54 if [target_info exists gdb_protocol] {
55 set protocol [target_info gdb_protocol];
57 set protocol "sparclet"
59 if [target_info exists serial] {
60 set targetname [target_info serial];
61 send_gdb "target $protocol [target_info serial]\n";
63 if ![target_info exists netport] {
64 perror "Need either netport or gdb_serial entry for [target_info name].";
67 set targetname [target_info netport];
68 send_gdb "target $protocol udp [target_info netport]\n";
72 -i $gdb_spawn_id -re "A program is being debug.*Kill it.*y or n. $" {
76 -i $gdb_spawn_id -re "Remote target.*$prompt $" { }
77 -i $gdb_spawn_id -re ".*SPARCLET appears to be alive.*$prompt $" {
79 send_user "Set target to $targetname\n"
82 -i $gdb_spawn_id timeout {
84 verbose "Timeout is now $timeout seconds" 2
85 perror "Couldn't set M32R target."
92 -i $gdb_spawn_id -re ".*$prompt $" {
93 verbose "Breakpoints disabled" 2
95 -i $gdb_spawn_id timeout {
96 perror "(timeout) disabling breakpoints";
99 -i $gdb_spawn_id default {
100 perror "error disabling breakpoints";
105 -i $gdb_spawn_id -re "A program is being debug.*Kill it.*y or n. $" {
109 -i $gdb_spawn_id -re "The program being debugged .*y or n. $" {
113 -i $gdb_spawn_id -re ".*Starting program:.*$" {
114 verbose "Starting remote stub succeeded"
116 -i $gdb_spawn_id timeout {
117 perror "(timeout) starting the remote stub" ;
120 -i $gdb_spawn_id default {
121 perror "error starting the remote stub";
130 -i $gdb_spawn_id -re ".*Give up .and stop debugging it.*$" {
134 -i $gdb_spawn_id -re ".*$prompt $" {
135 verbose "interrupting remote stub succeeded"
137 -i $gdb_spawn_id timeout {
138 perror "(timeout) interrupting the remote stub";
141 -i $gdb_spawn_id default {
142 perror "error interrupting the remote stub";
146 if [target_info exists gdb_serial] {
147 send_gdb "target remote [target_info gdb_serial]\n"
149 -i $gdb_spawn_id -re ".*Kill it?.*y or n.*" {
153 -i $gdb_spawn_id -re ".*$prompt $" {
154 verbose "connected to stub at [target_info gdb_serial]" 2
156 -i $gdb_spawn_id timeout {
158 verbose "Timeout is now $timeout seconds" 2
159 perror "Couldn't set remote target."
167 -i $gdb_spawn_id -re ".*$prompt $" {
168 verbose "Breakpoints enabled" 2
170 -i $gdb_spawn_id timeout {
171 perror "(timeout) enabling breakpoints";
174 -i $gdb_spawn_id default {
175 perror "error enabling breakpoints";
178 send_gdb "continue\n";
184 # gdb_load -- load a file into the GDB.
185 # Returns a 0 if there was an error,
186 # 1 if it load successfully.
188 proc gdb_load { arg } {
197 set loadfile [file tail $arg]
198 set loadpath [file dirname $arg]
200 if [target_info exists gdb_protocol] {
201 set protocol [target_info gdb_protocol];
206 # get the stub-based loader for faster loading
207 send_gdb "file [target_info gdb_loader]\n"
209 -i $gdb_spawn_id -re "A program is being debug.*Kill it.*y or n. $" {
213 -i $gdb_spawn_id -re "Load new symbol table.*y or n. $" {
217 -i $gdb_spawn_id -re "Reading symbols from.*done..*$prompt $" {}
218 -i $gdb_spawn_id -re "$prompt $" { perror "GDB couldn't find loader" }
219 -i $gdb_spawn_id timeout {
220 perror "(timeout) read symbol file" ;
225 if [target_info exists serial] {
226 set targetname [target_info serial];
227 send_gdb "target $protocol [target_info serial]\n";
229 if ![target_info exists netport] {
230 perror "Need either netport or gdb_serial entry for [target_info name].";
233 set targetname [target_info netport];
234 send_gdb "target $protocol udp [target_info netport]\n";
237 -i $gdb_spawn_id -re "Remote target.*$prompt $" { }
238 -i $gdb_spawn_id -re ".*SPARCLET appears to be alive.*$prompt $" {
240 send_user "Set target to $targetname\n"
243 -i $gdb_spawn_id timeout {
245 verbose "Timeout is now $timeout seconds" 2
246 perror "Couldn't set M32R target."
253 -i $gdb_spawn_id -re "A program is being debug.*Kill it.*y or n. $" {
257 -i $gdb_spawn_id -re "The program being debugged .*y or n. $" {
261 -i $gdb_spawn_id -re ".*Starting program:.*loader.*$" {
262 verbose "Starting loader succeeded"
264 -i $gdb_spawn_id timeout {
265 perror "(timeout) starting the loader" ;
268 -i $gdb_spawn_id default {
269 perror "error starting the loader";
278 -i $gdb_spawn_id -re ".*Give up .and stop debugging it.*$" {
282 -i $gdb_spawn_id -re ".*$prompt $" {
283 verbose "Running loader succeeded"
285 -i $gdb_spawn_id timeout {
286 perror "(timeout) interrupting the loader" ;
289 -i $gdb_spawn_id default {
290 perror "error interrupting the loader";
294 # Now ready to actually load the file:
296 send_gdb "file $arg\n"
298 -i $gdb_spawn_id -re "A program is being debug.*Kill it.*y or n. $" {
302 -i $gdb_spawn_id -re "Load new symbol table.*y or n. $" {
306 -i $gdb_spawn_id -re "Reading symbols from.*done..*$prompt $" {}
307 -i $gdb_spawn_id -re "$prompt $" { perror "GDB couldn't read file" }
308 -i $gdb_spawn_id timeout {
309 perror "(timeout) read symbol file" ;
314 if [target_info exists gdb_serial] {
315 send_gdb "target remote [target_info gdb_serial]\n"
317 -i $gdb_spawn_id -re ".*Kill it?.*y or n.*" {
321 -i $gdb_spawn_id -re ".*$prompt $" {
322 verbose "Set remote target to [target_info serial]" 2
324 -i $gdb_spawn_id timeout {
326 verbose "Timeout is now $timeout seconds" 2
327 perror "Couldn't set remote target."
332 if [target_info exists gdb_load_offset] {
333 set offset "[target_info gdb_load_offset]";
337 send_gdb "load $arg $offset\n"
338 verbose "Loading $arg into $GDB" 2
340 verbose "Timeout is now $timeout seconds" 2
342 -i $gdb_spawn_id -re "Loading.*$prompt $" {
343 verbose "Loaded $arg into $GDB" 1
345 verbose "Timeout is now $timeout seconds" 2
347 -i $gdb_spawn_id -re "$prompt $" {
349 perror "GDB couldn't load."
352 -i $gdb_spawn_id timeout {
354 perror "Timed out trying to load $arg."
359 send_user "
\aPlease reset the board now...
\a\n"
367 # go back to monitor, run the program, interrupt it, and start remote.
369 if [target_info exists serial] {
370 set targetname [target_info serial];
371 send_gdb "target $protocol [target_info serial]\n";
373 if ![target_info exists netport] {
374 perror "Need either netport or gdb_serial entry for [target_info name].";
377 set targetname [target_info netport];
378 send_gdb "target $protocol udp [target_info netport]\n";
382 -i $gdb_spawn_id -re "A program is being debug.*Kill it.*y or n. $" {
386 -i $gdb_spawn_id -re "Remote target.*$prompt $" { }
387 -i $gdb_spawn_id -re ".*SPARCLET appears to be alive.*$prompt $" {
389 send_user "Set target to $targetname\n"
392 -i $gdb_spawn_id timeout {
394 verbose "Timeout is now $timeout seconds" 2
395 perror "Couldn't set M32R target."
402 -i $gdb_spawn_id -re "A program is being debug.*Kill it.*y or n. $" {
406 -i $gdb_spawn_id -re "The program being debugged .*y or n. $" {
410 -i $gdb_spawn_id -re ".*Starting program:.*$" {
411 verbose "Starting remote stub succeeded"
413 -i $gdb_spawn_id timeout {
414 perror "(timeout) starting the remote stub" ;
417 -i $gdb_spawn_id default {
418 perror "error starting the remote stub";
427 -i $gdb_spawn_id -re ".*Give up .and stop debugging it.*$" {
431 -i $gdb_spawn_id -re ".*$prompt $" {
432 verbose "interrupting remote stub succeeded"
434 -i $gdb_spawn_id timeout {
435 perror "(timeout) interrupting the remote stub";
438 -i $gdb_spawn_id default {
439 perror "error interrupting the remote stub";
443 if [target_info exists gdb_serial] {
444 send_gdb "target remote [target_info gdb_serial]\n"
446 -i $gdb_spawn_id -re ".*Kill it?.*y or n.*" {
450 -i $gdb_spawn_id -re ".*$prompt $" {
451 verbose "connected to stub at [target_info gdb_serial]" 2
453 -i $gdb_spawn_id timeout {
455 verbose "Timeout is now $timeout seconds" 2
456 perror "Couldn't set remote target."