This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] Get wrapper.exp testcase passing with stdio gdbserver


Hi.

The wrapper.exp testcase is failing with stdio gdbserver.

make check RUNTESTFLAGS="--target_board=native-stdio-gdbserver wrapper.exp"
FAIL: gdb.server/wrapper.exp: continue to marker (the program is no longer running)
FAIL: gdb.server/wrapper.exp: print d

The problem is the "stdio" port argument isn't being properly
passed to gdbserver.

This patch fixes things by removing the clunky argument parsing
native-stdio-gdbserver.exp does to insert "stdio" and instead
adds a new setting that the board file can use to compute the "port"
argument.

Regression tested with native-gdbserver.exp, native-stdio-gdbserver.exp,
and remote-stdio-gdbserver.exp on amd64-linux.

2014-02-12  Doug Evans  <dje@google.com>

	testsuite/
	* 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.

diff --git a/gdb/testsuite/lib/gdbserver-support.exp b/gdb/testsuite/lib/gdbserver-support.exp
index 304bd14..8c91e28 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"
diff --git a/gdb/testsuite/boards/native-stdio-gdbserver.exp b/gdb/testsuite/boards/native-stdio-gdbserver.exp
index a1484e5..d1ae37c 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 73f86ad..807b9c3 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 } {


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]