Commit | Line | Data |
---|---|---|
787f6220 BM |
1 | # Test Framework Driver for GDB using the extended gdb remote protocol |
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 | # For this to function correctly, you need to set a number of variables | |
19 | # in your gdb/site.exp file | |
20 | # | |
21 | # set noargs 1 -- we can't pass arguments (yet) | |
22 | # set noinferiorio 1 -- we can't get io to/from the inferior | |
23 | # set targethost <host> -- name of the remote system (runs gdbserver) | |
24 | # set debughost <host> -- name of the system running gdb | |
25 | # set port <number> -- starting port number for communication | |
26 | # set gdbserver <path> -- path (on the remote side) to find | |
27 | # gdbserver | |
28 | # set rsh <path> -- path (on debughost side) to rsh | |
29 | # set rcp <path> -- path (on debughost side) to rcp | |
30 | # | |
31 | # You will need to be able to spawn processes from gdbhost to run on | |
32 | # targethost via rsh (this is how we start gdbserver); similarly | |
33 | # you need to be able to rcp files from gdbhost to targethost. | |
34 | # | |
35 | # We don't do much error checking, if something goes wrong, you'll probably | |
36 | # just get a tcl error and everything will die. FIXME | |
37 | # | |
38 | ||
39 | # Load the basic gdb testing library | |
40 | load_lib gdb.exp | |
41 | load_lib monitor.exp | |
42 | ||
43 | # | |
44 | # gdb_load -- load a file into the debugger. | |
45 | # return a -1 if anything goes wrong. | |
46 | # | |
47 | # Loading a file in the gdbsrever framework is a little strange in that | |
48 | # we also create the inferior (which is stopped at the first instruction | |
49 | # in the program when we get control). | |
50 | # | |
51 | proc gdb_load { arg } { | |
52 | global verbose | |
53 | global loadpath | |
54 | global loadfile | |
55 | global GDB | |
56 | global prompt | |
57 | global debughost | |
58 | global port | |
59 | ||
60 | # first load the file into gdb | |
61 | if [gdb_file_cmd $arg] then { return -1 } | |
62 | ||
63 | # bump the port number to avoid conflicts with hung ports | |
64 | set targethost [target_info gdb_server_host]; | |
65 | set debughost [target_info gdb_debug_host]; | |
66 | if [target_info exists gdb_server_prog] { | |
67 | set gdbserver [target_info gdb_server_prog]; | |
68 | } else { | |
69 | set gdbserver "gdbserver"; | |
70 | } | |
71 | incr port | |
72 | set serialport $targethost:$port | |
73 | ||
74 | # Copy the file down to the remote host. | |
75 | set file [remote_download host $arg]; | |
76 | ||
77 | # now start gdbserver on the remote side | |
78 | remote_spawn host "$gdbserver $debughost:$port $file >& /dev/null < /dev/null" | |
79 | ||
80 | # give it plenty of time to get going (lynx) | |
81 | sleep 30 | |
82 | ||
83 | # tell gdb we are remote debugging | |
84 | gdb_target_monitor | |
85 | ||
86 | return 1 | |
87 | } | |
88 | ||
89 | # | |
90 | # gdb_start -- start GDB running. | |
91 | # | |
92 | proc gdb_start { } { | |
93 | global prompt | |
94 | ||
95 | # do the usual stuff | |
96 | catch default_gdb_start | |
97 | ||
98 | # FIXME: This shouldn't be necessary, but lots of PA tests fail | |
99 | # without it. | |
100 | send "set remotecache 0\n" | |
101 | expect { | |
102 | -re "set remotecache 0\[\r\n\]+.*$prompt $" {} | |
103 | default { fail "gdb_start"} | |
104 | } | |
105 | } |