+2014-04-16 Doug Evans <dje@google.com>
+
+ * 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 <aburgess@broadcom.com>
* gdb.base/memattr.exp: Improve regexps to handle memory regions
# 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 } {
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]
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 } {
# 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.
#
} 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] {
append gdbserver_command " $options"
}
if { $portnum != "" } {
- append gdbserver_command " :$portnum"
+ append gdbserver_command " [$get_comm_port $portnum]"
}
if { $arguments != "" } {
append gdbserver_command " $arguments"