]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - gdb/testsuite/config/netware.exp
Copyright updates for 2007.
[thirdparty/binutils-gdb.git] / gdb / testsuite / config / netware.exp
CommitLineData
6aba47ca
DJ
1# Copyright (C) 1988, 1990, 1991, 1992, 1994, 1997, 2007
2# Free Software Foundation, Inc.
c906108c
SS
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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17
18# Please email any bugs, comments, and/or additions to this file to:
19# bug-gdb@prep.ai.mit.edu
20
21# This file was written by J.T. Conklin. (jtc@cygnus.com)
22
23load_lib gdb.exp
24load_lib remote.exp
25
26global shell_id
27
28global LD
29if ![info exists LD] then {
30 set LD [findfile "$base_dir/../../ld/ld.new"]
31}
32
33global NLMCONV
34if ![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#
41proc 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#
53proc gdb_load { arg } {
54 global gdb_prompt
55 global LD
56 global NLMCONV
57 global errorCode
58 global shell_id
59
60 # FIXME: this is wrong.
61 set targetname [target_info name];
62
63 set obj [file tail $arg]
64 set nlm "$obj.nlm"
65 set lnk "$obj.lnk"
66
67 # build *.lnk file
68 set fd [open $lnk w]
69 puts $fd "description \"[file tail $nlm]\""
70 puts $fd "screenname \"System Console\""
71 puts $fd "module clib.nlm"
72 puts $fd "module mathlib.nlm"
73 puts $fd "stack 32768"
74# puts $fd "stack 64512"
75 puts $fd "debug"
76 # FIXME: don't hardcode location of prelude.o
77 puts $fd "input /s1/cygnus/dejagnu/i386-netware/lib/prelude.o"
78 puts $fd "input $arg"
79 puts $fd "output $nlm"
80 close $fd
81
82 # run nlmconv
83 verbose "Executing: $NLMCONV -l$LD -T$lnk" 1
84 catch "exec $NLMCONV -l$LD -T$lnk" output
85 if ![string match "" $output] then {
86 verbose $output 1
87 }
88 if ![string match "NONE" $errorCode] {
89 warning "Can't link $arg"
90
91 return -1
92 }
93 catch "exec rm -f $lnk"
94
95 # download
96 verbose "Downloading $nlm" 1
97 catch "exec cp $nlm /.NetWare/$targetname.nws/sys.nwv/tmp/x.nlm" output
98 if ![string match "" $output] then {
99 verbose $output 1
100 return -1
101 }
102
103 gdb_file_cmd $nlm
104}
105
106proc gdb_run_cmd { } {
107 global shell_id
108 global gdb_prompt
109 global timeout
110
111 set connhost [target_info name];
112 if [board_info $connhost exists serial] {
113 set serialport [board_info $connhost serial];
114 } else {
115 set serialport [board_info $connhost netport];
116 }
117
118 if [board_info $connhost exists baud] {
119 set baud [board_info $connhost baud];
120 } else {
121 set baud 9600;
122 }
123 # FIXME: This is wrong.
124 send "kill\n"
125 gdb_expect {
126 -re ".*Kill the program being debugged.*y or n. $" {
127 send "y\n"
128 exp_continue
129 }
130 -re ".*$gdb_prompt $" {}
131 }
132
133 verbose "Starting GDB stub on [target_info name]" 1
134 send -i $shell_id "load nlmstub BAUD=$baud x.nlm\r\n"
135
136 send "set remotebaud $baud\n"
137 gdb_expect {
138 -re "$gdb_prompt" {}
139 timeout {
140 perror "Couldn't set remote baud rate"
141 return
142 }
143 }
144
145 set otimeout $timeout
146 set timeout 60
147 verbose "Timeout is now $timeout seconds" 2
148 send "target remote $serialport\n"
149 gdb_expect {
150 -re "Couldn't establish connection to remote target" {
151 send "target remote $serialport\n"
152 exp_continue
153 }
154 -re "$gdb_prompt" {}
155 timeout {
156 set timeout $otimeout
157 verbose "Timeout restored to $timeout seconds" 2
158 perror "Couldn't set remote target"
159 return
160 }
161 }
162 set timeout $otimeout
163 verbose "Timeout restored to $timeout seconds" 2
164
165 send "continue\n"
166 gdb_expect {
167 "Continuing.$" {}
168 }
169
170 return
171}
172
173
174
175#
176# start the remote shell
177#
178
179set shell_prompt "Password:"
180set shell_id [remote_open target]
181
182if $shell_id<0 then {
183 warning "Couldn't connect to target"
184 return -1
185}
186
187if [string match "" $passwd] then {
188 stty -echo
189 send_user "Password: "
190 expect_user -re "(.*)\n"
191 send_user "\n"
192 set passwd "$expect_out(1,string)"
193 stty echo
194}
195
196send -i $shell_id "$passwd\n"
197gdb_expect {
198 -i $shell_id ":" {
199 verbose "Got termtype prompt" 0
200 }
201
202 -i $shell_id timeout {
203 warning "Connection timed out"
204 return -1
205 }
206}
207
208
209# FIXME: this is wrong.
210set shell_prompt "[string toupper [target_info name]]:"
211send -i $shell_id "1\n"
212
213gdb_expect {
214 -i $shell_id -re "$shell_prompt" {}
215 -i $shell_id timeout {
216 warning "Connection timed out"
217 return -1
218 }
219}