* config/proelf.exp: New entry.
[deliverable/binutils-gdb.git] / gdb / testsuite / config / sparclet.exp
1 # Copyright (C) 1996, 1997 Free Software Foundation, Inc.
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
5 # the Free Software Foundation; either version 2 of the License, or
6 # (at your option) any later version.
7 #
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.
12 #
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.
16
17 # Please email any bugs, comments, and/or additions to this file to:
18 # DejaGnu@cygnus.com
19
20 # This file was written by Michael Snyder <msnyder@cygnus.com>.
21
22 # GDB support routines for a board using the sparclet remote debugging
23 # protocol.
24
25 load_lib remote.exp
26 load_lib gdb.exp
27 set gdb_prompt "\\(gdbslet\\)"
28
29
30 #
31 # Sparclet remote run command.
32 #
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.
37 #
38
39 proc gdb_start { } {
40 global gdb_prompt
41 global GDB
42
43 if { [default_gdb_start] != 0 } {
44 return -1;
45 }
46
47 if [target_info exists baud] {
48 send_gdb "set remotebaud [target_info baud]\n"
49 gdb_expect {
50 -re ".*$gdb_prompt" { }
51 default {
52 perror "Error setting baud rate."
53 return -1;
54 }
55 }
56 }
57
58 for {set x 1;} { $x < 4 } {incr x} {
59 if { [gdb_sparclet_startup] > 0 } {
60 break;
61 }
62 reboot_target;
63 }
64 return 1;
65 }
66
67 proc gdb_sparclet_startup { } {
68 global gdb_prompt
69 global GDB
70
71 set timeout 5;
72 set is_running_stub 0;
73
74 send_gdb "target sparclet [target_info serial]\n";
75 gdb_expect {
76 -re ".*already.*y or n." {
77 gdb_send "y\n";
78 exp_continue;
79 }
80 -re "Remote target.*connected to.*$gdb_prompt" { }
81 timeout {
82 verbose "timed out, checking if stub is already running"
83 set timeout 10
84 send_gdb "\003";
85 gdb_expect {
86 -re ".*$gdb_prompt" {
87 }
88 default {
89 perror "sparclet board isn't responding";
90 return -1;
91 }
92 }
93 send_gdb "target remote [target_info gdb_serial]\n";
94 gdb_expect {
95 -re ".*Remote debugging.*$gdb_prompt" {
96 verbose "stub is already running"
97 set is_running_stub 1;
98 }
99 default {
100 perror "sparclet board isn't responding";
101 return -1;
102 }
103 }
104 }
105 }
106
107 if { $is_running_stub == 0 } {
108 global srcdir
109
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]"];
112 }
113 set loader "loader";
114 send_gdb "file $loader\n";
115 gdb_expect {
116 -re "A program is being debug.*Kill it.*y or n. $" {
117 send_gdb "y\n"
118 exp_continue
119 }
120 -re "Load new symbol table.*y or n. $" {
121 send_gdb "y\n"
122 exp_continue
123 }
124 -re "Reading symbols from.*done..*$gdb_prompt $" {}
125 -re "$gdb_prompt $" { perror "GDB couldn't find loader" }
126 timeout {
127 perror "(timeout) read symbol file" ;
128 return -1
129 }
130 }
131
132 send_gdb "target [target_info gdb_protocol] [target_info serial]\n";
133 gdb_expect {
134 -re "Remote target.*connected to.*$gdb_prompt" { }
135 default {
136 perror "Error reconnecting to sparclet.";
137 return -1;
138 }
139 }
140
141 send_gdb "load $loader [target_info gdb_stub_offset]\n"
142 verbose "Loading $loader into $GDB" 2
143 set timeout 1200
144 verbose "Timeout is now $timeout seconds" 2
145 gdb_expect {
146 -re "Loading.*$gdb_prompt $" {
147 verbose "Loaded $loader into $GDB" 1
148 set timeout 60
149 verbose "Timeout is now $timeout seconds" 2
150 }
151 -re "$gdb_prompt $" {
152 if $verbose>1 then {
153 perror "GDB couldn't load."
154 }
155 }
156 timeout {
157 if $verbose>1 then {
158 perror "Timed out trying to load $arg."
159 }
160 }
161 }
162
163 send_gdb "run\n";
164 gdb_expect {
165 -re "A program is being debug.*Kill it.*y or n. $" {
166 send_gdb "y\n"
167 exp_continue
168 }
169 -re "The program being debugged .*y or n. $" {
170 send_gdb "y\n"
171 exp_continue
172 }
173 -re ".*Starting program:.*loader.*$" {
174 verbose "Starting loader succeeded"
175 }
176 timeout {
177 perror "(timeout) starting the loader" ;
178 return -1
179 }
180 default {
181 perror "error starting the loader";
182 }
183 }
184 sleep 2;
185 send_gdb "\ 3"
186 sleep 1;
187 send_gdb "\ 3"
188 verbose "Sent ^C^C"
189 gdb_expect {
190 -re ".*Give up .and stop debugging it.*$" {
191 send_gdb "y\n"
192 exp_continue
193 }
194 -re ".*$gdb_prompt $" {
195 verbose "Running loader succeeded"
196 }
197 timeout {
198 perror "(timeout) interrupting the loader" ;
199 return -1
200 }
201 default {
202 perror "error interrupting the loader";
203 }
204 }
205
206 gdb_exit;
207 return [gdb_start];
208 }
209 return 1;
210 }
211
212 proc gdb_run_cmd { args } {
213 global gdb_prompt
214
215 gdb_breakpoint exit;
216 send_gdb "set \$fp=0\n";
217 gdb_expect {
218 -re ".*$gdb_prompt" { }
219 }
220 send_gdb "jump start\n";
221 gdb_expect {
222 -re ".*y or n. $" {
223 send_gdb "y\n"
224 }
225 -re "Continuing at.*\[\r\n\]" { }
226 default {
227 return "failed"
228 }
229 }
230 return "";
231 }
232
233
234 #
235 # gdb_load -- load a file into the GDB.
236 # Returns a 0 if there was an error,
237 # 1 if it load successfully.
238 #
239 proc gdb_load { arg } {
240 global verbose
241 global loadpath
242 global loadfile
243 global gdb_prompt
244 global GDB
245 global expect_out
246
247 set loadfile [file tail $arg]
248 set loadpath [file dirname $arg]
249
250 if [target_info exists gdb_protocol] {
251 set protocol [target_info gdb_protocol];
252 } else {
253 set protocol "sparclet"
254 }
255
256 send_gdb "file $arg\n"
257 gdb_expect {
258 -re "A program is being debug.*Kill it.*y or n. $" {
259 send_gdb "y\n"
260 exp_continue
261 }
262 -re "Load new symbol table.*y or n. $" {
263 send_gdb "y\n"
264 exp_continue
265 }
266 -re "Reading symbols from.*done..*$gdb_prompt $" {}
267 -re "$gdb_prompt $" { perror "GDB couldn't read file" }
268 timeout {
269 perror "(timeout) read symbol file" ;
270 return -1
271 }
272 }
273
274 if [target_info exists gdb_serial] {
275 send_gdb "target remote [target_info gdb_serial]\n"
276 gdb_expect {
277 -re ".*Kill it?.*y or n.*" {
278 send_gdb "y\n";
279 exp_continue
280 }
281 -re ".*$gdb_prompt $" {
282 verbose "Set remote target to [target_info serial]" 2
283 }
284 timeout {
285 set timeout 10
286 verbose "Timeout is now $timeout seconds" 2
287 perror "Couldn't set remote target."
288 return -1
289 }
290 }
291 }
292 if [target_info exists gdb_load_offset] {
293 set offset "[target_info gdb_load_offset]";
294 } else {
295 set offset "";
296 }
297 send_gdb "load $arg $offset\n"
298 verbose "Loading $arg into $GDB" 2
299 set timeout 1200
300 verbose "Timeout is now $timeout seconds" 2
301 gdb_expect {
302 -re "Loading.*$gdb_prompt $" {
303 verbose "Loaded $arg into $GDB" 1
304 set timeout 60
305 verbose "Timeout is now $timeout seconds" 2
306 }
307 -re "$gdb_prompt $" {
308 if $verbose>1 then {
309 perror "GDB couldn't load."
310 }
311 }
312 timeout {
313 if $verbose>1 then {
314 perror "Timed out trying to load $arg."
315 }
316 }
317 }
318 send_gdb "list main\n";
319 gdb_expect {
320 -re ".*$gdb_prompt" { }
321 default {
322 perror "command for list main never completed";
323 return -1;
324 }
325 }
326
327 return 0
328 }
This page took 0.035851 seconds and 4 git commands to generate.