# Copyright (C) 1988, 1990, 1991, 1992, 1994, 1997 Free Software Foundation, Inc.
|
# Copyright (C) 1988, 1990, 1991, 1992, 1994, 1997 Free Software Foundation, Inc.
|
|
|
# This program is free software; you can redistribute it and/or modify
|
# 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
|
# it under the terms of the GNU General Public License as published by
|
# the Free Software Foundation; either version 2 of the License, or
|
# the Free Software Foundation; either version 2 of the License, or
|
# (at your option) any later version.
|
# (at your option) any later version.
|
#
|
#
|
# This program is distributed in the hope that it will be useful,
|
# This program is distributed in the hope that it will be useful,
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
# GNU General Public License for more details.
|
# GNU General Public License for more details.
|
#
|
#
|
# You should have received a copy of the GNU General Public License
|
# You should have received a copy of the GNU General Public License
|
# along with this program; if not, write to the Free Software
|
# along with this program; if not, write to the Free Software
|
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
|
# Please email any bugs, comments, and/or additions to this file to:
|
# Please email any bugs, comments, and/or additions to this file to:
|
# bug-gdb@prep.ai.mit.edu
|
# bug-gdb@prep.ai.mit.edu
|
|
|
# This file was written by J.T. Conklin. (jtc@cygnus.com)
|
# This file was written by J.T. Conklin. (jtc@cygnus.com)
|
|
|
load_lib gdb.exp
|
load_lib gdb.exp
|
load_lib remote.exp
|
load_lib remote.exp
|
|
|
global shell_id
|
global shell_id
|
|
|
global LD
|
global LD
|
if ![info exists LD] then {
|
if ![info exists LD] then {
|
set LD [findfile "$base_dir/../../ld/ld.new"]
|
set LD [findfile "$base_dir/../../ld/ld.new"]
|
}
|
}
|
|
|
global NLMCONV
|
global NLMCONV
|
if ![info exists NLMCONV] then {
|
if ![info exists NLMCONV] then {
|
set NLMCONV [findfile "$base_dir/../../binutils/nlmconv"]
|
set NLMCONV [findfile "$base_dir/../../binutils/nlmconv"]
|
}
|
}
|
|
|
#
|
#
|
# gdb_version -- extract and print the version number of gcc
|
# gdb_version -- extract and print the version number of gcc
|
#
|
#
|
proc gdb_version {} {
|
proc gdb_version {} {
|
default_gdb_version
|
default_gdb_version
|
}
|
}
|
|
|
#
|
#
|
# gdb_unload -- unload a file if one is loaded
|
# gdb_unload -- unload a file if one is loaded
|
#
|
#
|
|
|
#
|
#
|
# gdb_load -- load a file into the debugger.
|
# gdb_load -- load a file into the debugger.
|
# return a -1 if anything goes wrong.
|
# return a -1 if anything goes wrong.
|
#
|
#
|
proc gdb_load { arg } {
|
proc gdb_load { arg } {
|
global gdb_prompt
|
global gdb_prompt
|
global LD
|
global LD
|
global NLMCONV
|
global NLMCONV
|
global errorCode
|
global errorCode
|
global shell_id
|
global shell_id
|
|
|
# FIXME: this is wrong.
|
# FIXME: this is wrong.
|
set targetname [target_info name];
|
set targetname [target_info name];
|
|
|
set obj [file tail $arg]
|
set obj [file tail $arg]
|
set nlm "$obj.nlm"
|
set nlm "$obj.nlm"
|
set lnk "$obj.lnk"
|
set lnk "$obj.lnk"
|
|
|
# build *.lnk file
|
# build *.lnk file
|
set fd [open $lnk w]
|
set fd [open $lnk w]
|
puts $fd "description \"[file tail $nlm]\""
|
puts $fd "description \"[file tail $nlm]\""
|
puts $fd "screenname \"System Console\""
|
puts $fd "screenname \"System Console\""
|
puts $fd "module clib.nlm"
|
puts $fd "module clib.nlm"
|
puts $fd "module mathlib.nlm"
|
puts $fd "module mathlib.nlm"
|
puts $fd "stack 32768"
|
puts $fd "stack 32768"
|
# puts $fd "stack 64512"
|
# puts $fd "stack 64512"
|
puts $fd "debug"
|
puts $fd "debug"
|
# FIXME: don't hardcode location of prelude.o
|
# FIXME: don't hardcode location of prelude.o
|
puts $fd "input /s1/cygnus/dejagnu/i386-netware/lib/prelude.o"
|
puts $fd "input /s1/cygnus/dejagnu/i386-netware/lib/prelude.o"
|
puts $fd "input $arg"
|
puts $fd "input $arg"
|
puts $fd "output $nlm"
|
puts $fd "output $nlm"
|
close $fd
|
close $fd
|
|
|
# run nlmconv
|
# run nlmconv
|
verbose "Executing: $NLMCONV -l$LD -T$lnk" 1
|
verbose "Executing: $NLMCONV -l$LD -T$lnk" 1
|
catch "exec $NLMCONV -l$LD -T$lnk" output
|
catch "exec $NLMCONV -l$LD -T$lnk" output
|
if ![string match "" $output] then {
|
if ![string match "" $output] then {
|
verbose $output 1
|
verbose $output 1
|
}
|
}
|
if ![string match "NONE" $errorCode] {
|
if ![string match "NONE" $errorCode] {
|
warning "Can't link $arg"
|
warning "Can't link $arg"
|
|
|
return -1
|
return -1
|
}
|
}
|
catch "exec rm -f $lnk"
|
catch "exec rm -f $lnk"
|
|
|
# download
|
# download
|
verbose "Downloading $nlm" 1
|
verbose "Downloading $nlm" 1
|
catch "exec cp $nlm /.NetWare/$targetname.nws/sys.nwv/tmp/x.nlm" output
|
catch "exec cp $nlm /.NetWare/$targetname.nws/sys.nwv/tmp/x.nlm" output
|
if ![string match "" $output] then {
|
if ![string match "" $output] then {
|
verbose $output 1
|
verbose $output 1
|
return -1
|
return -1
|
}
|
}
|
|
|
gdb_file_cmd $nlm
|
gdb_file_cmd $nlm
|
}
|
}
|
|
|
proc gdb_run_cmd { } {
|
proc gdb_run_cmd { } {
|
global shell_id
|
global shell_id
|
global gdb_prompt
|
global gdb_prompt
|
global timeout
|
global timeout
|
|
|
set connhost [target_info name];
|
set connhost [target_info name];
|
if [board_info $connhost exists serial] {
|
if [board_info $connhost exists serial] {
|
set serialport [board_info $connhost serial];
|
set serialport [board_info $connhost serial];
|
} else {
|
} else {
|
set serialport [board_info $connhost netport];
|
set serialport [board_info $connhost netport];
|
}
|
}
|
|
|
if [board_info $connhost exists baud] {
|
if [board_info $connhost exists baud] {
|
set baud [board_info $connhost baud];
|
set baud [board_info $connhost baud];
|
} else {
|
} else {
|
set baud 9600;
|
set baud 9600;
|
}
|
}
|
# FIXME: This is wrong.
|
# FIXME: This is wrong.
|
send "kill\n"
|
send "kill\n"
|
gdb_expect {
|
gdb_expect {
|
-re ".*Kill the program being debugged.*y or n. $" {
|
-re ".*Kill the program being debugged.*y or n. $" {
|
send "y\n"
|
send "y\n"
|
exp_continue
|
exp_continue
|
}
|
}
|
-re ".*$gdb_prompt $" {}
|
-re ".*$gdb_prompt $" {}
|
}
|
}
|
|
|
verbose "Starting GDB stub on [target_info name]" 1
|
verbose "Starting GDB stub on [target_info name]" 1
|
send -i $shell_id "load nlmstub BAUD=$baud x.nlm\r\n"
|
send -i $shell_id "load nlmstub BAUD=$baud x.nlm\r\n"
|
|
|
send "set remotebaud $baud\n"
|
send "set remotebaud $baud\n"
|
gdb_expect {
|
gdb_expect {
|
-re "$gdb_prompt" {}
|
-re "$gdb_prompt" {}
|
timeout {
|
timeout {
|
perror "Couldn't set remote baud rate"
|
perror "Couldn't set remote baud rate"
|
return
|
return
|
}
|
}
|
}
|
}
|
|
|
set otimeout $timeout
|
set otimeout $timeout
|
set timeout 60
|
set timeout 60
|
verbose "Timeout is now $timeout seconds" 2
|
verbose "Timeout is now $timeout seconds" 2
|
send "target remote $serialport\n"
|
send "target remote $serialport\n"
|
gdb_expect {
|
gdb_expect {
|
-re "Couldn't establish connection to remote target" {
|
-re "Couldn't establish connection to remote target" {
|
send "target remote $serialport\n"
|
send "target remote $serialport\n"
|
exp_continue
|
exp_continue
|
}
|
}
|
-re "$gdb_prompt" {}
|
-re "$gdb_prompt" {}
|
timeout {
|
timeout {
|
set timeout $otimeout
|
set timeout $otimeout
|
verbose "Timeout restored to $timeout seconds" 2
|
verbose "Timeout restored to $timeout seconds" 2
|
perror "Couldn't set remote target"
|
perror "Couldn't set remote target"
|
return
|
return
|
}
|
}
|
}
|
}
|
set timeout $otimeout
|
set timeout $otimeout
|
verbose "Timeout restored to $timeout seconds" 2
|
verbose "Timeout restored to $timeout seconds" 2
|
|
|
send "continue\n"
|
send "continue\n"
|
gdb_expect {
|
gdb_expect {
|
"Continuing.$" {}
|
"Continuing.$" {}
|
}
|
}
|
|
|
return
|
return
|
}
|
}
|
|
|
|
|
|
|
#
|
#
|
# start the remote shell
|
# start the remote shell
|
#
|
#
|
|
|
set shell_prompt "Password:"
|
set shell_prompt "Password:"
|
set shell_id [remote_open target]
|
set shell_id [remote_open target]
|
|
|
if $shell_id<0 then {
|
if $shell_id<0 then {
|
warning "Couldn't connect to target"
|
warning "Couldn't connect to target"
|
return -1
|
return -1
|
}
|
}
|
|
|
if [string match "" $passwd] then {
|
if [string match "" $passwd] then {
|
stty -echo
|
stty -echo
|
send_user "Password: "
|
send_user "Password: "
|
expect_user -re "(.*)\n"
|
expect_user -re "(.*)\n"
|
send_user "\n"
|
send_user "\n"
|
set passwd "$expect_out(1,string)"
|
set passwd "$expect_out(1,string)"
|
stty echo
|
stty echo
|
}
|
}
|
|
|
send -i $shell_id "$passwd\n"
|
send -i $shell_id "$passwd\n"
|
gdb_expect {
|
gdb_expect {
|
-i $shell_id ":" {
|
-i $shell_id ":" {
|
verbose "Got termtype prompt" 0
|
verbose "Got termtype prompt" 0
|
}
|
}
|
|
|
-i $shell_id timeout {
|
-i $shell_id timeout {
|
warning "Connection timed out"
|
warning "Connection timed out"
|
return -1
|
return -1
|
}
|
}
|
}
|
}
|
|
|
|
|
# FIXME: this is wrong.
|
# FIXME: this is wrong.
|
set shell_prompt "[string toupper [target_info name]]:"
|
set shell_prompt "[string toupper [target_info name]]:"
|
send -i $shell_id "1\n"
|
send -i $shell_id "1\n"
|
|
|
gdb_expect {
|
gdb_expect {
|
-i $shell_id -re "$shell_prompt" {}
|
-i $shell_id -re "$shell_prompt" {}
|
-i $shell_id timeout {
|
-i $shell_id timeout {
|
warning "Connection timed out"
|
warning "Connection timed out"
|
return -1
|
return -1
|
}
|
}
|
}
|
}
|
|
|