* as.h: Don't declare parameters for strstr.
[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
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
33set prompt "\(gdb\)"
34
35load_lib remote.exp
36load_lib gdb.exp
37
38#
39# gdb_version -- extract and print the version number of gdb
40#
41proc gdb_version {} {
42 global GDB
43 global GDBFLAGS
44 global prompt
45 set tmp [exec echo "q" | $GDB]
46 set version [lindex $tmp [lsearch $tmp "\[0-9\]*"]]
47 set version [string range $version 0 [expr [string length $version]-2]]
48 clone_output "[which $GDB] version $version $GDBFLAGS\n"
49}
50
51#
52# gdb_load -- load a file into the GDB.
53# Returns a 0 if there was an error,
54# 1 if it load successfully.
55#
56proc gdb_load { arg } {
57 global verbose
58 global loadpath
59 global loadfile
60 global prompt
61 global spawn_id
62 global GDB
63 global expect_out
64
65 set loadfile [file tail $arg]
66 set loadpath [file dirname $arg]
67 gdb_unload
68 send "file $arg\n"
69 expect {
70 -re "A program is being debugged already. Kill it\? \(y or n\)" {
71 send "y\n"
2f109983 72 continue -expect
31ca3f4c
ILT
73 }
74 -re "Reading symbols from.*done..*$prompt $" { }
8f07e537
BC
75 -re "$prompt $" { perror "GDB couldn't read file" }
76 timeout { perror "(timeout) read symbol file" ; return }
31ca3f4c
ILT
77 }
78 send "load $arg\n"
79 if $verbose>1 then {
80 send_user "Loading $arg into $GDB\n"
81 }
48d10a25 82 set timeout 2400
31ca3f4c
ILT
83 expect {
84 -re "Loading.*$prompt $" {
85 if $verbose>1 then {
86 send_user "Loaded $arg into $GDB\n"
87 }
88 set timeout 30
89 return 1
90 }
91 -re "$prompt $" {
92 if $verbose>1 then {
8f07e537 93 perror "GDB couldn't load."
31ca3f4c
ILT
94 }
95 }
96 timeout {
97 if $verbose>1 then {
8f07e537 98 perror "Timed out trying to load $arg."
31ca3f4c
ILT
99 }
100 }
101 }
102 set timeout 10
103 if [info exists expect_out(buffer)] then {
104 send_log $expect_out(buffer)
105 }
106 return 0
107}
108
31ca3f4c
ILT
109#
110# gdb_start -- start GDB running.
111#
112proc gdb_start { } {
113 global GDB
114 global GDBFLAGS
115 global spawn_id
116 global shell_id
117 global prompt
118 global verbose
119 global targetname
120 global connectmode
121 global reboot
122 global baud
123
124 # reboot the board to get a clean start
125 if $reboot then {
126 if ![info exists connectmode] then {
127 set connectmode "kermit"
128 }
129 if ![info exists baud] then {
130 set baud 9600
131 }
132 set shell_id [ eval $connectmode "$targetname" $baud ]
48d10a25
ILT
133 send -i $shell_id "\n"
134 expect {
135 -i $shell_id -re "<IDT>$" { }
136 timeout {
137 send -i $shell_id "\CC"
138 expect {
139 -i $shell_id -re "<IDT>$" { }
140 timeout {
8f07e537 141 perror "(timeout) board did not come up."; return -1
48d10a25
ILT
142 }
143 }
144 }
31ca3f4c 145 }
48d10a25
ILT
146 send -i $shell_id "go 0xbfc00000\n"
147 expect {
148 -i $shell_id -re "<IDT>$" { }
8f07e537 149 timeout { perror "(timeout) board did not come up."; return -1 }
31ca3f4c 150 }
48d10a25 151 verbose "about to exit kermit"
31ca3f4c
ILT
152 exit_remote_shell $shell_id
153 }
154
155 set GDB [which $GDB]
156 # start GDB
157 if [ llength $GDBFLAGS ] then {
158 spawn $GDB $GDBFLAGS
159 } else {
160 spawn $GDB
161 }
162 expect {
163 -re "GDB.*$prompt $" {
164 if $verbose>1 then {
165 send_user "$GDB initialized for cross mode\n\n"
166 }
167 }
8f07e537
BC
168 -re "$prompt $" { perror "GDB never initialized."; return -1 }
169 timeout { perror "(timeout) GDB never initialized.";
05a291bb 170 return -1 }
31ca3f4c
ILT
171 }
172
173 # force the height to "unlimited", so no pagers get used
174 send "set height 0\n"
175 expect -re ".*$prompt $" {}
176 # force the width to "unlimited", so no wraparound occurs
177 send "set width 0\n"
178 expect -re ".*$prompt $" {}
179
180 # Don't use floating point instructions, in case the board doesn't
181 # support them.
182 send "set mipsfpu off\n"
183 expect -re ".*$prompt $" {}
184
185 if $verbose>1 then {
186 send_user "Setting up target, please wait...\n"
187 }
188 send "target mips $targetname\n"
189 set timeout 60
190 expect {
191 -re "Remote MIPS debugging.*$prompt $" {
192 if $verbose>1 then {
193 send_user "Set target to $targetname\n"
194 }
195 }
196 timeout {
8f07e537 197 perror "Couldn't set MIPS target."
31ca3f4c 198 set timeout 10
05a291bb 199 return -1
31ca3f4c
ILT
200 }
201 }
202 set timeout 10
203}
204
205expect_after {
8f07e537
BC
206 "<return>" { send "\n"; perror "Window too small." }
207 -re "\(y or n\) " { send "n\n"; perror "Got interactive prompt." }
208 buffer_full { perror "internal buffer is full." }
209 eof { perror "eof -- pty is hosed." }
210 timeout { perror "timeout." }
211 "virtual memory exhausted" { perror "virtual memory exhausted." }
212 "Undefined command" { perror "send string probably wrong." }
31ca3f4c
ILT
213}
214
3f677d9e 215proc gdb_exit { } {
3f677d9e
RS
216 catch default_gdb_exit
217}
218
31ca3f4c
ILT
219gdb_start
220
221# make sure gdb has actually started, otherwise if the first test
222# timesout, DejaGnu crashes
223send "\n"
224expect {
225 -re "$prompt"
226 }
This page took 0.131022 seconds and 4 git commands to generate.