]>
Commit | Line | Data |
---|---|---|
a26fa899 FF |
1 | # Copyright (C) 1988, 1990, 1991, 1992, 1994 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 J.T. Conklin. ([email protected]) | |
21 | ||
22 | load_lib gdb.exp | |
23 | load_lib remote.exp | |
24 | ||
25 | global shell_id | |
26 | global passwd | |
27 | ||
28 | global LD | |
29 | if ![info exists LD] then { | |
30 | set LD [findfile "$base_dir/../../ld/ld.new"] | |
31 | } | |
32 | ||
33 | global NLMCONV | |
34 | if ![info exists NLMCONV] then { | |
35 | set NLMCONV [findfile "$base_dir/../../binutils/nlmconv"] | |
36 | } | |
37 | ||
38 | # | |
39 | # gdb_version -- extract and print the version number of gcc | |
40 | # | |
41 | proc gdb_version {} { | |
42 | default_gdb_version | |
43 | } | |
44 | ||
45 | # | |
46 | # gdb_unload -- unload a file if one is loaded | |
47 | # | |
48 | ||
49 | # | |
50 | # gdb_load -- load a file into the debugger. | |
51 | # return a -1 if anything goes wrong. | |
52 | # | |
53 | proc gdb_load { arg } { | |
54 | global prompt | |
55 | global LD | |
56 | global NLMCONV | |
57 | global errorCode | |
58 | global targetname | |
59 | global shell_id | |
60 | ||
61 | set obj [file tail $arg] | |
62 | set nlm "$obj.nlm" | |
63 | set lnk "$obj.lnk" | |
64 | ||
65 | # build *.lnk file | |
66 | set fd [open $lnk w] | |
67 | puts $fd "description \"[file tail $nlm]\"" | |
68 | puts $fd "screenname \"System Console\"" | |
69 | puts $fd "module clib.nlm" | |
70 | puts $fd "module mathlib.nlm" | |
71 | puts $fd "stack 32768" | |
72 | # puts $fd "stack 64512" | |
73 | puts $fd "debug" | |
74 | # FIXME: don't hardcode location of prelude.o | |
75 | puts $fd "input /s1/cygnus/dejagnu/i386-netware/lib/prelude.o" | |
76 | puts $fd "input $arg" | |
77 | puts $fd "output $nlm" | |
78 | close $fd | |
79 | ||
80 | # run nlmconv | |
81 | verbose "Executing: $NLMCONV -l$LD -T$lnk" 1 | |
82 | catch "exec $NLMCONV -l$LD -T$lnk" output | |
83 | if ![string match "" $output] then { | |
84 | verbose $output 1 | |
85 | } | |
86 | if ![string match "NONE" $errorCode] { | |
87 | warning "Can't link $arg" | |
88 | ||
89 | return -1 | |
90 | } | |
91 | catch "exec rm -f $lnk" | |
92 | ||
93 | # download | |
94 | verbose "Downloading $nlm" 1 | |
95 | catch "exec cp $nlm /.NetWare/$targetname.nws/sys.nwv/tmp/x.nlm" output | |
96 | if ![string match "" $output] then { | |
97 | verbose $output 1 | |
98 | return -1 | |
99 | } | |
100 | ||
101 | gdb_file_cmd $nlm | |
102 | } | |
103 | ||
104 | proc gdb_start { } { | |
105 | default_gdb_start | |
106 | } | |
107 | ||
108 | proc gdb_exit { } { | |
109 | catch default_gdb_exit | |
110 | } | |
111 | ||
112 | proc gdb_run_cmd { } { | |
113 | global shell_id | |
114 | global prompt | |
115 | global baud serialport | |
116 | global targetname | |
117 | global timeout | |
118 | ||
119 | send "kill\n" | |
120 | expect { | |
121 | -re ".*Kill the program being debugged.*y or n. $" { | |
122 | send "y\n" | |
123 | exp_continue | |
124 | } | |
125 | -re ".*$prompt $" {} | |
126 | } | |
127 | ||
128 | verbose "Starting GDB stub on $targetname" 1 | |
129 | send -i $shell_id "load nlmstub BAUD=$baud x.nlm\r\n" | |
130 | ||
131 | send "set remotebaud $baud\n" | |
132 | expect { | |
133 | -re "$prompt" {} | |
134 | timeout { | |
135 | perror "Couldn't set remote baud rate" | |
136 | return | |
137 | } | |
138 | } | |
139 | ||
140 | set otimeout $timeout | |
141 | set timeout 60 | |
142 | verbose "Timeout is now $timeout seconds" 2 | |
143 | send "target remote $serialport\n" | |
144 | expect { | |
145 | -re "Couldn't establish connection to remote target" { | |
146 | send "target remote $serialport\n" | |
147 | exp_continue | |
148 | } | |
149 | -re "$prompt" {} | |
150 | timeout { | |
151 | perror "Couldn't set remote target" | |
152 | return | |
153 | } | |
154 | } | |
155 | set timeout $otimeout | |
156 | verbose "Timeout is now $timeout seconds" 2 | |
157 | ||
158 | send "continue\n" | |
159 | expect { | |
160 | "Continuing.$" {} | |
161 | } | |
162 | ||
163 | return | |
164 | } | |
165 | ||
166 | ||
167 | ||
168 | # | |
169 | # start the remote shell | |
170 | # | |
171 | ||
172 | set shell_prompt "Password:" | |
173 | set shell_id [ eval $connectmode "$targetname" ] | |
174 | ||
175 | if $shell_id<0 then { | |
176 | warning "Couldn't connect to target" | |
177 | return -1 | |
178 | } | |
179 | ||
180 | if [string match "" $passwd] then { | |
181 | stty -echo | |
182 | send_user "Password: " | |
183 | expect_user -re "(.*)\n" | |
184 | send_user "\n" | |
185 | set passwd "$expect_out(1,string)" | |
186 | stty echo | |
187 | } | |
188 | ||
189 | send -i $shell_id "$passwd\n" | |
190 | expect { | |
191 | -i $shell_id ":" { | |
192 | verbose "Got termtype prompt" 0 | |
193 | } | |
194 | ||
195 | -i $shell_id timeout { | |
196 | warning "Connection timed out" | |
197 | return -1 | |
198 | } | |
199 | } | |
200 | ||
201 | ||
202 | set shell_prompt "[string toupper $targetname]:" | |
203 | send -i $shell_id "1\n" | |
204 | ||
205 | expect { | |
206 | -i $shell_id -re "$shell_prompt" {} | |
207 | -i $shell_id timeout { | |
208 | warning "Connection timed out" | |
209 | return -1 | |
210 | } | |
211 | } | |
212 | ||
213 | gdb_start |