* config/mt-slite: add LIBS and -nostdlib.
[deliverable/binutils-gdb.git] / gdb / testsuite / config / slite-gdb.exp
CommitLineData
40ee1402
KH
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., 675 Mass Ave, Cambridge, MA 02139, 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
33load_lib remote.exp
34load_lib gdb.exp
35
36#
37# gdb_version -- extract and print the version number of gdb
38#
39proc 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#
54proc 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 "Reading symbols from.*done..*$prompt $" {}
74 -re "$prompt $" { perror "GDB couldn't read file" }
75 timeout { perror "(timeout) read symbol file" ; return -1 }
76 }
77
78 send "target sparclite $targetname\n"
79 set timeout 60
80 expect {
81 -re ".*SPARClite appears to be alive.*$prompt $" {
82 if $verbose>1 then {
83 send_user "Set target to $targetname\n"
84 }
85 }
86 timeout {
87 perror "Couldn't set SLITE target."
88 set timeout 10
89 return -1
90 }
91 }
92
93 send "load $arg\n"
94 if $verbose>1 then {
95 send_user "Loading $arg into $GDB\n"
96 }
97 set timeout 2400
98 expect {
99 -re "Loading.*$prompt $" {
100 if $verbose>1 then {
101 send_user "Loaded $arg into $GDB\n"
102 }
103 set timeout 30
104 }
105 -re "$prompt $" {
106 if $verbose>1 then {
107 perror "GDB couldn't load."
108 }
109 }
110 timeout {
111 if $verbose>1 then {
112 perror "Timed out trying to load $arg."
113 }
114 }
115 }
116 set timeout 10
117
118 send "target remote $targetname\n"
119 set timeout 60
120 expect {
121 -re ".*$prompt $" {
122 if $verbose>1 then {
123 send_user "Set remote target to $targetname\n"
124 }
125 }
126 timeout {
127 perror "Couldn't set remote target."
128 set timeout 10
129 return -1
130 }
131 }
132
133 if [info exists expect_out(buffer)] then {
134 send_log $expect_out(buffer)
135 }
136 return 0
137}
138
139#
140# gdb_start -- start GDB running.
141#
142proc gdb_start { } {
143 global GDB
144 global GDBFLAGS
145 global spawn_id
146 global shell_id
147 global prompt
148 global verbose
149 global targetname
150 global connectmode
151 global reboot
152 global baud
153
154 # reboot the board to get a clean start
155 if $reboot then {
156 if ![info exists connectmode] then {
157 set connectmode "kermit"
158 }
159 if ![info exists baud] then {
160 set baud 9600
161 }
162 set shell_id [ eval $connectmode "$targetname" ]
163 send -i $shell_id "\n"
164 expect {
165 -i $shell_id -re ">$" { }
166 timeout {
167 send -i $shell_id "\CC"
168 expect {
169 -i $shell_id -re ">$" { }
170 timeout {
171 perror "(timeout) board did not come up."; return -1
172 }
173 }
174 }
175 }
176 send -i $shell_id "go 0xbfc00000\n"
177 expect {
178 -i $shell_id -re ">$" { }
179 timeout { perror "(timeout) board did not come up."; return -1 }
180 }
181 verbose "about to exit kermit"
182 exit_remote_shell $shell_id
183 }
184
185 set GDB [which $GDB]
186 # start GDB
187 if [ llength $GDBFLAGS ] then {
188 spawn $GDB $GDBFLAGS
189 } else {
190 spawn $GDB
191 }
192 expect {
193 -re ".*\r\n$prompt $" {
194 verbose "GDB initialized."
195 }
196 -re "$prompt $" {
197 perror "GDB never initialized."
198 return -1
199 }
200 timeout {
201 perror "(timeout) GDB never initialized."
202 return -1
203 }
204 }
205
206 # force the height to "unlimited", so no pagers get used
207 send "set height 0\n"
208 expect -re ".*$prompt $" {}
209 # force the width to "unlimited", so no wraparound occurs
210 send "set width 0\n"
211 expect -re ".*$prompt $" {}
212
213 # Don't use floating point instructions, in case the board doesn't
214 # support them.
215 # send "set mipsfpu off\n"
216 # expect -re ".*$prompt $" {}
217
218# if $verbose>1 then {
219# send_user "Setting up target, please wait...\n"
220# }
221# send "target mips $targetname\n"
222# set timeout 60
223# expect {
224# -re "Remote MIPS debugging.*$prompt $" {
225# if $verbose>1 then {
226# send_user "Set target to $targetname\n"
227# }
228# }
229# timeout {
230# perror "Couldn't set MIPS target."
231# set timeout 10
232# return -1
233# }
234# }
235 set timeout 10
236}
237
238expect_after {
239 "<return>" { send "\n"; perror "Window too small." }
240 -re "\(y or n\) " { send "n\n"; perror "Got interactive prompt." }
241 buffer_full { perror "internal buffer is full." }
242 eof { perror "eof -- pty is hosed." }
243 timeout { perror "timeout." }
244 "virtual memory exhausted" { perror "virtual memory exhausted." }
245 "Undefined command" { perror "send string probably wrong." }
246}
247
248proc gdb_exit { } {
249 catch default_gdb_exit
250}
251
252gdb_start
253
254# make sure gdb has actually started, otherwise if the first test
255# timesout, DejaGnu crashes
256send "\n"
257expect {
258 -re "$prompt"
259 }
This page took 0.031986 seconds and 4 git commands to generate.