]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - gdb/testsuite/config/slite.exp
Copyright updates for 2007.
[thirdparty/binutils-gdb.git] / gdb / testsuite / config / slite.exp
CommitLineData
6aba47ca 1# Copyright 1993, 1997, 1998, 2007 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
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
c906108c
SS
17# This file was written by Ian Lance Taylor <ian@cygnus.com>.
18
19# GDB support routines for a board using the MIPS remote debugging
20# protocol. These are actually pretty generic.
21
22# DejaGnu currently assumes that debugging is being done over the main
23# console port. It would probably be more convenient for people using
24# IDT boards to permit the debugging port and the connected port to be
25# different, since an IDT board has two ports. This would require
26# extending some of the tests in a fashion similar to that done for
27# VxWorks, because the test output would appear on the other port,
28# rather than being displayed by gdb.
29
30load_lib remote.exp
31load_lib gdb.exp
32set gdb_prompt "\\(gdb\\)"
33
34#
35# gdb_load -- load a file into the GDB.
36# Returns a 0 if there was an error,
37# 1 if it load successfully.
38#
39proc gdb_load { arg } {
40 global verbose
41 global loadpath
42 global loadfile
43 global gdb_prompt
44 global GDB
45 global expect_out
46
47 set loadfile [file tail $arg]
48 set loadpath [file dirname $arg]
49
50 gdb_file_cmd $arg
51
52 if [target_info exists gdb_protocol] {
53 set protocol [target_info gdb_protocol];
54 } else {
55 set protocol "sparclite"
56 }
57
58 if [target_info exists serial] {
59 set targetname [target_info serial];
60 set command "target $protocol [target_info serial]\n";
61 } else {
62 if ![target_info exists netport] {
63 perror "Need either netport or gdb_serial entry for [target_info name].";
64 return -1;
65 }
66 set targetname [target_info netport];
67 set command "target $protocol udp [target_info netport]\n";
68 }
69 set timeout 60
70 verbose "Timeout is now $timeout seconds" 2
71 set try_count 0;
72 send_gdb $command;
73 gdb_expect {
74 -re "Unknown response.*resetting the board.|remote timeout" {
75 incr try_count;
76 if { $try_count > 3 } {
77 set try_count 0;
78 reboot_target;
79 sleep 5;
80 }
81 sleep 1;
82 send_gdb $command;
83 exp_continue;
84 }
85 -re "Remote target.*$gdb_prompt $" { }
86 -re ".*SPARClite appears to be alive.*$gdb_prompt $" {
87 if $verbose>1 then {
88 send_user "Set target to $targetname\n"
89 }
90 }
91 timeout {
92 perror "Couldn't set SLITE target."
93 set timeout 10
94 verbose "Timeout is now $timeout seconds" 2
95 return -1
96 }
97 }
98
99 if [target_info exists gdb_load_offset] {
100 set offset "[target_info gdb_load_offset]";
101 } else {
102 set offset "";
103 }
104 if { 1 } {
105 if [is_remote host] {
106 set arg [remote_download host $arg];
107 if { $arg == "" } {
108 error "download failed"
109 return -1;
110 }
111 }
112 send_gdb "load $arg $offset\n"
113 verbose "Loading $arg into $GDB" 2
114 set timeout 2400
115 verbose "Timeout is now $timeout seconds" 2
116 gdb_expect {
117 -re "Loading.*$gdb_prompt $" {
118 verbose "Loaded $arg into $GDB" 1
119 set timeout 30
120 verbose "Timeout is now $timeout seconds" 2
121 }
122 -re "$gdb_prompt $" {
123 if $verbose>1 then {
124 perror "GDB couldn't load."
125 }
126 }
127 timeout {
128 if $verbose>1 then {
129 perror "Timed out trying to load $arg."
130 }
131 }
132 }
133 }
134 # Some SPARClite boards automagically do a run after the program is
135 # loaded.
136 if [target_info exists need_monitor_run] {
137 set timeout 10
138 verbose "Timeout is now $timeout seconds, doing monitor run" 2
139 send_gdb "monitor run\n";
140 sleep 2;
141 send_gdb "\ 3";
142 gdb_expect {
143 -re ".*$gdb_prompt $" { verbose "Run command succeded" }
144 default {
145 perror "error sending monitor run command";
146 }
147 }
148 } else {
149 sleep 2;
150 }
151
152 if [target_info exists gdb_serial] {
153 set serial [target_info gdb_serial];
154 } else {
155 set serial [target_info serial];
156 }
157 send_gdb "target remote $serial\n"
158 set timeout 60
159 verbose "Timeout is now $timeout seconds" 2
160 gdb_expect {
161 -re ".*Kill it?.*y or n.*" {
162 send_gdb "y\n";
163 exp_continue
164 }
165 -re ".*$gdb_prompt $" {
166 verbose "Set remote target to [target_info serial]" 2
167 }
168 timeout {
169 perror "Couldn't set remote target."
170 set timeout 10
171 verbose "Timeout is now $timeout seconds" 2
172 return -1
173 }
174 }
175
176 if [info exists expect_out(buffer)] then {
177 send_log $expect_out(buffer)
178 }
179 return 0
180}