* lib/gdb.exp: Report timeout value for verbosity level 2.
[deliverable/binutils-gdb.git] / gdb / testsuite / config / mips-gdb.exp
CommitLineData
31ca3f4c
ILT
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
6c9638b4 15# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
31ca3f4c
ILT
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
31ca3f4c
ILT
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
cb58e516 62 global targetname
31ca3f4c
ILT
63
64 set loadfile [file tail $arg]
65 set loadpath [file dirname $arg]
cb58e516 66
31ca3f4c
ILT
67 send "file $arg\n"
68 expect {
cb58e516 69 -re "A program is being debugged already..*Kill it.*y or n. $" {
31ca3f4c 70 send "y\n"
90fba5fa 71 exp_continue
31ca3f4c 72 }
cb58e516 73 -re "Reading symbols from.*done..*$prompt $" {}
8f07e537 74 -re "$prompt $" { perror "GDB couldn't read file" }
cb58e516
KH
75 timeout { perror "(timeout) read symbol file" ; return -1 }
76 }
77
78 send "target mips $targetname\n"
79 set timeout 60
a26fa899 80 verbose "Timeout is now $timeout seconds" 2
cb58e516
KH
81 expect {
82 -re "Remote MIPS debugging.*$prompt $" {
83 if $verbose>1 then {
84 send_user "Set target to $targetname\n"
85 }
86 }
87 timeout {
88 perror "Couldn't set MIPS target."
89 set timeout 10
a26fa899 90 verbose "Timeout is now $timeout seconds" 2
cb58e516
KH
91 return -1
92 }
31ca3f4c 93 }
cb58e516 94
31ca3f4c
ILT
95 send "load $arg\n"
96 if $verbose>1 then {
97 send_user "Loading $arg into $GDB\n"
98 }
48d10a25 99 set timeout 2400
a26fa899 100 verbose "Timeout is now $timeout seconds" 2
31ca3f4c
ILT
101 expect {
102 -re "Loading.*$prompt $" {
103 if $verbose>1 then {
104 send_user "Loaded $arg into $GDB\n"
105 }
106 set timeout 30
a26fa899 107 verbose "Timeout is now $timeout seconds" 2
31ca3f4c
ILT
108 }
109 -re "$prompt $" {
110 if $verbose>1 then {
cb58e516 111 perror "GDB couldn't load."
31ca3f4c
ILT
112 }
113 }
114 timeout {
115 if $verbose>1 then {
cb58e516 116 perror "Timed out trying to load $arg."
31ca3f4c
ILT
117 }
118 }
119 }
120 set timeout 10
a26fa899 121 verbose "Timeout is now $timeout seconds" 2
31ca3f4c
ILT
122 if [info exists expect_out(buffer)] then {
123 send_log $expect_out(buffer)
124 }
125 return 0
126}
127
31ca3f4c
ILT
128#
129# gdb_start -- start GDB running.
130#
131proc gdb_start { } {
132 global GDB
133 global GDBFLAGS
134 global spawn_id
135 global shell_id
136 global prompt
137 global verbose
138 global targetname
139 global connectmode
140 global reboot
141 global baud
142
143 # reboot the board to get a clean start
144 if $reboot then {
145 if ![info exists connectmode] then {
146 set connectmode "kermit"
147 }
148 if ![info exists baud] then {
149 set baud 9600
150 }
cb58e516 151 set shell_id [ eval $connectmode "$targetname" ]
48d10a25
ILT
152 send -i $shell_id "\n"
153 expect {
154 -i $shell_id -re "<IDT>$" { }
155 timeout {
156 send -i $shell_id "\CC"
157 expect {
158 -i $shell_id -re "<IDT>$" { }
159 timeout {
8f07e537 160 perror "(timeout) board did not come up."; return -1
48d10a25
ILT
161 }
162 }
163 }
31ca3f4c 164 }
48d10a25
ILT
165 send -i $shell_id "go 0xbfc00000\n"
166 expect {
167 -i $shell_id -re "<IDT>$" { }
8f07e537 168 timeout { perror "(timeout) board did not come up."; return -1 }
31ca3f4c 169 }
48d10a25 170 verbose "about to exit kermit"
31ca3f4c
ILT
171 exit_remote_shell $shell_id
172 }
173
174 set GDB [which $GDB]
175 # start GDB
176 if [ llength $GDBFLAGS ] then {
177 spawn $GDB $GDBFLAGS
178 } else {
179 spawn $GDB
180 }
181 expect {
cb58e516
KH
182 -re ".*\r\n$prompt $" {
183 verbose "GDB initialized."
184 }
185 -re "$prompt $" {
186 perror "GDB never initialized."
187 return -1
188 }
189 timeout {
190 perror "(timeout) GDB never initialized."
191 return -1
31ca3f4c 192 }
31ca3f4c
ILT
193 }
194
195 # force the height to "unlimited", so no pagers get used
196 send "set height 0\n"
197 expect -re ".*$prompt $" {}
198 # force the width to "unlimited", so no wraparound occurs
199 send "set width 0\n"
200 expect -re ".*$prompt $" {}
201
202 # Don't use floating point instructions, in case the board doesn't
203 # support them.
204 send "set mipsfpu off\n"
205 expect -re ".*$prompt $" {}
206
cb58e516
KH
207# if $verbose>1 then {
208# send_user "Setting up target, please wait...\n"
209# }
210# send "target mips $targetname\n"
211# set timeout 60
a26fa899 212# verbose "Timeout is now $timeout seconds" 2
cb58e516
KH
213# expect {
214# -re "Remote MIPS debugging.*$prompt $" {
215# if $verbose>1 then {
216# send_user "Set target to $targetname\n"
217# }
218# }
219# timeout {
220# perror "Couldn't set MIPS target."
221# set timeout 10
a26fa899 222# verbose "Timeout is now $timeout seconds" 2
cb58e516
KH
223# return -1
224# }
225# }
31ca3f4c 226 set timeout 10
a26fa899 227 verbose "Timeout is now $timeout seconds" 2
31ca3f4c
ILT
228}
229
230expect_after {
8f07e537
BC
231 "<return>" { send "\n"; perror "Window too small." }
232 -re "\(y or n\) " { send "n\n"; perror "Got interactive prompt." }
233 buffer_full { perror "internal buffer is full." }
234 eof { perror "eof -- pty is hosed." }
235 timeout { perror "timeout." }
236 "virtual memory exhausted" { perror "virtual memory exhausted." }
237 "Undefined command" { perror "send string probably wrong." }
31ca3f4c
ILT
238}
239
3f677d9e 240proc gdb_exit { } {
3f677d9e
RS
241 catch default_gdb_exit
242}
243
31ca3f4c
ILT
244gdb_start
245
246# make sure gdb has actually started, otherwise if the first test
247# timesout, DejaGnu crashes
248send "\n"
249expect {
250 -re "$prompt"
251 }
This page took 0.22988 seconds and 4 git commands to generate.