1 # Copyright (C) 1988, 1990, 1991, 1992, 1994 Free Software Foundation, Inc.
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.
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.
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. */
17 # Please email any bugs, comments, and/or additions to this file to:
18 # bug-gdb@prep.ai.mit.edu
20 # This file was written by J.T. Conklin. (jtc@cygnus.com)
29 if ![info exists LD] then {
30 set LD [findfile "$base_dir/../../ld/ld.new"]
34 if ![info exists NLMCONV] then {
35 set NLMCONV [findfile "$base_dir/../../binutils/nlmconv"]
39 # gdb_version -- extract and print the version number of gcc
46 # gdb_unload -- unload a file if one is loaded
50 # gdb_load -- load a file into the debugger.
51 # return a -1 if anything goes wrong.
53 proc gdb_load { arg } {
61 set obj [file tail $arg]
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"
74 # FIXME: don't hardcode location of prelude.o
75 puts $fd "input /s1/cygnus/dejagnu/i386-netware/lib/prelude.o"
77 puts $fd "output $nlm"
81 verbose "Executing: $NLMCONV -l$LD -T$lnk" 1
82 catch "exec $NLMCONV -l$LD -T$lnk" output
83 if ![string match "" $output] then {
86 if ![string match "NONE" $errorCode] {
87 warning "Can't link $arg"
91 catch "exec rm -f $lnk"
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 {
109 catch default_gdb_exit
112 proc gdb_run_cmd { } {
115 global baud serialport
121 -re ".*Kill the program being debugged.*y or n. $" {
128 verbose "Starting GDB stub on $targetname" 1
129 send -i $shell_id "load nlmstub BAUD=$baud x.nlm\r\n"
131 send "set remotebaud $baud\n"
135 perror "Couldn't set remote baud rate"
140 set otimeout $timeout
142 verbose "Timeout is now $timeout seconds" 2
143 send "target remote $serialport\n"
145 -re "Couldn't establish connection to remote target" {
146 send "target remote $serialport\n"
151 perror "Couldn't set remote target"
155 set timeout $otimeout
156 verbose "Timeout is now $timeout seconds" 2
169 # start the remote shell
172 set shell_prompt "Password:"
173 set shell_id [ eval $connectmode "$targetname" ]
175 if $shell_id<0 then {
176 warning "Couldn't connect to target"
180 if [string match "" $passwd] then {
182 send_user "Password: "
183 expect_user -re "(.*)\n"
185 set passwd "$expect_out(1,string)"
189 send -i $shell_id "$passwd\n"
192 verbose "Got termtype prompt" 0
195 -i $shell_id timeout {
196 warning "Connection timed out"
202 set shell_prompt "[string toupper $targetname]:"
203 send -i $shell_id "1\n"
206 -i $shell_id -re "$shell_prompt" {}
207 -i $shell_id timeout {
208 warning "Connection timed out"