]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blob - gdb/testsuite/config/slite-gdb.exp
* elf32-mn10200.c (reloc_type): Add 16bit pc-relative reloc.
[thirdparty/binutils-gdb.git] / gdb / testsuite / config / slite-gdb.exp
1 # Copyright (C) 1993 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 Ian Lance Taylor <ian@cygnus.com>.
21
22 # GDB support routines for a board using the MIPS remote debugging
23 # protocol. These are actually pretty generic.
24
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.
32
33 load_lib remote.exp
34 load_lib gdb.exp
35
36 #
37 # gdb_version -- extract and print the version number of gdb
38 #
39 proc gdb_version {} {
40 global GDB
41 global GDBFLAGS
42 global prompt
43 set tmp [exec echo "q" | $GDB]
44 set version [lindex $tmp [lsearch $tmp "\[0-9\]*"]]
45 set version [string range $version 0 [expr [string length $version]-2]]
46 clone_output "[which $GDB] version $version $GDBFLAGS\n"
47 }
48
49 #
50 # gdb_load -- load a file into the GDB.
51 # Returns a 0 if there was an error,
52 # 1 if it load successfully.
53 #
54 proc gdb_load { arg } {
55 global verbose
56 global loadpath
57 global loadfile
58 global prompt
59 global spawn_id
60 global GDB
61 global expect_out
62 global targetname
63
64 set loadfile [file tail $arg]
65 set loadpath [file dirname $arg]
66
67 send "file $arg\n"
68 expect {
69 -re "A program is being debugged already..*Kill it.*y or n. $" {
70 send "y\n"
71 exp_continue
72 }
73 -re "Load new symbol table.*y or n. $" {
74 send "y\n"
75 exp_continue
76 }
77 -re "Reading symbols from.*done..*$prompt $" {}
78 -re "$prompt $" { perror "GDB couldn't read file" }
79 timeout { perror "(timeout) read symbol file" ; return -1 }
80 }
81
82 send "target sparclite $targetname\n"
83 set timeout 60
84 verbose "Timeout is now $timeout seconds" 2
85 expect {
86 -re ".*SPARClite appears to be alive.*$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 send "load $arg\n"
100 if $verbose>1 then {
101 send_user "Loading $arg into $GDB\n"
102 }
103 set timeout 2400
104 verbose "Timeout is now $timeout seconds" 2
105 expect {
106 -re "Loading.*$prompt $" {
107 if $verbose>1 then {
108 send_user "Loaded $arg into $GDB\n"
109 }
110 set timeout 30
111 verbose "Timeout is now $timeout seconds" 2
112 }
113 -re "$prompt $" {
114 if $verbose>1 then {
115 perror "GDB couldn't load."
116 }
117 }
118 timeout {
119 if $verbose>1 then {
120 perror "Timed out trying to load $arg."
121 }
122 }
123 }
124 set timeout 10
125 verbose "Timeout is now $timeout seconds" 2
126
127 send "target remote $targetname\n"
128 set timeout 60
129 verbose "Timeout is now $timeout seconds" 2
130 expect {
131 -re ".*$prompt $" {
132 if $verbose>1 then {
133 send_user "Set remote target to $targetname\n"
134 }
135 }
136 timeout {
137 perror "Couldn't set remote target."
138 set timeout 10
139 verbose "Timeout is now $timeout seconds" 2
140 return -1
141 }
142 }
143
144 if [info exists expect_out(buffer)] then {
145 send_log $expect_out(buffer)
146 }
147 return 0
148 }
149
150 #
151 # gdb_start -- start GDB running.
152 #
153 proc gdb_start { } {
154 global GDB
155 global GDBFLAGS
156 global spawn_id
157 global shell_id
158 global prompt
159 global verbose
160 global targetname
161 global connectmode
162 global reboot
163 global baud
164
165 # reboot the board to get a clean start
166 if $reboot then {
167 if ![info exists connectmode] then {
168 set connectmode "kermit"
169 }
170 if ![info exists baud] then {
171 set baud 9600
172 }
173 set shell_id [ eval $connectmode "$targetname" ]
174 send -i $shell_id "\n"
175 expect {
176 -i $shell_id -re ">$" { }
177 timeout {
178 send -i $shell_id "\CC"
179 expect {
180 -i $shell_id -re ">$" { }
181 timeout {
182 perror "(timeout) board did not come up."; return -1
183 }
184 }
185 }
186 }
187 send -i $shell_id "go 0xbfc00000\n"
188 expect {
189 -i $shell_id -re ">$" { }
190 timeout { perror "(timeout) board did not come up."; return -1 }
191 }
192 verbose "about to exit kermit"
193 exit_remote_shell $shell_id
194 }
195
196 set GDB [which $GDB]
197 # start GDB
198 if [ llength $GDBFLAGS ] then {
199 spawn $GDB $GDBFLAGS
200 } else {
201 spawn $GDB
202 }
203 expect {
204 -re ".*\r\n$prompt $" {
205 verbose "GDB initialized."
206 }
207 -re "$prompt $" {
208 perror "GDB never initialized."
209 return -1
210 }
211 timeout {
212 perror "(timeout) GDB never initialized."
213 return -1
214 }
215 }
216
217 # force the height to "unlimited", so no pagers get used
218 send "set height 0\n"
219 expect -re ".*$prompt $" {}
220 # force the width to "unlimited", so no wraparound occurs
221 send "set width 0\n"
222 expect -re ".*$prompt $" {}
223
224 # Don't use floating point instructions, in case the board doesn't
225 # support them.
226 # send "set mipsfpu off\n"
227 # expect -re ".*$prompt $" {}
228
229 # if $verbose>1 then {
230 # send_user "Setting up target, please wait...\n"
231 # }
232 # send "target mips $targetname\n"
233 # set timeout 60
234 # verbose "Timeout is now $timeout seconds" 2
235 # expect {
236 # -re "Remote MIPS debugging.*$prompt $" {
237 # if $verbose>1 then {
238 # send_user "Set target to $targetname\n"
239 # }
240 # }
241 # timeout {
242 # perror "Couldn't set MIPS target."
243 # set timeout 10
244 # verbose "Timeout is now $timeout seconds" 2
245 # return -1
246 # }
247 # }
248 set timeout 10
249 verbose "Timeout is now $timeout seconds" 2
250 }
251
252 expect_after {
253 "<return>" { send "\n"; perror "Window too small." }
254 -re "\(y or n\) " { send "n\n"; perror "Got interactive prompt." }
255 full_buffer { perror "internal buffer is full." }
256 eof { perror "eof -- pty is hosed." }
257 timeout { perror "timeout." }
258 "virtual memory exhausted" { perror "virtual memory exhausted." }
259 "Undefined command" { perror "send string probably wrong." }
260 }
261
262 proc gdb_exit { } {
263 catch default_gdb_exit
264 }
265
266 gdb_start
267
268 # make sure gdb has actually started, otherwise if the first test
269 # timesout, DejaGnu crashes
270 send "\n"
271 expect {
272 -re "$prompt"
273 }