Major revision to testsuites for cross-testing and DOS testing support.
[deliverable/binutils-gdb.git] / gdb / testsuite / config / monitor.exp
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
16 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
17
18 load_lib gdb.exp
19
20 #
21 # gdb_target_monitor
22 # Set gdb to target the monitor
23 #
24 proc gdb_target_monitor { } {
25 global prompt
26 global exit_status
27 global timeout
28
29 set timeout 60
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;
37 }
38 if [target_info exists baud] {
39 send_gdb "set remotebaud [target_info baud]\n"
40 }
41 if [target_info exists netport] {
42 set serialport "[target_info netport]"
43 } else {
44 set serialport "[target_info serial]"
45 }
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
62 }
63 -re "Connection refused" {
64 verbose "Connection refused by remote target. Pausing, and trying again."
65 sleep 30
66 continue
67 }
68 timeout {
69 break
70 }
71 }
72 }
73 if { $j == 1 && ![reboot_target] } {
74 break;
75 }
76 }
77
78 perror "Couldn't set target for $targetname, port is $serialport."
79 cleanup
80 exit $exit_status
81 }
82
83 #
84 # gdb_load -- load a file into the debugger.
85 # return a -1 if anything goes wrong.
86 #
87 proc gdb_load { arg } {
88 global verbose
89 global loadpath
90 global loadfile
91 global GDB
92 global prompt
93 global timeout
94
95 if { $arg != "" } {
96 if [gdb_file_cmd $arg] { return -1 }
97 }
98
99 gdb_target_monitor
100
101 if [is_remote host] {
102 # FIXME:
103 set arg a.out;
104 }
105
106 verbose "Loading $arg"
107 send_gdb "load $arg\n"
108 set timeout 1000
109 verbose "Timeout is now $timeout seconds" 2
110 expect {
111 -re ".*$prompt $" {
112 if { $verbose > 1 } {
113 send_user "Loaded $arg into $GDB\n"
114 }
115 return 1
116 }
117 -re "$prompt $" {
118 if { $verbose > 1 } {
119 perror "GDB couldn't load."
120 }
121 }
122 timeout {
123 if { $verbose > 1 } {
124 perror "Timed out trying to load $arg."
125 }
126 }
127 }
128 }
129
130 proc gdb_start { } {
131 global timeout
132 global reboot
133
134 # reboot the board to get a clean start
135 if $reboot then {
136 reboot_target;
137 }
138 catch default_gdb_start;
139
140 set timeout 10
141 verbose "Timeout is now $timeout seconds" 2
142 }
This page took 0.038546 seconds and 4 git commands to generate.