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.
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 } {
51 set loadfile [file tail $arg]
52 set loadpath [file dirname $arg]
54 send_gdb "file $arg\n"
56 -i $gdb_spawn_id -re "A program is being debugged already..*Kill it.*y or n. $" {
60 -i $gdb_spawn_id -re "Load new symbol table.*y or n. $" {
64 -i $gdb_spawn_id -re "Reading symbols from.*done..*$gdb_prompt $" {}
65 -i $gdb_spawn_id -re "$gdb_prompt $" { perror "GDB couldn't read file" }
66 -i $gdb_spawn_id timeout { perror "(timeout) read symbol file" ; return -1 }
69 if [target_info exists gdb_protocol] {
70 set protocol [target_info gdb_protocol];
72 set protocol "sparclite"
75 if [target_info exists serial] {
76 set targetname [target_info serial];
77 send_gdb "target $protocol [target_info serial]\n";
79 if ![target_info exists netport] {
80 perror "Need either netport or gdb_serial entry for [target_info name].";
83 set targetname [target_info netport];
84 send_gdb "target $protocol udp [target_info netport]\n";
87 verbose "Timeout is now $timeout seconds" 2
89 -i $gdb_spawn_id -re "Remote target.*$gdb_prompt $" { }
90 -i $gdb_spawn_id -re ".*SPARClite appears to be alive.*$gdb_prompt $" {
92 send_user "Set target to $targetname\n"
95 -i $gdb_spawn_id timeout {
96 perror "Couldn't set SLITE target."
98 verbose "Timeout is now $timeout seconds" 2
103 if [target_info exists gdb_load_offset] {
104 set offset "[target_info gdb_load_offset]";
109 send_gdb "load $arg $offset\n"
110 verbose "Loading $arg into $GDB" 2
112 verbose "Timeout is now $timeout seconds" 2
114 -i $gdb_spawn_id -re "Loading.*$gdb_prompt $" {
115 verbose "Loaded $arg into $GDB" 1
117 verbose "Timeout is now $timeout seconds" 2
119 -i $gdb_spawn_id -re "$gdb_prompt $" {
121 perror "GDB couldn't load."
124 -i $gdb_spawn_id timeout {
126 perror "Timed out trying to load $arg."
132 verbose "Timeout is now $timeout seconds, doing monitor run" 2
133 send_gdb "monitor run\n";
137 -i $gdb_spawn_id -re ".*$gdb_prompt $" { verbose "Run command succeded" }
138 -i $gdb_spawn_id default {
139 perror "error sending monitor run command";
143 if [target_info exists gdb_serial] {
144 set serial [target_info gdb_serial];
146 set serial [target_info serial];
148 send_gdb "target remote $serial\n"
150 verbose "Timeout is now $timeout seconds" 2
152 -i $gdb_spawn_id -re ".*Kill it?.*y or n.*" {
156 -i $gdb_spawn_id -re ".*$gdb_prompt $" {
157 verbose "Set remote target to [target_info serial]" 2
159 -i $gdb_spawn_id timeout {
160 perror "Couldn't set remote target."
162 verbose "Timeout is now $timeout seconds" 2
167 if [info exists expect_out(buffer)] then {
168 send_log $expect_out(buffer)