diff options
author | Daniel Jacobowitz <drow@false.org> | 2005-04-08 12:57:00 +0000 |
---|---|---|
committer | Daniel Jacobowitz <drow@false.org> | 2005-04-08 12:57:00 +0000 |
commit | 6f8eac0e511dcb7454312581371ee94e68d29587 (patch) | |
tree | 0a3772b1f5d87d6b381b5869ef1aeddda7d6c0f9 /gdb/testsuite/config | |
parent | 0228dfb97d58a54af8758840101975bf92903133 (diff) | |
download | gdb-6f8eac0e511dcb7454312581371ee94e68d29587.zip gdb-6f8eac0e511dcb7454312581371ee94e68d29587.tar.gz gdb-6f8eac0e511dcb7454312581371ee94e68d29587.tar.bz2 |
gdb/testsuite/
* Makefile.in (ALL_SUBDIRS): Add gdb.gdbserver.
* configure.ac: Create gdb.gdbserver/Makefile.
* configure: Regenerated.
* lib/gdbserver-support.exp: New file, derived from
config/gdbserver.exp.
* config/gdbserver.exp: Use gdbserver-support.exp.
* gdb.gdbserver/Makefile.in: New file.
* gdb.gdbserver/server.c: New file.
* gdb.gdbserver/server-run.exp: New file.
gdb/
* config/fnchange.lst: Add testsuite/gdb.gdbserver entries.
Diffstat (limited to 'gdb/testsuite/config')
-rw-r--r-- | gdb/testsuite/config/gdbserver.exp | 155 |
1 files changed, 9 insertions, 146 deletions
diff --git a/gdb/testsuite/config/gdbserver.exp b/gdb/testsuite/config/gdbserver.exp index 61db50e..9d133cf 100644 --- a/gdb/testsuite/config/gdbserver.exp +++ b/gdb/testsuite/config/gdbserver.exp @@ -1,7 +1,3 @@ -# Test framework for GDB (remote protocol) using a "gdbserver", -# ie. a debug agent running as a native process on the same or -# a different host. - # Copyright 2000, 2002, 2003, 2004, 2005 Free Software Foundation, Inc. # This program is free software; you can redistribute it and/or modify @@ -18,19 +14,15 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -# Please email any bugs, comments, and/or additions to this file to: -# bug-gdb@prep.ai.mit.edu - -# This file was written by Michael Snyder. (msnyder@redhat.com) +# Test framework for GDB (remote protocol) using a "gdbserver", +# ie. a debug agent running as a native process on the same or +# a different host. # # This module to be used for testing gdb with a "gdbserver" # built either from libremote or from gdb/gdbserver. # -# Load the basic testing library, and the remote stuff. -load_lib ../config/monitor.exp - # # To be addressed or set in your baseboard config file: # @@ -73,148 +65,19 @@ load_lib ../config/monitor.exp # Defaults to "localhost". Note: old gdbserver requires # that you define this, but libremote/gdbserver does not. # -# set_board_info socketport +# set_board_info gdb,socketport # Port id to use for socket connection. If not set explicitly, # it will start at "2345" and increment for each use. # +# The guts live in gdbserver-support.exp now. +load_lib gdbserver-support.exp -# -# gdb_load -- load a file into the debugger. -# return a -1 if anything goes wrong. -# - -global server_exec; -global portnum; -set portnum "2345"; - -proc gdbserver_gdb_load { server_exec } { - global portnum - - # Port id -- either specified in baseboard file, or managed here. - if [target_info exists gdb,socketport] { - set portnum [target_info gdb,socketport]; - } else { - # Bump the port number to avoid conflicts with hung ports. - incr portnum; - } - - # Extract the local and remote host ids from the target board struct. - - if [target_info exists sockethost] { - set debughost [target_info sockethost]; - } else { - set debughost "localhost:"; - } - # Extract the protocol - if [target_info exists gdb_protocol] { - set protocol [target_info gdb_protocol]; - } else { - set protocol "remote"; - } - - # Extract the name of the gdbserver, if known (default 'gdbserver'). - if [target_info exists gdb_server_prog] { - set gdbserver [target_info gdb_server_prog]; - } else { - set gdbserver "gdbserver"; - } - # Extract the socket hostname - if [target_info exists sockethost] { - set sockethost [target_info sockethost]; - } else { - set sockethost "" - } - - # Export the host:port pair. - set gdbport $debughost$portnum; - - # Fire off the debug agent - if [target_info exists gdb_server_args] { - # This flavour of gdbserver takes as arguments those specified - # in the board configuration file - set custom_args [target_info gdb_server_args]; - set server_spawn_id [remote_spawn target \ - "$gdbserver $custom_args"] - } else { - # This flavour of gdbserver takes as arguments the port information - # and the name of the executable file to be debugged. - set server_spawn_id [remote_spawn target \ - "$gdbserver $sockethost$portnum $server_exec"] - } - - # Wait for the server to produce at least one line and an additional - # character of output. This will wait until any TCP socket has been - # created, so that GDB can connect. - expect { - -i $server_spawn_id - -notransfer - -re ".*\n." { } - } - - # 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) - } - } - - 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 gdbserver_gdb_load { arg } { + return [gdbserver_spawn $arg ""] } 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 } - } - - if { ! [info exists server_exec] } { - if [is_remote target] { - set server_exec [remote_download target $host_exec /tmp/[file tail $host_exec].[pid]] - } else { - set server_exec $host_exec - } - } - - set res [gdbserver_gdb_load $server_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 + return [gdbserver_load $arg ""] } |