771a9e1dbb7038154be8fc954a010bb2a0bc3045
[external/binutils.git] / gdb / testsuite / config / slite.exp
1 #   Copyright (C) 1993 Free Software Foundation, Inc.
2
3 # This program is free software; you can redistribute it and/or modify
4 # it under the terms of the GNU General Public License as published by
5 # the Free Software Foundation; either version 2 of the License, or
6 # (at your option) any later version.
7
8 # This program is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11 # GNU General Public License for more details.
12
13 # You should have received a copy of the GNU General Public License
14 # along with this program; if not, write to the Free Software
15 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
16
17 # Please email any bugs, comments, and/or additions to this file to:
18 # DejaGnu@cygnus.com
19
20 # This file was written by Ian Lance Taylor <ian@cygnus.com>.
21
22 # GDB support routines for a board using the MIPS remote debugging
23 # protocol.  These are actually pretty generic.
24
25 # DejaGnu currently assumes that debugging is being done over the main
26 # console port.  It would probably be more convenient for people using
27 # IDT boards to permit the debugging port and the connected port to be
28 # different, since an IDT board has two ports.  This would require
29 # extending some of the tests in a fashion similar to that done for
30 # VxWorks, because the test output would appear on the other port,
31 # rather than being displayed by gdb.
32
33 load_lib remote.exp
34 load_lib gdb.exp
35 set prompt "\\(gdb\\)"
36
37 #
38 # gdb_load -- load a file into the GDB. 
39 #             Returns a 0 if there was an error,
40 #                       1 if it load successfully.
41 #
42 proc gdb_load { arg } {
43     global verbose
44     global loadpath
45     global loadfile
46     global prompt
47     global GDB
48     global expect_out
49     global gdb_spawn_id
50
51     set loadfile [file tail $arg]
52     set loadpath [file dirname $arg]
53
54     send_gdb "file $arg\n"
55     expect {
56         -i $gdb_spawn_id -re "A program is being debugged already..*Kill it.*y or n. $" {
57             send_gdb "y\n"
58             exp_continue
59         }
60         -i $gdb_spawn_id -re "Load new symbol table.*y or n. $" {
61             send_gdb "y\n"
62             exp_continue
63         }
64         -i $gdb_spawn_id -re "Reading symbols from.*done..*$prompt $" {}
65         -i $gdb_spawn_id -re "$prompt $" { perror "GDB couldn't read file" }
66         -i $gdb_spawn_id timeout { perror "(timeout) read symbol file" ; return -1 }
67     }
68
69     if [target_info exists gdb_protocol] {
70         set protocol [target_info gdb_protocol];
71     } else {
72         set protocol "sparclite"
73     }
74
75     if [target_info exists serial] {
76         set targetname [target_info serial];
77         send_gdb "target $protocol [target_info serial]\n";
78     } else {
79         if ![target_info exists netport] {
80             perror "Need either netport or gdb_serial entry for [target_info name].";
81             return -1;
82         }
83         set targetname [target_info netport];
84         send_gdb "target $protocol udp [target_info netport]\n";
85     }
86     set timeout 60
87     verbose "Timeout is now $timeout seconds" 2
88     expect {
89         -i $gdb_spawn_id -re "Remote target.*$prompt $" { }
90         -i $gdb_spawn_id -re ".*SPARClite appears to be alive.*$prompt $"       {
91             if $verbose>1 then {
92                 send_user "Set target to $targetname\n"
93             }
94         }
95         -i $gdb_spawn_id timeout { 
96             perror "Couldn't set SLITE target."
97             set timeout 10
98             verbose "Timeout is now $timeout seconds" 2
99             return -1
100         }
101     }
102     
103     if [target_info exists gdb_load_offset] {
104         set offset "[target_info gdb_load_offset]";
105     } else {
106         set offset "";
107     }
108     if { 1 } {
109         send_gdb "load $arg $offset\n"
110         verbose "Loading $arg into $GDB" 2
111         set timeout 2400
112         verbose "Timeout is now $timeout seconds" 2
113         expect {
114             -i $gdb_spawn_id -re "Loading.*$prompt $" {
115                 verbose "Loaded $arg into $GDB" 1
116                 set timeout 30
117                 verbose "Timeout is now $timeout seconds" 2
118             }
119             -i $gdb_spawn_id -re "$prompt $"     {
120                 if $verbose>1 then {
121                     perror "GDB couldn't load."
122                 }
123             }
124             -i $gdb_spawn_id timeout {
125                 if $verbose>1 then {
126                     perror "Timed out trying to load $arg."
127                 }
128             }
129         }
130     }
131     set timeout 10
132     verbose "Timeout is now $timeout seconds, doing monitor run" 2
133     send_gdb "monitor run\n";
134     sleep 2;
135     send_gdb "\ 3";
136     expect {
137         -i $gdb_spawn_id -re ".*$prompt $" { verbose "Run command succeded" }
138         -i $gdb_spawn_id default {
139             perror "error sending monitor run command";
140         }
141     }
142
143     if [target_info exists gdb_serial] {
144         set serial [target_info gdb_serial];
145     } else {
146         set serial [target_info serial];
147     }
148     send_gdb "target remote $serial\n"
149     set timeout 60
150     verbose "Timeout is now $timeout seconds" 2
151     expect {
152         -i $gdb_spawn_id -re ".*Kill it?.*y or n.*" {
153             send_gdb "y\n";
154             exp_continue
155         }
156         -i $gdb_spawn_id -re ".*$prompt $"      {
157             verbose "Set remote target to [target_info serial]" 2
158         }
159         -i $gdb_spawn_id timeout {
160             perror "Couldn't set remote target."
161             set timeout 10
162             verbose "Timeout is now $timeout seconds" 2
163             return -1
164         }
165     }
166
167     if [info exists expect_out(buffer)] then {
168         send_log $expect_out(buffer)
169     }
170     return 0
171 }