]> Git Repo - binutils.git/blob - gdb/testsuite/config/udi-gdb.exp
Just a little cleanup. Made gdb_exit "kill" any isstip's still running
[binutils.git] / gdb / testsuite / config / udi-gdb.exp
1 # Test Framework Driver for GDB driving Universal Debug Interface on 29K
2 #   Copyright 1988, 1990, 1991, 1992, 1993 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[email protected]
20
21 # This file was written by Rob Savoye. ([email protected])
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 load_lib gdb.exp
35
36 #
37 # gdb_version -- extract and print the version number of gdb
38 #
39 proc gdb_version {} {
40     default_gdb_version
41 }
42
43 #
44 # gdb_load -- load a file into the GDB. 
45 #             Returns a 0 if there was an error,
46 #                       1 if it load successfully.
47 #
48 proc gdb_load { arg } {
49     global verbose
50     global loadpath
51     global loadfile
52     global prompt
53     global spawn_id
54     global GDB
55     global expect_out
56
57     send "load $arg\n"
58     verbose "Loading $arg into $GDB"
59     expect {
60         -re "Loading.*\.text.*\.data.*\.bss.*Reading symbols from $arg.+done.*$prompt $" {
61             verbose "Loaded $arg into $GDB"
62             return 1
63         }
64         -re "$prompt $" {
65             error "Couldn't load $arg into $GDB."
66             return 0
67         }
68         timeout {
69                 error "Timed out trying to load $arg."
70             return 0
71         }
72     }
73     if [info exists expect_out(buffer)] then {
74         send_log $expect_out(buffer)
75     }
76     return 0
77 }
78
79 #
80 # gdb_target_udi
81 # Set gdb to the desired UDI target
82 #
83 proc gdb_target_udi { } {
84     global targetname
85     global prompt
86     global verbose
87     global exit_status
88
89     # set targets hostname
90     send "target udi $targetname\n"
91     set timeout 60
92     expect {
93         -re "target udi $targetname\[\r\n\]+" {
94             continue -expect
95         }
96         -re "TIP UDI 1.2 Conformant.*$prompt $" {
97             verbose "Set target to $targetname"
98         }
99         -re "TIP-ipc WARNING,.*failed:" {
100             warning "$expect_out(buffer)"
101         }
102         -re "TIP-ipc ERROR,.*failed:" {
103             error "$expect_out(buffer)"
104         }
105         -re "A program is being debugged already.  Kill it\? \(y or n\)" {
106             send "y\n"
107             continue -expect
108         }
109         timeout { 
110             error "Couldn't set target for UDI."
111             cleanup
112             exit $exit_status
113         }
114     }
115     set timeout 10
116 }
117
118 #
119 # gdb_start -- start GDB running. This assumes that there the
120 #              UDICONF enviroment variable is set.
121 #
122 proc gdb_start { } {
123     global GDB
124     global GDBFLAGS
125     global spawn_id
126     global prompt
127     global verbose
128
129     set GDB [which $GDB]
130     # start GDB
131     if [ llength $GDBFLAGS ] then {
132         spawn $GDB $GDBFLAGS
133     } else {
134         spawn $GDB
135     }
136     expect  {
137         -re "GDB.*$prompt $"   {
138             verbose "$GDB initialized for cross mode\n"
139         }
140         -re "$prompt $" {
141             error "GDB never initialized."
142             return -1
143         }
144         timeout {
145             error "(timeout) GDB never initialized."    
146             return -1
147         }
148     }
149
150     # force the height to "unlimited", so no pagers get used
151     send "set height 0\n"
152     expect -re ".*$prompt $" {}
153     # force the width to "unlimited", so no wraparound occurs
154     send "set width 0\n"
155     expect -re ".*$prompt $" {}
156     # set the default arguments to "main", so that "run" with no
157     # arguments will work correctly.
158     send "set args main\n"
159     expect -re ".*$prompt $" {}
160
161     verbose "Setting up target, Please wait..."
162
163     gdb_target_udi
164 }
165
166 #
167 # gdb_exit -- exit gdb
168 #
169 proc gdb_exit { } {
170     slay isstip
171     catch default_gdb_exit
172     set in [open [concat "|ls -F"] r]
173     while {[gets $in line]>-1} {
174         if [regexp "=$" $line] then {
175             set line [string trimright $line "="]
176             verbose "Removing the $line named socket"
177             exec rm -f $line
178         }
179     }
180     close $in
181 }
182
183 gdb_start
184
185 # make sure gdb has actually started, otherwise if the first test
186 # timesout, DejaGnu crashes
187 send "\n"
188 expect {
189     -re "$prompt"
190     }
This page took 0.031954 seconds and 4 git commands to generate.