* config/monitor.exp (gdb_target_monitor): Fix loop interator so
[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., 675 Mass Ave, Cambridge, MA 02139, USA. */
17
18 load_lib gdb.exp
19
20 #
21 # gdb_version -- extract and print the version number of gdb
22 #
23 proc gdb_version {} {
24 default_gdb_version
25 }
26
27 #
28 # gdb_target_monitor
29 # Set gdb to target the monitor
30 #
31 proc gdb_target_monitor { } {
32 global prompt
33 global exit_status
34 global targetname
35 global serialport
36 global baud
37
38 set timeout 60
39 for {set i 1} {$i <= 3} {incr i} {
40 send "target $targetname $serialport\n"
41 expect {
42 -re "Remote target $targetname connected to.*$prompt $" {
43 verbose "Set target to $targetname"
44 break
45 }
46 -re "Connection refused" {
47 verbose "Connection refused by remote target. Pausing, and trying again."
48 sleep 30
49 continue
50 }
51 timeout {
52 perror "Couldn't set target for $targetname."
53 cleanup
54 exit $exit_status
55 }
56 }
57 }
58 }
59
60 #
61 # gdb_load -- load a file into the debugger.
62 # return a -1 if anything goes wrong.
63 #
64 proc gdb_load { arg } {
65 global verbose
66 global loadpath
67 global loadfile
68 global GDB
69 global prompt
70
71 if [gdb_file_cmd $arg] then { return -1 }
72
73 gdb_target_monitor
74
75 send "load\n"
76 set timeout 600
77 expect {
78 -re ".*$prompt $" {
79 if $verbose>1 then {
80 send_user "Loaded $arg into $GDB\n"
81 }
82 return 1
83 }
84 -re "$prompt $" {
85 if $verbose>1 then {
86 perror "GDB couldn't load."
87 }
88 }
89 timeout {
90 if $verbose>1 then {
91 perror "Timed out trying to load $arg."
92 }
93 }
94 }
95 }
96
97 #
98 # gdb_start -- start GDB running.
99 #
100 proc gdb_start { } {
101 default_gdb_start
102 }
103
104 #
105 # gdb_exit -- exit gdb
106 #
107 proc gdb_exit { } {
108 catch default_gdb_exit
109 }
110
111 gdb_start
This page took 0.034866 seconds and 5 git commands to generate.