]> Git Repo - binutils.git/blob - gdb/testsuite/config/mips-gdb.exp
* lib/gdb.exp (gdb_test_exact): Turn \n in pattern into \r\n.
[binutils.git] / gdb / testsuite / config / mips-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[email protected]
19
20 # This file was written by Ian Lance Taylor <[email protected]>.
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 "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 mips $targetname\n"
79     set timeout 60
80     verbose "Timeout is now $timeout seconds" 2
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
90             verbose "Timeout is now $timeout seconds" 2
91             return -1
92         }
93     }
94     
95     send "load $arg\n"
96     if $verbose>1 then {
97         send_user "Loading $arg into $GDB\n"
98     }
99     set timeout 2400
100     verbose "Timeout is now $timeout seconds" 2
101     expect {
102         -re "Loading.*$prompt $" {
103             if $verbose>1 then {
104                 send_user "Loaded $arg into $GDB\n"
105             }
106             set timeout 30
107             verbose "Timeout is now $timeout seconds" 2
108         }
109         -re "$prompt $"     {
110             if $verbose>1 then {
111                  perror "GDB couldn't load."
112             }
113         }
114         timeout {
115             if $verbose>1 then {
116                  perror "Timed out trying to load $arg."
117             }
118         }
119     }
120     set timeout 10
121     verbose "Timeout is now $timeout seconds" 2
122     if [info exists expect_out(buffer)] then {
123         send_log $expect_out(buffer)
124     }
125     return 0
126 }
127
128 #
129 # gdb_start -- start GDB running.
130 #
131 proc 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         }
151         set shell_id [ eval $connectmode "$targetname" ]
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 {
160                  perror "(timeout) board did not come up."; return -1
161                     }
162                 }
163             }
164         }
165         send -i $shell_id "go 0xbfc00000\n"
166         expect {
167             -i $shell_id -re "<IDT>$" { }
168             timeout     { perror "(timeout) board did not come up."; return -1 }
169         }
170         verbose "about to exit kermit"
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  {
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
192         }
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
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
212 #    verbose "Timeout is now $timeout seconds" 2
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
222 #           verbose "Timeout is now $timeout seconds" 2
223 #           return -1
224 #       }
225 #    }
226     set timeout 10
227     verbose "Timeout is now $timeout seconds" 2
228 }
229
230 expect_after {
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." }
238 }
239
240 proc gdb_exit { } {
241     catch default_gdb_exit
242 }
243
244 gdb_start
245
246 # make sure gdb has actually started, otherwise if the first test
247 # timesout, DejaGnu crashes
248 send "\n"
249 expect {
250     -re "$prompt"
251     }
This page took 0.038399 seconds and 4 git commands to generate.