* Redid configuration scheme. Removed gdb.t*/configure.in.
[deliverable/binutils-gdb.git] / gdb / testsuite / config / udi-gdb.exp
1 # Test Framework Driver
2 # Copyright (C) 1988, 1990, 1991, 1992 Free Software Foundation, Inc.
3
4 # This program is free software; you can redistribute it and/or modify
5 # it under the terms of the GNU General Public License as published by
6 # the Free Software Foundation; either version 2 of the License, or
7 # (at your option) any later version.
8 #
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
13 #
14 # You should have received a copy of the GNU General Public License
15 # along with this program; if not, write to the Free Software
16 # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
17
18 # Please email any bugs, comments, and/or additions to this file to:
19 # DejaGnu@cygnus.com
20
21 # This file was written by Rob Savoye. (rob@cygnus.com)
22
23 #
24 # NOTE: these test assume that there is a udi_soc file in th
25 #
26
27 # these need to be initialized only if site.exp doesn't set them
28 set prompt "\(gdb\)"
29
30 if ![info exists prompt] then {
31 set prompt "\(gdb\)"
32 }
33
34 #
35 # gdb_version -- extract and print the version number of gdb
36 #
37 proc gdb_version {} {
38 global GDB
39 global GDBFLAGS
40 global prompt
41 set tmp [exec echo "q" | $GDB]
42 set version [lindex $tmp [lsearch $tmp "\[0-9\]*"]]
43 set version [string range $version 0 [expr [string length $version]-2]]
44 clone_output "[which $GDB] version $version $GDBFLAGS\n"
45 }
46
47 #
48 # gdb_load -- load a file into the GDB.
49 # Returns a 0 if there was an error,
50 # 1 if it load successfully.
51 #
52 proc gdb_load { arg } {
53 global verbose
54 global loadpath
55 global loadfile
56 global prompt
57 global spawn_id
58 global GDB
59 global expect_out
60
61 send "load $arg\n"
62 if $verbose>1 then {
63 send_user "Loading $arg into $GDB\n"
64 }
65 expect {
66 -re "Loading.*\.text.*\.data.*\.bss.*Reading symbols from $arg.+done.*$prompt $" {
67 if $verbose>1 then {
68 send_user "Loaded $arg into $GDB\n"
69 }
70 return 1
71 }
72 -re "$prompt $" {
73 if $verbose>1 then {
74 error "GDB couldn't load."
75 }
76 }
77 timeout {
78 if $verbose>1 then {
79 error "Timed out trying to load $arg."
80 }
81 }
82 }
83 if [info exists expect_out(buffer)] then {
84 send_log $expect_out(buffer)
85 }
86 return 0
87 }
88
89 #
90 # gdb_exit -- exit the GDB
91 #
92 proc gdb_exit {} {
93 global GDB
94 global GDBFLAGS
95 global verbose
96
97 set timeout 5
98 send "quit\n"
99 expect {
100 eof {
101 if $verbose>1 then {
102 send_user "Got EOF from $GDB\n"
103 }
104 }
105 timeout {
106 if $verbose>1 then {
107 send_user "Got TIMEOUT from $GDB\n"
108 }
109 }
110 -re "The program is running. Quit anyway? (y or n) $"\
111 { send "y\n"
112 if $verbose>1 then {
113 send_user "\t\tKilling program being debugged\n"
114 }
115 }
116 }
117 if $verbose>1 then {
118 send_user "Quitting $GDB $GDBFLAGS\n"
119 }
120 close
121 }
122
123 #
124 # gdb_start -- start GDB running. This assumes that there the
125 # UDICONF enviroment variable is set.
126 #
127 proc gdb_start { } {
128 global GDB
129 global GDBFLAGS
130 global spawn_id
131 global prompt
132 global verbose
133 global targetname
134
135 set GDB [which $GDB]
136 # start GDB
137 if [ llength $GDBFLAGS ] then {
138 spawn $GDB $GDBFLAGS
139 } else {
140 spawn $GDB
141 }
142 expect {
143 -re "GDB.*$prompt $" {
144 if $verbose>1 then {
145 send_user "$GDB initialized for cross mode\n\n"
146 }
147 }
148 -re "$prompt $" { error "GDB never initialized."; alldone }
149 timeout { error "(timeout) GDB never initialized.";
150 alldone }
151 }
152
153 # force the height to "unlimited", so no pagers get used
154 send "set height 0\n"
155 expect -re ".*$prompt $" {}
156 # force the width to "unlimited", so no wraparound occurs
157 send "set width 0\n"
158 expect -re ".*$prompt $" {}
159 # set the default arguments to "main", so that "run" with no
160 # arguments will work correctly.
161 send "set args main\n"
162 expect -re ".*$prompt $" {}
163
164 if $verbose>1 then {
165 send_user "Setting up target, Please wait...\n"
166 }
167 catch "exec rm [glob -nocomplain *_soc]"
168 catch "exec rm [glob -nocomplain /tmp/*_soc]"
169 # set targets hostname
170 send "target udi $targetname\n"
171 set timeout 60
172 expect {
173 -re "target udi.*TIP UDI 1.2 Conformant.*$prompt $" {
174 if $verbose>1 then {
175 send_user "Set target to $targetname\n"
176 }
177 }
178 timeout {
179 error "Couldn't set target for vxworks."
180 set timeout 10
181 alldone
182 }
183 }
184 set timeout 10
185 }
186
187 expect_after {
188 "<return>" { send "\n"; clone_output "ERROR: Window too small." }
189 -re "\(y or n\) " { send "n\n"; error "Got interactive prompt." }
190 buffer_full { error "internal buffer is full." }
191 eof { error "eof -- pty is hosed." }
192 timeout { error "timeout." }
193 "virtual memory exhausted" { error "virtual memory exhausted." }
194 "Undefined command" { error "send string probably wrong." }
195 }
196
197 load_lib gdb.exp
198
199 gdb_start
200
201 # make sure gdb has actually started, otherwise if the first test
202 # timesout, DejaGnu crashes
203 send "\n"
204 expect {
205 -re "$prompt"
206 }
This page took 0.036543 seconds and 4 git commands to generate.