diff options
author | Daniel Jacobowitz <drow@false.org> | 2004-01-18 15:23:30 +0000 |
---|---|---|
committer | Daniel Jacobowitz <drow@false.org> | 2004-01-18 15:23:30 +0000 |
commit | da6012e52d0682c9f884d769fca82b89b3408798 (patch) | |
tree | e6b63a917aa0d609e77e44097b2d249cb3c98487 /gdb/testsuite/config | |
parent | 4389ce38f0d2e743b101f6cdf8e508c6cfa8150b (diff) | |
download | gdb-da6012e52d0682c9f884d769fca82b89b3408798.zip gdb-da6012e52d0682c9f884d769fca82b89b3408798.tar.gz gdb-da6012e52d0682c9f884d769fca82b89b3408798.tar.bz2 |
* config/gdbserver.exp (gdbserver_gdb_load): Rename from gdb_load.
Remove downloading, guessing the host executable, the calls to
gdb_file_cmd and gdb_target_cmd, and "load" support.
(infer_host_exec): New function broken out from gdb_load.
(gdb_load): New wrapper for gdbserver_gdb_load.
* lib/mi-support.exp (mi_gdb_target_cmd): New function, based on
gdb_target_cmd. Use -target-select.
(mi_gdb_file_cmd): New function, broken out from mi_gdb_load.
Download binaries to the host. Clear last_mi_remote_file when
we load a new binary.
(mi_gdb_load): Call mi_gdb_file_cmd. If gdbserver.exp is loaded,
call gdbserver_gdb_load and mi_gdb_target_cmd.
Diffstat (limited to 'gdb/testsuite/config')
-rw-r--r-- | gdb/testsuite/config/gdbserver.exp | 144 |
1 files changed, 68 insertions, 76 deletions
diff --git a/gdb/testsuite/config/gdbserver.exp b/gdb/testsuite/config/gdbserver.exp index 475acd4..bb5b246 100644 --- a/gdb/testsuite/config/gdbserver.exp +++ b/gdb/testsuite/config/gdbserver.exp @@ -2,7 +2,7 @@ # ie. a debug agent running as a native process on the same or # a different host. -# Copyright 2000, 2002 Free Software Foundation, Inc. +# Copyright 2000, 2002, 2003, 2004 Free Software Foundation, Inc. # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -89,12 +89,8 @@ global server_exec; global portnum; set portnum "2345"; -proc gdb_load { arg } { - global host_exec; - global server_exec; - global portnum; - global verbose; - global gdb_prompt; +proc gdbserver_gdb_load { server_exec } { + global portnum # Port id -- either specified in baseboard file, or managed here. if [target_info exists gdb,socketport] { @@ -134,35 +130,6 @@ proc gdb_load { arg } { # Export the host:port pair. set gdbport $debughost$portnum; - # Remember new exec file. - if { $arg == "" } { - if { ! [info exists 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 $" { } - } - } - } else { - set host_exec $arg - if [info exists server_exec] { unset server_exec } - } - - if { ! [info exists server_exec] } { - if [is_remote target] { - set server_exec [remote_download target $host_exec] - } else { - set server_exec $host_exec - } - } - # Fire off the debug agent if [target_info exists gdb_server_args] { # This flavour of gdbserver takes as arguments those specified @@ -175,52 +142,77 @@ proc gdb_load { arg } { # and the name of the executable file to be debugged. set server_spawn_id [remote_spawn target \ "$gdbserver $sockethost$portnum $server_exec"] - } + } - # We can't call close, because if gdbserver is local then that means - # that it will get a SIGHUP. - ## close -i $server_spawn_id - wait -nowait -i $server_spawn_id + # Wait for the server to produce at least one character of output. + expect { + -i $server_spawn_id + -notransfer + -re . { } + } - # Give it a little time to establish - sleep 1 + # We can't just call close, because if gdbserver is local then that means + # that it will get a SIGHUP. Doing it this way could also allow us to + # get at the inferior's input or output if necessary, and means that we + # don't need to redirect output. + expect_background { + -i $server_spawn_id + -re "." { } + eof { + # The spawn ID is already closed now (but not yet waited for). + wait -i $expect_out(spawn_id) + } + } - # tell gdb what file we are debugging - if { $arg != "" } { - if [gdb_file_cmd $arg] { - return -1; + 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 +} + +proc gdb_load { arg } { + global host_exec + global server_exec + + if { $arg == "" && $host_exec == "" } { + set host_exec [infer_host_exec] + } elseif { $arg != "" } { + set host_exec $arg + if [info exists server_exec] { unset server_exec } } - # attach to the "serial port" - gdb_target_cmd $protocol $gdbport; - - # do the real load if needed - if [target_info exists gdb_server_do_load] { - send_gdb "load\n" - set timeout 2400 - verbose "Timeout is now $timeout seconds" 2 - gdb_expect { - -re ".*$gdb_prompt $" { - if $verbose>1 then { - send_user "Loaded $arg into $GDB\n" - } - set timeout 30 - verbose "Timeout is now $timeout seconds" 2 - return 1 - } - -re "$gdb_prompt $" { - if $verbose>1 then { - perror "GDB couldn't load." - } - } - timeout { - if $verbose>1 then { - perror "Timed out trying to load $arg." - } - } - } + if { ! [info exists server_exec] } { + if [is_remote target] { + set server_exec [remote_download target $host_exec] + } else { + set server_exec $host_exec + } } - return 0; + set res [gdbserver_gdb_load $host_exec] + set protocol [lindex $res 0] + set gdbport [lindex $res 1] + + if { $arg != "" } { + if [gdb_file_cmd $arg] { + return -1 + } + } + gdb_target_cmd $protocol $gdbport } |