]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - gdb/testsuite/config/monitor.exp
Major revision to testsuites for cross-testing and DOS testing support.
[thirdparty/binutils-gdb.git] / gdb / testsuite / config / monitor.exp
CommitLineData
7e7b4a02
SG
1# Test Framework Driver for GDB driving a ROM monitor (via monitor.c).
2# Copyright 1995 Free Software Foundation, Inc.
3#
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.
8#
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.
13#
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
4db6401f 16# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
7e7b4a02
SG
17
18load_lib gdb.exp
19
7e7b4a02
SG
20#
21# gdb_target_monitor
22# Set gdb to target the monitor
23#
24proc gdb_target_monitor { } {
25 global prompt
26 global exit_status
787f6220 27 global timeout
7e7b4a02
SG
28
29 set timeout 60
787f6220
BM
30
31 verbose "Timeout is now $timeout seconds" 2
32 if [target_info exists gdb_protocol] {
33 set targetname "[target_info gdb_protocol]"
34 } else {
35 perror "No protocol specified for [target_info name].";
36 return -1;
4db6401f 37 }
787f6220
BM
38 if [target_info exists baud] {
39 send_gdb "set remotebaud [target_info baud]\n"
4db6401f 40 }
787f6220
BM
41 if [target_info exists netport] {
42 set serialport "[target_info netport]"
43 } else {
44 set serialport "[target_info serial]"
4db6401f 45 }
787f6220
BM
46
47 for {set j 1} {$j <= 2} {incr j} {
48 for {set i 1} {$i <= 3} {incr i} {
49 send_gdb "target $targetname $serialport\n"
50 expect {
51 -re "Remote MIPS debugging.*" {
52 verbose "Set target to $targetname"
53 return
54 }
55 -re "Remote debugging using $serialport.*" {
56 verbose "Set target to $targetname"
57 return
58 }
59 -re "Remote target $targetname connected to.*" {
60 verbose "Set target to $targetname"
61 return
7e7b4a02
SG
62 }
63 -re "Connection refused" {
64 verbose "Connection refused by remote target. Pausing, and trying again."
65 sleep 30
66 continue
67 }
68 timeout {
4db6401f 69 break
7e7b4a02 70 }
787f6220
BM
71 }
72 }
73 if { $j == 1 && ![reboot_target] } {
74 break;
7e7b4a02
SG
75 }
76 }
4db6401f 77
787f6220 78 perror "Couldn't set target for $targetname, port is $serialport."
4db6401f
RS
79 cleanup
80 exit $exit_status
7e7b4a02
SG
81}
82
83#
84# gdb_load -- load a file into the debugger.
85# return a -1 if anything goes wrong.
86#
87proc gdb_load { arg } {
88 global verbose
89 global loadpath
90 global loadfile
91 global GDB
92 global prompt
787f6220 93 global timeout
7e7b4a02 94
787f6220
BM
95 if { $arg != "" } {
96 if [gdb_file_cmd $arg] { return -1 }
97 }
7e7b4a02
SG
98
99 gdb_target_monitor
100
787f6220
BM
101 if [is_remote host] {
102 # FIXME:
103 set arg a.out;
104 }
105
4db6401f 106 verbose "Loading $arg"
787f6220
BM
107 send_gdb "load $arg\n"
108 set timeout 1000
109 verbose "Timeout is now $timeout seconds" 2
7e7b4a02
SG
110 expect {
111 -re ".*$prompt $" {
4db6401f 112 if { $verbose > 1 } {
7e7b4a02
SG
113 send_user "Loaded $arg into $GDB\n"
114 }
115 return 1
116 }
117 -re "$prompt $" {
4db6401f
RS
118 if { $verbose > 1 } {
119 perror "GDB couldn't load."
7e7b4a02
SG
120 }
121 }
122 timeout {
4db6401f 123 if { $verbose > 1 } {
787f6220 124 perror "Timed out trying to load $arg."
7e7b4a02
SG
125 }
126 }
127 }
128}
129
7e7b4a02 130proc gdb_start { } {
787f6220
BM
131 global timeout
132 global reboot
7e7b4a02 133
787f6220
BM
134 # reboot the board to get a clean start
135 if $reboot then {
136 reboot_target;
137 }
138 catch default_gdb_start;
7e7b4a02 139
787f6220
BM
140 set timeout 10
141 verbose "Timeout is now $timeout seconds" 2
142}