1 # Copyright (C) 1988, 1990, 1991, 1992, 1994, 1997, 2007
2 # Free Software Foundation, Inc.
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.
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.
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.
18 # Please email any bugs, comments, and/or additions to this file to:
19 # bug-gdb@prep.ai.mit.edu
21 # 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 } {
60 # FIXME: this is wrong.
61 set targetname [target_info name];
63 set obj [file tail $arg]
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"
76 # FIXME: don't hardcode location of prelude.o
77 puts $fd "input /s1/cygnus/dejagnu/i386-netware/lib/prelude.o"
79 puts $fd "output $nlm"
83 verbose "Executing: $NLMCONV -l$LD -T$lnk" 1
84 catch "exec $NLMCONV -l$LD -T$lnk" output
85 if ![string match "" $output] then {
88 if ![string match "NONE" $errorCode] {
89 warning "Can't link $arg"
93 catch "exec rm -f $lnk"
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 {
106 proc gdb_run_cmd { } {
111 set connhost [target_info name];
112 if [board_info $connhost exists serial] {
113 set serialport [board_info $connhost serial];
115 set serialport [board_info $connhost netport];
118 if [board_info $connhost exists baud] {
119 set baud [board_info $connhost baud];
123 # FIXME: This is wrong.
126 -re ".*Kill the program being debugged.*y or n. $" {
130 -re ".*$gdb_prompt $" {}
133 verbose "Starting GDB stub on [target_info name]" 1
134 send -i $shell_id "load nlmstub BAUD=$baud x.nlm\r\n"
136 send "set remotebaud $baud\n"
140 perror "Couldn't set remote baud rate"
145 set otimeout $timeout
147 verbose "Timeout is now $timeout seconds" 2
148 send "target remote $serialport\n"
150 -re "Couldn't establish connection to remote target" {
151 send "target remote $serialport\n"
156 set timeout $otimeout
157 verbose "Timeout restored to $timeout seconds" 2
158 perror "Couldn't set remote target"
162 set timeout $otimeout
163 verbose "Timeout restored to $timeout seconds" 2
176 # start the remote shell
179 set shell_prompt "Password:"
180 set shell_id [remote_open target]
182 if $shell_id<0 then {
183 warning "Couldn't connect to target"
187 if [string match "" $passwd] then {
189 send_user "Password: "
190 expect_user -re "(.*)\n"
192 set passwd "$expect_out(1,string)"
196 send -i $shell_id "$passwd\n"
199 verbose "Got termtype prompt" 0
202 -i $shell_id timeout {
203 warning "Connection timed out"
209 # FIXME: this is wrong.
210 set shell_prompt "[string toupper [target_info name]]:"
211 send -i $shell_id "1\n"
214 -i $shell_id -re "$shell_prompt" {}
215 -i $shell_id timeout {
216 warning "Connection timed out"