1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218
|
# Copyright (C) 1988, 1990, 1991, 1992, 1994, 1997 Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
# Please email any bugs, comments, and/or additions to this file to:
# bug-gdb@prep.ai.mit.edu
# This file was written by J.T. Conklin. (jtc@cygnus.com)
load_lib gdb.exp
load_lib remote.exp
global shell_id
global LD
if ![info exists LD] then {
set LD [findfile "$base_dir/../../ld/ld.new"]
}
global NLMCONV
if ![info exists NLMCONV] then {
set NLMCONV [findfile "$base_dir/../../binutils/nlmconv"]
}
#
# gdb_version -- extract and print the version number of gcc
#
proc gdb_version {} {
default_gdb_version
}
#
# gdb_unload -- unload a file if one is loaded
#
#
# gdb_load -- load a file into the debugger.
# return a -1 if anything goes wrong.
#
proc gdb_load { arg } {
global gdb_prompt
global LD
global NLMCONV
global errorCode
global shell_id
# FIXME: this is wrong.
set targetname [target_info name];
set obj [file tail $arg]
set nlm "$obj.nlm"
set lnk "$obj.lnk"
# build *.lnk file
set fd [open $lnk w]
puts $fd "description \"[file tail $nlm]\""
puts $fd "screenname \"System Console\""
puts $fd "module clib.nlm"
puts $fd "module mathlib.nlm"
puts $fd "stack 32768"
# puts $fd "stack 64512"
puts $fd "debug"
# FIXME: don't hardcode location of prelude.o
puts $fd "input /s1/cygnus/dejagnu/i386-netware/lib/prelude.o"
puts $fd "input $arg"
puts $fd "output $nlm"
close $fd
# run nlmconv
verbose "Executing: $NLMCONV -l$LD -T$lnk" 1
catch "exec $NLMCONV -l$LD -T$lnk" output
if ![string match "" $output] then {
verbose $output 1
}
if ![string match "NONE" $errorCode] {
warning "Can't link $arg"
return -1
}
catch "exec rm -f $lnk"
# download
verbose "Downloading $nlm" 1
catch "exec cp $nlm /.NetWare/$targetname.nws/sys.nwv/tmp/x.nlm" output
if ![string match "" $output] then {
verbose $output 1
return -1
}
gdb_file_cmd $nlm
}
proc gdb_run_cmd { } {
global shell_id
global gdb_prompt
global timeout
set connhost [target_info name];
if [board_info $connhost exists serial] {
set serialport [board_info $connhost serial];
} else {
set serialport [board_info $connhost netport];
}
if [board_info $connhost exists baud] {
set baud [board_info $connhost baud];
} else {
set baud 9600;
}
# FIXME: This is wrong.
send "kill\n"
gdb_expect {
-re ".*Kill the program being debugged.*y or n. $" {
send "y\n"
exp_continue
}
-re ".*$gdb_prompt $" {}
}
verbose "Starting GDB stub on [target_info name]" 1
send -i $shell_id "load nlmstub BAUD=$baud x.nlm\r\n"
send "set remotebaud $baud\n"
gdb_expect {
-re "$gdb_prompt" {}
timeout {
perror "Couldn't set remote baud rate"
return
}
}
set otimeout $timeout
set timeout 60
verbose "Timeout is now $timeout seconds" 2
send "target remote $serialport\n"
gdb_expect {
-re "Couldn't establish connection to remote target" {
send "target remote $serialport\n"
exp_continue
}
-re "$gdb_prompt" {}
timeout {
set timeout $otimeout
verbose "Timeout restored to $timeout seconds" 2
perror "Couldn't set remote target"
return
}
}
set timeout $otimeout
verbose "Timeout restored to $timeout seconds" 2
send "continue\n"
gdb_expect {
"Continuing.$" {}
}
return
}
#
# start the remote shell
#
set shell_prompt "Password:"
set shell_id [remote_open target]
if $shell_id<0 then {
warning "Couldn't connect to target"
return -1
}
if [string match "" $passwd] then {
stty -echo
send_user "Password: "
expect_user -re "(.*)\n"
send_user "\n"
set passwd "$expect_out(1,string)"
stty echo
}
send -i $shell_id "$passwd\n"
gdb_expect {
-i $shell_id ":" {
verbose "Got termtype prompt" 0
}
-i $shell_id timeout {
warning "Connection timed out"
return -1
}
}
# FIXME: this is wrong.
set shell_prompt "[string toupper [target_info name]]:"
send -i $shell_id "1\n"
gdb_expect {
-i $shell_id -re "$shell_prompt" {}
-i $shell_id timeout {
warning "Connection timed out"
return -1
}
}
|