1995-05-11 01:03:50 +00:00
|
|
|
|
# Test Framework Driver for GDB driving a ROM monitor (via monitor.c).
|
|
|
|
|
# Copyright 1995 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
|
1996-05-08 04:04:25 +00:00
|
|
|
|
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
1995-05-11 01:03:50 +00:00
|
|
|
|
|
|
|
|
|
load_lib gdb.exp
|
|
|
|
|
|
|
|
|
|
#
|
|
|
|
|
# gdb_target_monitor
|
|
|
|
|
# Set gdb to target the monitor
|
|
|
|
|
#
|
|
|
|
|
proc gdb_target_monitor { } {
|
1997-02-02 07:59:25 +00:00
|
|
|
|
global gdb_prompt
|
1995-05-11 01:03:50 +00:00
|
|
|
|
global exit_status
|
1997-01-29 09:40:31 +00:00
|
|
|
|
global timeout
|
1995-05-11 01:03:50 +00:00
|
|
|
|
|
|
|
|
|
set timeout 60
|
1997-01-29 09:40:31 +00:00
|
|
|
|
|
|
|
|
|
verbose "Timeout is now $timeout seconds" 2
|
|
|
|
|
if [target_info exists gdb_protocol] {
|
|
|
|
|
set targetname "[target_info gdb_protocol]"
|
|
|
|
|
} else {
|
|
|
|
|
perror "No protocol specified for [target_info name].";
|
|
|
|
|
return -1;
|
1996-05-08 04:04:25 +00:00
|
|
|
|
}
|
1997-01-29 09:40:31 +00:00
|
|
|
|
if [target_info exists baud] {
|
1997-03-01 04:50:01 +00:00
|
|
|
|
gdb_test "set remotebaud [target_info baud]" "" ""
|
1996-05-08 04:04:25 +00:00
|
|
|
|
}
|
1997-01-29 09:40:31 +00:00
|
|
|
|
if [target_info exists netport] {
|
|
|
|
|
set serialport "[target_info netport]"
|
|
|
|
|
} else {
|
|
|
|
|
set serialport "[target_info serial]"
|
1996-05-08 04:04:25 +00:00
|
|
|
|
}
|
1997-01-29 09:40:31 +00:00
|
|
|
|
|
|
|
|
|
for {set j 1} {$j <= 2} {incr j} {
|
|
|
|
|
for {set i 1} {$i <= 3} {incr i} {
|
|
|
|
|
send_gdb "target $targetname $serialport\n"
|
1997-03-01 04:50:01 +00:00
|
|
|
|
gdb_expect {
|
|
|
|
|
-re "A program is being debugged already.*ill it.*y or n. $" {
|
|
|
|
|
send_gdb "y\n";
|
|
|
|
|
exp_continue;
|
|
|
|
|
}
|
|
|
|
|
-re ".*Couldn't establish connection to remote.*$gdb_prompt" {
|
|
|
|
|
verbose "Connection failed"
|
|
|
|
|
}
|
|
|
|
|
-re "Remote MIPS debugging.*$gdb_prompt" {
|
1997-01-29 09:40:31 +00:00
|
|
|
|
verbose "Set target to $targetname"
|
|
|
|
|
return
|
|
|
|
|
}
|
1997-03-01 04:50:01 +00:00
|
|
|
|
-re "Remote debugging using $serialport.*$gdb_prompt" {
|
1997-01-29 09:40:31 +00:00
|
|
|
|
verbose "Set target to $targetname"
|
|
|
|
|
return
|
|
|
|
|
}
|
1997-03-01 04:50:01 +00:00
|
|
|
|
-re "Remote target $targetname connected to.*$gdb_prompt" {
|
1997-01-29 09:40:31 +00:00
|
|
|
|
verbose "Set target to $targetname"
|
|
|
|
|
return
|
1995-05-11 01:03:50 +00:00
|
|
|
|
}
|
1997-03-01 04:50:01 +00:00
|
|
|
|
-re "Connection refused.*$gdb_prompt" {
|
1995-05-11 01:03:50 +00:00
|
|
|
|
verbose "Connection refused by remote target. Pausing, and trying again."
|
|
|
|
|
sleep 30
|
|
|
|
|
continue
|
|
|
|
|
}
|
1997-03-01 04:50:01 +00:00
|
|
|
|
timeout {
|
|
|
|
|
send_gdb "";
|
1996-05-08 04:04:25 +00:00
|
|
|
|
break
|
1995-05-11 01:03:50 +00:00
|
|
|
|
}
|
1997-01-29 09:40:31 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if { $j == 1 && ![reboot_target] } {
|
|
|
|
|
break;
|
1995-05-11 01:03:50 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
1996-05-08 04:04:25 +00:00
|
|
|
|
|
1997-01-29 09:40:31 +00:00
|
|
|
|
perror "Couldn't set target for $targetname, port is $serialport."
|
1997-03-01 04:50:01 +00:00
|
|
|
|
return -1;
|
1995-05-11 01:03:50 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#
|
|
|
|
|
# gdb_load -- load a file into the debugger.
|
|
|
|
|
# return a -1 if anything goes wrong.
|
|
|
|
|
#
|
|
|
|
|
proc gdb_load { arg } {
|
|
|
|
|
global verbose
|
|
|
|
|
global loadpath
|
|
|
|
|
global loadfile
|
|
|
|
|
global GDB
|
1997-02-02 07:59:25 +00:00
|
|
|
|
global gdb_prompt
|
1997-01-29 09:40:31 +00:00
|
|
|
|
global timeout
|
1995-05-11 01:03:50 +00:00
|
|
|
|
|
1997-01-29 09:40:31 +00:00
|
|
|
|
if { $arg != "" } {
|
|
|
|
|
if [gdb_file_cmd $arg] { return -1 }
|
|
|
|
|
}
|
1995-05-11 01:03:50 +00:00
|
|
|
|
|
|
|
|
|
gdb_target_monitor
|
|
|
|
|
|
1997-01-29 09:40:31 +00:00
|
|
|
|
if [is_remote host] {
|
|
|
|
|
# FIXME:
|
|
|
|
|
set arg a.out;
|
|
|
|
|
}
|
|
|
|
|
|
1996-05-08 04:04:25 +00:00
|
|
|
|
verbose "Loading $arg"
|
1997-01-29 09:40:31 +00:00
|
|
|
|
send_gdb "load $arg\n"
|
|
|
|
|
set timeout 1000
|
|
|
|
|
verbose "Timeout is now $timeout seconds" 2
|
1997-03-01 04:50:01 +00:00
|
|
|
|
gdb_expect {
|
1997-02-02 07:59:25 +00:00
|
|
|
|
-re ".*$gdb_prompt $" {
|
1997-03-01 04:50:01 +00:00
|
|
|
|
verbose "Loaded $arg into $GDB\n"
|
1995-05-11 01:03:50 +00:00
|
|
|
|
return 1
|
|
|
|
|
}
|
|
|
|
|
timeout {
|
1996-05-08 04:04:25 +00:00
|
|
|
|
if { $verbose > 1 } {
|
1997-01-29 09:40:31 +00:00
|
|
|
|
perror "Timed out trying to load $arg."
|
1995-05-11 01:03:50 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
proc gdb_start { } {
|
1997-01-29 09:40:31 +00:00
|
|
|
|
global timeout
|
|
|
|
|
global reboot
|
1995-05-11 01:03:50 +00:00
|
|
|
|
|
1997-01-29 09:40:31 +00:00
|
|
|
|
# reboot the board to get a clean start
|
|
|
|
|
if $reboot then {
|
|
|
|
|
reboot_target;
|
|
|
|
|
}
|
|
|
|
|
catch default_gdb_start;
|
1995-05-11 01:03:50 +00:00
|
|
|
|
|
1997-01-29 09:40:31 +00:00
|
|
|
|
set timeout 10
|
|
|
|
|
verbose "Timeout is now $timeout seconds" 2
|
|
|
|
|
}
|