1 # Copyright 1993-2024 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 3 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, see <http://www.gnu.org/licenses/>.
16 # This file was written by Ian Lance Taylor <ian@cygnus.com>.
18 # GDB support routines for a board using the MIPS remote debugging
19 # protocol. These are actually pretty generic.
21 # DejaGnu currently assumes that debugging is being done over the main
22 # console port. It would probably be more convenient for people using
23 # IDT boards to permit the debugging port and the connected port to be
24 # different, since an IDT board has two ports. This would require
25 # extending some of the tests in a fashion similar to that done for
26 # VxWorks, because the test output would appear on the other port,
27 # rather than being displayed by gdb.
31 set gdb_prompt "\\(gdb\\)"
34 # gdb_load -- load a file into the GDB.
35 # Returns a 0 if there was an error,
36 # 1 if it load successfully.
38 proc gdb_load { arg } {
46 set loadfile [file tail $arg]
47 set loadpath [file dirname $arg]
51 if [target_info exists gdb_protocol] {
52 set protocol [target_info gdb_protocol]
54 set protocol "sparclite"
57 if [target_info exists serial] {
58 set targetname [target_info serial]
59 set command "target $protocol [target_info serial]\n"
61 if ![target_info exists netport] {
62 perror "Need either netport or gdb_serial entry for [target_info name]."
65 set targetname [target_info netport]
66 set command "target $protocol udp [target_info netport]\n"
69 verbose "Timeout is now $timeout seconds" 2
73 -re "Unknown response.*resetting the board.|remote timeout" {
75 if { $try_count > 3 } {
84 -re "Remote target.*$gdb_prompt $" { }
85 -re ".*SPARClite appears to be alive.*$gdb_prompt $" {
87 send_user "Set target to $targetname\n"
91 perror "Couldn't set SLITE target."
93 verbose "Timeout is now $timeout seconds" 2
98 if [target_info exists gdb_load_offset] {
99 set offset "[target_info gdb_load_offset]"
104 if [is_remote host] {
105 set arg [remote_download host $arg]
107 error "download failed"
111 send_gdb "load $arg $offset\n"
112 verbose "Loading $arg into $GDB" 2
114 verbose "Timeout is now $timeout seconds" 2
116 -re "Loading.*$gdb_prompt $" {
117 verbose "Loaded $arg into $GDB" 1
119 verbose "Timeout is now $timeout seconds" 2
121 -re "$gdb_prompt $" {
123 perror "GDB couldn't load."
128 perror "Timed out trying to load $arg."
133 # Some SPARClite boards automagically do a run after the program is
135 if [target_info exists need_monitor_run] {
137 verbose "Timeout is now $timeout seconds, doing monitor run" 2
138 send_gdb "monitor run\n"
142 -re ".*$gdb_prompt $" { verbose "Run command succeeded" }
144 perror "error sending monitor run command"
151 if [target_info exists gdb_serial] {
152 set serial [target_info gdb_serial]
154 set serial [target_info serial]
156 send_gdb "target remote $serial\n"
158 verbose "Timeout is now $timeout seconds" 2
160 -re ".*Kill it?.*y or n.*" {
164 -re ".*$gdb_prompt $" {
165 verbose "Set remote target to [target_info serial]" 2
168 perror "Couldn't set remote target."
170 verbose "Timeout is now $timeout seconds" 2
175 if {[info exists expect_out(buffer)]} {
176 send_log $expect_out(buffer)