Automatic Copyright Year update after running gdb/copyright.py
[deliverable/binutils-gdb.git] / gdb / testsuite / config / slite.exp
CommitLineData
88b9d363 1# Copyright 1993-2022 Free Software Foundation, Inc.
c906108c
SS
2
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
e22f8b7c 5# the Free Software Foundation; either version 3 of the License, or
c906108c 6# (at your option) any later version.
e22f8b7c 7#
c906108c
SS
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.
e22f8b7c 12#
c906108c 13# You should have received a copy of the GNU General Public License
e22f8b7c 14# along with this program. If not, see <http://www.gnu.org/licenses/>.
c906108c 15
c906108c
SS
16# This file was written by Ian Lance Taylor <ian@cygnus.com>.
17
18# GDB support routines for a board using the MIPS remote debugging
19# protocol. These are actually pretty generic.
20
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.
28
29load_lib remote.exp
7cde5fc2 30
c906108c
SS
31set gdb_prompt "\\(gdb\\)"
32
33#
34# gdb_load -- load a file into the GDB.
35# Returns a 0 if there was an error,
36# 1 if it load successfully.
37#
38proc gdb_load { arg } {
39 global verbose
40 global loadpath
41 global loadfile
42 global gdb_prompt
43 global GDB
44 global expect_out
45
46 set loadfile [file tail $arg]
47 set loadpath [file dirname $arg]
48
49 gdb_file_cmd $arg
50
51 if [target_info exists gdb_protocol] {
4ec70201 52 set protocol [target_info gdb_protocol]
c906108c
SS
53 } else {
54 set protocol "sparclite"
55 }
56
57 if [target_info exists serial] {
4ec70201
PA
58 set targetname [target_info serial]
59 set command "target $protocol [target_info serial]\n"
c906108c
SS
60 } else {
61 if ![target_info exists netport] {
4ec70201 62 perror "Need either netport or gdb_serial entry for [target_info name]."
ae59b1da 63 return -1
c906108c 64 }
4ec70201
PA
65 set targetname [target_info netport]
66 set command "target $protocol udp [target_info netport]\n"
c906108c
SS
67 }
68 set timeout 60
69 verbose "Timeout is now $timeout seconds" 2
4ec70201
PA
70 set try_count 0
71 send_gdb $command
c906108c
SS
72 gdb_expect {
73 -re "Unknown response.*resetting the board.|remote timeout" {
4ec70201 74 incr try_count
c906108c 75 if { $try_count > 3 } {
4ec70201
PA
76 set try_count 0
77 reboot_target
78 sleep 5
c906108c 79 }
4ec70201
PA
80 sleep 1
81 send_gdb $command
82 exp_continue
c906108c
SS
83 }
84 -re "Remote target.*$gdb_prompt $" { }
85 -re ".*SPARClite appears to be alive.*$gdb_prompt $" {
86 if $verbose>1 then {
87 send_user "Set target to $targetname\n"
88 }
89 }
90 timeout {
91 perror "Couldn't set SLITE target."
92 set timeout 10
93 verbose "Timeout is now $timeout seconds" 2
94 return -1
95 }
96 }
97
98 if [target_info exists gdb_load_offset] {
4ec70201 99 set offset "[target_info gdb_load_offset]"
c906108c 100 } else {
4ec70201 101 set offset ""
c906108c
SS
102 }
103 if { 1 } {
104 if [is_remote host] {
4ec70201 105 set arg [remote_download host $arg]
c906108c
SS
106 if { $arg == "" } {
107 error "download failed"
ae59b1da 108 return -1
c906108c
SS
109 }
110 }
111 send_gdb "load $arg $offset\n"
112 verbose "Loading $arg into $GDB" 2
113 set timeout 2400
114 verbose "Timeout is now $timeout seconds" 2
115 gdb_expect {
116 -re "Loading.*$gdb_prompt $" {
117 verbose "Loaded $arg into $GDB" 1
118 set timeout 30
119 verbose "Timeout is now $timeout seconds" 2
120 }
121 -re "$gdb_prompt $" {
122 if $verbose>1 then {
123 perror "GDB couldn't load."
124 }
125 }
126 timeout {
127 if $verbose>1 then {
128 perror "Timed out trying to load $arg."
129 }
130 }
131 }
132 }
133 # Some SPARClite boards automagically do a run after the program is
134 # loaded.
135 if [target_info exists need_monitor_run] {
136 set timeout 10
137 verbose "Timeout is now $timeout seconds, doing monitor run" 2
4ec70201
PA
138 send_gdb "monitor run\n"
139 sleep 2
140 send_gdb "\ 3"
c906108c
SS
141 gdb_expect {
142 -re ".*$gdb_prompt $" { verbose "Run command succeded" }
143 default {
4ec70201 144 perror "error sending monitor run command"
c906108c
SS
145 }
146 }
147 } else {
4ec70201 148 sleep 2
c906108c
SS
149 }
150
151 if [target_info exists gdb_serial] {
4ec70201 152 set serial [target_info gdb_serial]
c906108c 153 } else {
4ec70201 154 set serial [target_info serial]
c906108c
SS
155 }
156 send_gdb "target remote $serial\n"
157 set timeout 60
158 verbose "Timeout is now $timeout seconds" 2
159 gdb_expect {
160 -re ".*Kill it?.*y or n.*" {
4ec70201 161 send_gdb "y\n"
c906108c
SS
162 exp_continue
163 }
164 -re ".*$gdb_prompt $" {
165 verbose "Set remote target to [target_info serial]" 2
166 }
167 timeout {
168 perror "Couldn't set remote target."
169 set timeout 10
170 verbose "Timeout is now $timeout seconds" 2
171 return -1
172 }
173 }
174
175 if [info exists expect_out(buffer)] then {
176 send_log $expect_out(buffer)
177 }
178 return 0
179}
This page took 4.788892 seconds and 4 git commands to generate.