From ab19de874b887743e0862e6680e561f6fc4f02fa Mon Sep 17 00:00:00 2001 From: Doug Evans Date: Wed, 16 Apr 2014 10:40:41 -0700 Subject: [PATCH] Fix wrapper.exp testcase with stdio gdbserver. * lib/gdbserver-support.exp (gdbserver_default_get_remote_address): Add comment. (gdbserver_default_get_comm_port): New function. (gdbserver_start): Check if board file provided "gdbserver,get_comm_port" and use it if so. * boards/native-stdio-gdbserver.exp (sockethost): Set to "". (gdb,socketport): Set to "stdio". (gdbserver,get_comm_port): Set to ${board}_get_comm_port. (stdio_gdbserver_template): Delete. (${board}_get_remote_address): Update. (${board}_build_remote_cmd): Delete. (${board}_get_comm_port): New function. (${board}_spawn): Update. * boards/remote-stdio-gdbserver.exp (${board}_build_remote_cmd): Delete. (${board}_get_remote_address): Update. (${board}_get_comm_port): New function. --- gdb/testsuite/ChangeLog | 20 +++++++ .../boards/native-stdio-gdbserver.exp | 54 ++++--------------- .../boards/remote-stdio-gdbserver.exp | 38 +++---------- gdb/testsuite/lib/gdbserver-support.exp | 15 +++++- 4 files changed, 50 insertions(+), 77 deletions(-) diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog index a554ad76d1b..7c7bd348400 100644 --- a/gdb/testsuite/ChangeLog +++ b/gdb/testsuite/ChangeLog @@ -1,3 +1,23 @@ +2014-04-16 Doug Evans + + * lib/gdbserver-support.exp (gdbserver_default_get_remote_address): + Add comment. + (gdbserver_default_get_comm_port): New function. + (gdbserver_start): Check if board file provided + "gdbserver,get_comm_port" and use it if so. + * boards/native-stdio-gdbserver.exp (sockethost): Set to "". + (gdb,socketport): Set to "stdio". + (gdbserver,get_comm_port): Set to ${board}_get_comm_port. + (stdio_gdbserver_template): Delete. + (${board}_get_remote_address): Update. + (${board}_build_remote_cmd): Delete. + (${board}_get_comm_port): New function. + (${board}_spawn): Update. + * boards/remote-stdio-gdbserver.exp (${board}_build_remote_cmd): + Delete. + (${board}_get_remote_address): Update. + (${board}_get_comm_port): New function. + 2014-04-16 Andrew Burgess * gdb.base/memattr.exp: Improve regexps to handle memory regions diff --git a/gdb/testsuite/boards/native-stdio-gdbserver.exp b/gdb/testsuite/boards/native-stdio-gdbserver.exp index a1484e5b962..d1ae37c1c2e 100644 --- a/gdb/testsuite/boards/native-stdio-gdbserver.exp +++ b/gdb/testsuite/boards/native-stdio-gdbserver.exp @@ -29,60 +29,28 @@ set_board_info gdb,do_reload_on_run 1 # There's no support for argument-passing (yet). set_board_info noargs 1 -# Hack into sockethost to pass our peculiar remote connection string. -set_board_info sockethost "stdio" -set_board_info gdb,socketport "" +# Hack the host,port to pass our peculiar remote connection string. +set_board_info sockethost "" +set_board_info gdb,socketport "stdio" set_board_info gdb,get_remote_address ${board}_get_remote_address +set_board_info gdbserver,get_comm_port ${board}_get_comm_port + set_board_info use_gdb_stub 1 set_board_info exit_is_reliable 1 # We will be using the standard GDB remote protocol. set_board_info gdb_protocol "remote" -# The argument to pass to "target remote". -# We build this once we know how the testsuite will start gdbserver. -set stdio_gdbserver_template "| @GDBSERVER_PROG@ @ARGS@ stdio @PROG_AND_ARGS@" - # Used to pass a value between ${board}_spawn and ${board}_get_remote_address. set stdio_gdbserver_command "--unset--" proc ${board}_get_remote_address { host port } { global stdio_gdbserver_command - return $stdio_gdbserver_command + return "| $stdio_gdbserver_command" } -proc ${board}_build_remote_cmd { cmd } { - global stdio_gdbserver_template - - # First parse $cmd, picking out the various pieces. - set gdbserver_prog [lindex $cmd 0] - set args "" - set len [llength $cmd] - - for { set i 1 } { $i < $len } { incr i } { - set elm [lindex $cmd $i] - switch -- $elm { - --multi { - set args "$args $elm" - } - --once { - set args "$args $elm" - } - default { - break - } - } - } - - set prog_and_args [lrange $cmd $i end] - - set buf $stdio_gdbserver_template - - regsub {@GDBSERVER_PROG@} $buf $gdbserver_prog buf - regsub {@ARGS@} $buf $args buf - regsub {@PROG_AND_ARGS@} $buf $prog_and_args buf - - return $buf +proc ${board}_get_comm_port { port } { + return $port } proc ${board}_spawn { board cmd } { @@ -90,12 +58,10 @@ proc ${board}_spawn { board cmd } { verbose -log "${board}_spawn: $board $cmd" - # Convert the command to start gdbserver to something to pass to - # "target remote | ..." and save it for later retrieval by + # Save the command to start gdbserver for later retrieval by # ${board}_get_remote_address. global stdio_gdbserver_command - set stdio_gdbserver_command [${board}_build_remote_cmd $cmd] - verbose -log "gdbserver_command: $stdio_gdbserver_command" + set stdio_gdbserver_command $cmd set baseboard [lindex [split $board "/"] 0] diff --git a/gdb/testsuite/boards/remote-stdio-gdbserver.exp b/gdb/testsuite/boards/remote-stdio-gdbserver.exp index 73f86ad6d68..6508b76bb81 100644 --- a/gdb/testsuite/boards/remote-stdio-gdbserver.exp +++ b/gdb/testsuite/boards/remote-stdio-gdbserver.exp @@ -73,40 +73,14 @@ proc get_remote_login { } { return $result } -proc ${board}_build_remote_cmd { cmd } { - set stdio_gdbserver_template "| @RSH_CMD@ @GDBSERVER_PROG@ @ARGS@ stdio @PROG_AND_ARGS@" - - # First parse $cmd, picking out the various pieces. - set gdbserver_prog [lindex $cmd 0] - set args "" - set len [llength $cmd] - - for { set i 1 } { $i < $len } { incr i } { - set elm [lindex $cmd $i] - switch $elm { - --multi { - set args "$args $elm" - } - --once { - set args "$args $elm" - } - default { - break - } - } - } - - set prog_and_args [lrange $cmd $i end] - - set buf $stdio_gdbserver_template - +proc ${board}_get_remote_address { host port } { + global stdio_gdbserver_command set rsh_cmd "[board_info [target_info name] rsh_prog] [get_remote_login]" - regsub {@RSH_CMD@} $buf $rsh_cmd buf - regsub {@GDBSERVER_PROG@} $buf $gdbserver_prog buf - regsub {@ARGS@} $buf $args buf - regsub {@PROG_AND_ARGS@} $buf $prog_and_args buf + return "| $rsh_cmd $stdio_gdbserver_command" +} - return $buf +proc ${board}_get_comm_port { port } { + return $port } proc ${board}_download { board host dest } { diff --git a/gdb/testsuite/lib/gdbserver-support.exp b/gdb/testsuite/lib/gdbserver-support.exp index 304bd14bcad..8c91e281f22 100644 --- a/gdb/testsuite/lib/gdbserver-support.exp +++ b/gdb/testsuite/lib/gdbserver-support.exp @@ -189,9 +189,17 @@ proc gdbserver_download_current_prog { } { # Default routine to compute the argument to "target remote". proc gdbserver_default_get_remote_address { host port } { + # Historically HOST included the trailing ":". + # To avoid breaking any board files out there we leave things alone. return "$host$port" } +# Default routine to compute the "comm" argument for gdbserver. + +proc gdbserver_default_get_comm_port { port } { + return ":$port" +} + # Start a gdbserver process with initial OPTIONS and trailing ARGUMENTS. # The port will be filled in between them automatically. # @@ -223,6 +231,11 @@ proc gdbserver_start { options arguments } { } else { set get_remote_address gdbserver_default_get_remote_address } + if [target_info exists gdbserver,get_comm_port] { + set get_comm_port [target_info gdbserver,get_comm_port] + } else { + set get_comm_port gdbserver_default_get_comm_port + } # Extract the protocol if [target_info exists gdb_protocol] { @@ -251,7 +264,7 @@ proc gdbserver_start { options arguments } { append gdbserver_command " $options" } if { $portnum != "" } { - append gdbserver_command " :$portnum" + append gdbserver_command " [$get_comm_port $portnum]" } if { $arguments != "" } { append gdbserver_command " $arguments" -- 2.30.2