]> Git Repo - binutils.git/blob - gdb/testsuite/config/monitor.exp
* lib/gdb.exp (gdb_test_exact): Turn \n in pattern into \r\n.
[binutils.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_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     global target_info
38
39     set timeout 60
40     if {$baud != ""} then {
41         send "set remotebaud $baud\n"
42     }
43     if [info exists target_info(target,cflags)] {
44         set targetname "$target_info(target,target)"
45     }
46     if [info exists target_info(target,netport)] {
47         set serialport "$target_info(target,netport)"
48     }
49     for {set i 1} {$i <= 3} {incr i} {
50         send "target $targetname $serialport\n"
51         expect {
52                 -re "Remote target $targetname connected to.*$prompt $" {
53                      verbose "Set target to $targetname"
54                      return
55                 }
56                 -re "Connection refused" {
57                     verbose "Connection refused by remote target.  Pausing, and trying again."
58                     sleep 30
59                     continue
60                 }
61                 timeout { 
62                     break
63                 }
64         }
65     }
66
67     perror "Couldn't set target for $targetname."
68     cleanup
69     exit $exit_status
70 }
71
72 #
73 # gdb_load -- load a file into the debugger.
74 #             return a -1 if anything goes wrong.
75 #
76 proc gdb_load { arg } {
77     global verbose
78     global loadpath
79     global loadfile
80     global GDB
81     global prompt
82
83     if [gdb_file_cmd $arg] then { return -1 }
84
85     gdb_target_monitor
86
87     verbose "Loading $arg"
88     send "load $arg\n"
89     set timeout 600
90     expect {
91         -re ".*$prompt $" {
92             if { $verbose > 1 } {
93                 send_user "Loaded $arg into $GDB\n"
94             }
95             return 1
96         }
97         -re "$prompt $"     {
98             if { $verbose > 1 } {
99                 perror "GDB couldn't load."
100             }
101         }
102         timeout {
103             if { $verbose > 1 } {
104          perror "Timed out trying to load $arg."
105             }
106         }
107     }
108 }
109
110 #
111 # gdb_start -- start GDB running.
112 #
113 proc gdb_start { } {
114     default_gdb_start
115 }
116
117 #
118 # gdb_exit -- exit gdb
119 #
120 proc gdb_exit { } {
121     catch default_gdb_exit
122 }
123
124 gdb_start
This page took 0.0343 seconds and 4 git commands to generate.