1 # Test Framework Driver
for GDB driving an external simulator
2 # Copyright
1999, 2001 Free Software Foundation
, Inc.
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.
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.
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.
23 set port
[lindex
[split
[target_info netport
] ":"] 1]
25 #
Set a default endianness
26 case
[target_info multilib_flags
] in
{
27 { *big
-endian
* *-EB
* *-meb
* } { set sidendian
"-EB" }
28 { *little
-endian
* *-EL
* *-mel
* } { set sidendian
"-EL" }
30 if {[target_info
exists sim
,defaultendian
]} then {
31 set sidendian
[target_info sim
,defaultendian
]
33 # rely
on endianness settings in sid configuration defaults
39 { -EB
} { set sidendian2
{-e
"set cpu endian big"} }
40 { -EL
} { set sidendian2
{-e
"set cpu endian little"} }
41 default
{ set sidendian2
{} }
44 # test to see whether to use use sid in build or install tree
45 set use_build_tree
[file
exists ..
/..
/sid
]
47 if {$use_build_tree
} then {
50 set env
(SID_LIBRARY_PATH
) [join
[glob
"../../sid/component/*"] ":"]
51 set env
(SID
) "../../sid/main/dynamic/sid"
52 if {! [file
exists $env
(SID
)]} then { error
"Cannot find sid in build tree" }
54 if { [board_info target sim
,protocol
] == "sid" } {
55 set spawncmd
"[target_info sim] [target_info sim,options] $sidendian2 -e \"set cpu-gdb-socket sockaddr-local 0.0.0.0:$port\""
56 } elseif
{ [board_info target sim
,protocol
] == "rawsid" } {
57 set spawncmd
"[target_info sim] [target_info sim,options] -$sidendian --gdb=$port"
59 set spawncmd
"../../sid/bsp/[target_info sim] $sidendian --gdb=$port [target_info sim,options]"
63 unset env
(SID_LIBRARY_PATH
)
68 if { [board_info target sim
,protocol
] == "sid" } {
69 # FIXME
: sim
,options may be from the build tree
, should find
70 # it in the install tree.
71 set spawncmd
"sid [target_info sim,options] $sidendian2 -e \"set cpu-gdb-socket sockaddr-local 0.0.0.0:$port\""
72 } elseif
{ [board_info target sim
,protocol
] == "rawsid" } {
73 set spawncmd
"[target_info sim] [target_info sim,options] -$sidendian --gdb=$port"
75 set spawncmd
"[target_info sim] $sidendian --gdb=$port [target_info sim,options]"
81 if {[catch
[list remote_spawn host $spawncmd
] msg
]} {
87 # Don
't do the following any more; it breaks with "runtest ... < /dev/null"
90 # regsub "\n" $expect_out(buffer) {} msg
91 # verbose "SID: $msg" 2
95 # There should be no need to sleep to give SID time to start;
96 # GDB would wait for a fair while for the stub to respond.
99 if ![target_info exists gdb,no_push_conn] {
100 remote_push_conn host;
105 # Handle GDB talking to SID
110 return [default_gdb_start]
114 if ![target_info exists gdb,no_push_conn] {
116 remote_pop_conn host;
121 set result [default_gdb_exit]
128 # Set gdb to target the simulator
130 proc send_target_sid { } {
131 # wait a little while, giving sid time to shut down & restart its
134 send_gdb "target [target_info gdb_protocol] [target_info netport]\n"
137 proc gdb_target_sid { } {
144 set prev_timeout $timeout
146 verbose "Timeout is now $timeout seconds" 2
148 -re ".*\[Ee\]rror.*$gdb_prompt $" {
149 perror "Couldn't
set target
for remote simulator.
"
153 -re
"Remote debugging using.*$gdb_prompt" {
154 verbose
"Set target to sid"
157 perror
"Couldn't set target for remote simulator."
162 set timeout $prev_timeout
163 verbose
"Timeout is now $timeout seconds" 2
167 # gdb_load
-- load a file into the debugger.
168 #
return a
-1 if anything goes wrong.
170 proc gdb_load
{ arg } {
179 if [gdb_file_cmd $
arg] then { return -1 }
184 set prev_timeout $timeout
186 verbose
"Timeout is now $timeout seconds" 2
188 -re
".*\[Ee\]rror.*$gdb_prompt $" {
190 perror
"Error during download."
194 -re
".*$gdb_prompt $" {
196 send_user
"Loaded $arg into $GDB\n"
200 -re
"$gdb_prompt $" {
202 perror
"GDB couldn't load."
208 perror
"Timed out trying to load $arg."
213 set timeout $prev_timeout
214 verbose
"Timeout is now $timeout seconds" 2