]>
Commit | Line | Data |
---|---|---|
7a7d682b JG |
1 | # Test Framework Driver for GDB driving Universal Debug Interface on 29K |
2 | # Copyright 1988, 1990, 1991, 1992, 1993 Free Software Foundation, Inc. | |
3 | # | |
19fa4a0a MW |
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 | ||
41a85720 | 34 | load_lib gdb.exp |
e4d30c7e | 35 | load_lib udi.exp |
41a85720 | 36 | |
19fa4a0a MW |
37 | # |
38 | # gdb_version -- extract and print the version number of gdb | |
39 | # | |
40 | proc gdb_version {} { | |
41a85720 | 41 | default_gdb_version |
19fa4a0a MW |
42 | } |
43 | ||
5f2912cc ILT |
44 | # |
45 | # gdb_target_udi | |
46 | # Set gdb to the desired UDI target | |
47 | # | |
48 | proc gdb_target_udi { } { | |
49 | global targetname | |
50 | global prompt | |
51 | global verbose | |
653ae28f | 52 | global exit_status |
5f2912cc ILT |
53 | |
54 | # set targets hostname | |
55 | send "target udi $targetname\n" | |
56 | set timeout 60 | |
57 | expect { | |
41a85720 RS |
58 | -re "target udi $targetname\[\r\n\]+" { |
59 | continue -expect | |
60 | } | |
5f2912cc | 61 | -re "TIP UDI 1.2 Conformant.*$prompt $" { |
41a85720 RS |
62 | verbose "Set target to $targetname" |
63 | } | |
64 | -re "TIP-ipc WARNING,.*failed:" { | |
65 | warning "$expect_out(buffer)" | |
66 | } | |
67 | -re "TIP-ipc ERROR,.*failed:" { | |
68 | error "$expect_out(buffer)" | |
5f2912cc ILT |
69 | } |
70 | -re "A program is being debugged already. Kill it\? \(y or n\)" { | |
71 | send "y\n" | |
72 | continue -expect | |
73 | } | |
74 | timeout { | |
75 | error "Couldn't set target for UDI." | |
653ae28f FF |
76 | cleanup |
77 | exit $exit_status | |
5f2912cc ILT |
78 | } |
79 | } | |
80 | set timeout 10 | |
19fa4a0a MW |
81 | } |
82 | ||
2558ba5d JK |
83 | # |
84 | # gdb_load -- load a file into the debugger. | |
85 | # return a -1 if anything goes wrong. | |
86 | # | |
87 | proc gdb_load { arg } { | |
88 | global verbose | |
89 | global loadpath | |
90 | global loadfile | |
91 | global GDB | |
92 | global prompt | |
93 | ||
94 | if [gdb_file_cmd $arg] then { return -1 } | |
95 | ||
96 | gdb_target_udi | |
97 | } | |
98 | ||
19fa4a0a MW |
99 | # |
100 | # gdb_start -- start GDB running. This assumes that there the | |
101 | # UDICONF enviroment variable is set. | |
102 | # | |
103 | proc gdb_start { } { | |
104 | global GDB | |
105 | global GDBFLAGS | |
106 | global spawn_id | |
107 | global prompt | |
108 | global verbose | |
19fa4a0a MW |
109 | |
110 | set GDB [which $GDB] | |
111 | # start GDB | |
112 | if [ llength $GDBFLAGS ] then { | |
113 | spawn $GDB $GDBFLAGS | |
114 | } else { | |
115 | spawn $GDB | |
116 | } | |
117 | expect { | |
118 | -re "GDB.*$prompt $" { | |
41a85720 RS |
119 | verbose "$GDB initialized for cross mode\n" |
120 | } | |
121 | -re "$prompt $" { | |
122 | error "GDB never initialized." | |
123 | return -1 | |
124 | } | |
125 | timeout { | |
126 | error "(timeout) GDB never initialized." | |
127 | return -1 | |
19fa4a0a | 128 | } |
19fa4a0a MW |
129 | } |
130 | ||
131 | # force the height to "unlimited", so no pagers get used | |
132 | send "set height 0\n" | |
133 | expect -re ".*$prompt $" {} | |
134 | # force the width to "unlimited", so no wraparound occurs | |
135 | send "set width 0\n" | |
136 | expect -re ".*$prompt $" {} | |
19fa4a0a | 137 | |
41a85720 | 138 | verbose "Setting up target, Please wait..." |
5f2912cc ILT |
139 | |
140 | gdb_target_udi | |
19fa4a0a MW |
141 | } |
142 | ||
41a85720 RS |
143 | # |
144 | # gdb_exit -- exit gdb | |
145 | # | |
146 | proc gdb_exit { } { | |
147 | slay isstip | |
148 | catch default_gdb_exit | |
149 | set in [open [concat "|ls -F"] r] | |
150 | while {[gets $in line]>-1} { | |
151 | if [regexp "=$" $line] then { | |
152 | set line [string trimright $line "="] | |
153 | verbose "Removing the $line named socket" | |
154 | exec rm -f $line | |
155 | } | |
156 | } | |
157 | close $in | |
19fa4a0a MW |
158 | } |
159 | ||
19fa4a0a MW |
160 | gdb_start |
161 | ||
162 | # make sure gdb has actually started, otherwise if the first test | |
163 | # timesout, DejaGnu crashes | |
164 | send "\n" | |
165 | expect { | |
166 | -re "$prompt" | |
167 | } |