summaryrefslogtreecommitdiff
path: root/gdb/testsuite/lib/gdbserver-support.exp
diff options
context:
space:
mode:
authorDaniel Jacobowitz <drow@false.org>2007-03-27 17:59:38 +0000
committerDaniel Jacobowitz <drow@false.org>2007-03-27 17:59:38 +0000
commitb741e217929039042129802a61e4510c580ecc79 (patch)
tree7f95fddc87c00954b65a276ae74af2533d50aa59 /gdb/testsuite/lib/gdbserver-support.exp
parentd2449ee801d18f5af7317bc72c92bc9bbb7b669e (diff)
downloadbinutils-gdb-b741e217929039042129802a61e4510c580ecc79.tar.gz
* config/gdbserver.exp (gdbserver_gdb_load): Update argument list.
(gdb_load): Delete, replace with... (gdb_reload): ...this. * gdb.server/server-run.exp: Use gdb_load and gdbserver_run. * gdb.server/server-mon.exp: Likewise. * lib/gdb.exp (gdb_run_cmd): Use gdb_reload. (gdb_start_cmd): New. (gdb_file_cmd): Save the last loaded file. (gdb_reload): New. (gdb_gnu_strip_debug): Use transform. * lib/gdbserver-support.exp (gdbserver_spawn): Move file download support here. Use new $last_loaded_file. Check mtime. (gdb_target_cmd): Handle ObjC failure case. (infer_host_exec): Delete. (gdbserver_load): Rename to... (gdbserver_run): ...this. Simplify. * lib/mi-support.exp (mi_gdb_file_cmd): Set last_loaded_file. (mi_gdb_load): Move most contents to a new function... (mi_gdb_target_load): ...here. Simplify call to gdbserver_gdb_load. (mi_run_cmd): Use mi_gdb_target_load. * gdb.base/break.exp, gdb.base/ending-run.exp, gdb.base/pending.exp, gdb.base/sepdebug.exp, gdb.base/unload.exp, gdb.objc/objcdecode.exp: Use gdb_run_cmd. * gdb.base/charsign.exp: Remove incorrect comment. * gdb.base/dbx.exp (gdb_file_cmd): Set last_loaded_file. * gdb.ada/exec_changed.exp, gdb.ada/null_record.exp, gdb.ada/start.exp, gdb.base/start.exp: Use gdb_start_cmd.
Diffstat (limited to 'gdb/testsuite/lib/gdbserver-support.exp')
-rw-r--r--gdb/testsuite/lib/gdbserver-support.exp92
1 files changed, 42 insertions, 50 deletions
diff --git a/gdb/testsuite/lib/gdbserver-support.exp b/gdb/testsuite/lib/gdbserver-support.exp
index 12b14a299ea..3bf974d319b 100644
--- a/gdb/testsuite/lib/gdbserver-support.exp
+++ b/gdb/testsuite/lib/gdbserver-support.exp
@@ -80,6 +80,11 @@ proc gdb_target_cmd { targetname serialport } {
-re "Timeout reading from remote system.*$gdb_prompt $" {
verbose "Got timeout error from gdb."
}
+ -notransfer -re "Remote debugging using .*\r\n> $" {
+ # We got an unexpected prompt while creating the target.
+ # Leave it there for the test to diagnose.
+ return 1
+ }
timeout {
send_gdb ""
break
@@ -129,8 +134,40 @@ proc skip_gdbserver_tests { } {
#
# Returns the target protocol and socket to connect to.
-proc gdbserver_spawn { server_exec child_args } {
+proc gdbserver_spawn { child_args } {
global portnum
+ global gdbserver_host_exec
+ global gdbserver_host_mtime
+ global gdbserver_server_exec
+ global last_loaded_file
+
+ set host_exec $last_loaded_file
+
+ # If we already downloaded a file to the target, see if we can reuse it.
+ set reuse 0
+ if { [info exists gdbserver_server_exec] } {
+ set reuse 1
+
+ # If the file has changed, we can not.
+ if { $host_exec != $gdbserver_host_exec } {
+ set reuse 0
+ }
+
+ # If the mtime has changed, we can not.
+ if { [file mtime $host_exec] != $gdbserver_host_mtime } {
+ set reuse 0
+ }
+ }
+
+ if { $reuse == 0 } {
+ set gdbserver_host_exec $host_exec
+ set gdbserver_host_mtime [file mtime $host_exec]
+ if [is_remote target] {
+ set gdbserver_server_exec [remote_download target $host_exec /tmp/[file tail $host_exec].[pid]]
+ } else {
+ set gdbserver_server_exec $host_exec
+ }
+ }
# Port id -- either specified in baseboard file, or managed here.
if [target_info exists gdb,socketport] {
@@ -162,7 +199,7 @@ proc gdbserver_spawn { server_exec child_args } {
# Fire off the debug agent. This flavour of gdbserver takes as
# arguments the port information, the name of the executable file to
# be debugged, and any arguments.
- set gdbserver_command "$gdbserver :$portnum $server_exec"
+ set gdbserver_command "$gdbserver :$portnum $gdbserver_server_exec"
if { $child_args != "" } {
append gdbserver_command " $child_args"
}
@@ -194,58 +231,13 @@ proc gdbserver_spawn { server_exec child_args } {
return [list $protocol $gdbport]
}
-proc infer_host_exec { } {
- set host_exec ""
-
- send_gdb "info files\n"
- gdb_expect 30 {
- -re "Symbols from \"(\[^\"\]+)\"" {
- set host_exec $expect_out(1,string)
- exp_continue
- }
- -re "Local exec file:\[\r\n\]+\[ \t\]*`(\[^'\]+)'," {
- set host_exec $expect_out(1,string)
- exp_continue
- }
- -re "$gdb_prompt $" { }
- }
-
- return $host_exec
-}
-
# Start a gdbserver process running HOST_EXEC and pass CHILD_ARGS
# to it. Return 0 on success, or non-zero on failure.
-proc gdbserver_load { host_exec child_args } {
- global gdbserver_host_exec
- global gdbserver_server_exec
-
- # If we weren't passed an explicit binary, try to reuse the current
- # one. If we were, be sure to redownload it.
-
- if { $host_exec == "" && $gdbserver_host_exec == "" } {
- set gdbserver_host_exec [infer_host_exec]
- } elseif { $host_exec != "" } {
- set gdbserver_host_exec $host_exec
- if [info exists gdbserver_server_exec] { unset gdbserver_server_exec }
- }
-
- if { ! [info exists gdbserver_server_exec] } {
- if [is_remote target] {
- set gdbserver_server_exec [remote_download target $host_exec /tmp/[file tail $gdbserver_host_exec].[pid]]
- } else {
- set gdbserver_server_exec $gdbserver_host_exec
- }
- }
-
- set res [gdbserver_spawn $gdbserver_server_exec $child_args]
+proc gdbserver_run { child_args } {
+ set res [gdbserver_spawn $child_args]
set protocol [lindex $res 0]
set gdbport [lindex $res 1]
- if { $host_exec != "" } {
- if [gdb_file_cmd $host_exec] {
- return -1
- }
- }
- gdb_target_cmd $protocol $gdbport
+ return [gdb_target_cmd $protocol $gdbport]
}