* config.bfd (i[34]86-*-netbsd*): New target; use i386-netbsd.
[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"
72 continue -expect
73 }
74 -re "Reading symbols from.*done..*$prompt $" { }
75 -re "$prompt $" { error "GDB couldn't read file" }
76 timeout { error "(timeout) read symbol file" ; return }
77 }
78 send "load $arg\n"
79 if $verbose>1 then {
80 send_user "Loading $arg into $GDB\n"
81 }
82 set timeout 1200
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 {
93 error "GDB couldn't load."
94 }
95 }
96 timeout {
97 if $verbose>1 then {
98 error "Timed out trying to load $arg."
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 ]
133 send -i $shell_id "\CC"
134 expect -i $shell_id {
135 -re "<IDT>$" { }
05a291bb 136 timeout { error "(timeout) board did not come up."; return -1 }
31ca3f4c
ILT
137 }
138 send -i $shell_id "go 0xbfc00000"
139 expect -i $shell_id {
140 -re "<IDT>$" { }
05a291bb 141 timeout { error "(timeout) board did not come up."; return -1 }
31ca3f4c
ILT
142 }
143 exit_remote_shell $shell_id
144 }
145
146 set GDB [which $GDB]
147 # start GDB
148 if [ llength $GDBFLAGS ] then {
149 spawn $GDB $GDBFLAGS
150 } else {
151 spawn $GDB
152 }
153 expect {
154 -re "GDB.*$prompt $" {
155 if $verbose>1 then {
156 send_user "$GDB initialized for cross mode\n\n"
157 }
158 }
05a291bb 159 -re "$prompt $" { error "GDB never initialized."; return -1 }
31ca3f4c 160 timeout { error "(timeout) GDB never initialized.";
05a291bb 161 return -1 }
31ca3f4c
ILT
162 }
163
164 # force the height to "unlimited", so no pagers get used
165 send "set height 0\n"
166 expect -re ".*$prompt $" {}
167 # force the width to "unlimited", so no wraparound occurs
168 send "set width 0\n"
169 expect -re ".*$prompt $" {}
170
171 # Don't use floating point instructions, in case the board doesn't
172 # support them.
173 send "set mipsfpu off\n"
174 expect -re ".*$prompt $" {}
175
176 if $verbose>1 then {
177 send_user "Setting up target, please wait...\n"
178 }
179 send "target mips $targetname\n"
180 set timeout 60
181 expect {
182 -re "Remote MIPS debugging.*$prompt $" {
183 if $verbose>1 then {
184 send_user "Set target to $targetname\n"
185 }
186 }
187 timeout {
188 error "Couldn't set MIPS target."
189 set timeout 10
05a291bb 190 return -1
31ca3f4c
ILT
191 }
192 }
193 set timeout 10
194}
195
196expect_after {
197 "<return>" { send "\n"; error "Window too small." }
198 -re "\(y or n\) " { send "n\n"; error "Got interactive prompt." }
199 buffer_full { error "internal buffer is full." }
200 eof { error "eof -- pty is hosed." }
201 timeout { error "timeout." }
202 "virtual memory exhausted" { error "virtual memory exhausted." }
203 "Undefined command" { error "send string probably wrong." }
204}
205
206gdb_start
207
208# make sure gdb has actually started, otherwise if the first test
209# timesout, DejaGnu crashes
210send "\n"
211expect {
212 -re "$prompt"
213 }
This page took 0.076882 seconds and 4 git commands to generate.