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] boards/native-stdio-gdbserver.exp: New file.


Hi.

This is my stdio gdbserver "board file" to accompany
http://sourceware.org/ml/gdb-patches/2011-12/msg00022.html

I will check it in after the stdio gdbserver patch
and the boards/native-gdbserver.exp patch.

A careful reader may notice an odd difference like this between
the two board files:

native-gdbserver.exp:

+# Can't do hardware watchpoints, in general.
+set_board_info gdb,no_hardware_watchpoints 1

vs native-stdio-gdbserver.exp:

+# Can't do hardware watchpoints, in general.  But can for x86.
+if { [istarget i?86-*-*] || [istarget x86_64-*-* ] } {
+    ;# leave unset, testcases check for whether it is defined
+} else {
+    set_board_info gdb,no_hardware_watchpoints 1
+}

I'm open to suggestions for how to do this better.
My plan is to first check in native-gdbserver.exp as is,
so that it's a copy of what's in the wiki, and then spiff it up.
[And of course update the wiki to just refer to the gdb source tree.]


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

	* boards/native-stdio-gdbserver.exp: New file.

--- /dev/null	2011-11-17 12:50:30.979948001 -0800
+++ boards/native-stdio-gdbserver.exp	2011-12-02 11:33:06.000000000 -0800
@@ -0,0 +1,144 @@
+# Copyright 2011 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
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# This file is a dejagnu "board file" and is used to run the testsuite
+# natively with gdbserver using stdio for comms.
+#
+# To use this file:
+# bash$ touch ${my_dejagnu_dir}/my-dejagnu.exp
+# bash$ export DEJAGNU=${my_dejagnu_dir}/my-dejagnu.exp
+# bash$ mkdir ${my_dejagnu_dir}/boards
+# bash$ cp ${src_dir}/gdb/testsuite/boards/native-stdio-gdbserver.exp \
+#   ${my_dejagnu_dir}/boards
+# bash$ cd ${build_dir}/gdb
+# bash$ make check RUNTESTFLAGS="--target_board=native-stdio-gdbserver"
+
+load_generic_config "gdbserver"
+process_multilib_options ""
+
+# The default compiler for this target.
+set_board_info compiler "[find_gcc]"
+
+# This gdbserver can only run a process once per session.
+set_board_info gdb,do_reload_on_run 1
+
+# There's no support for argument-passing (yet).
+set_board_info noargs 1
+
+# Can't do input (or output) in the current gdbserver.
+set_board_info gdb,noinferiorio 1
+
+# gdbserver does not intercept target file operations and perform them
+# on the host.
+set_board_info gdb,nofileio 1
+
+# Can't do hardware watchpoints, in general.  But can for x86.
+if { [istarget i?86-*-*] || [istarget x86_64-*-* ] } {
+    ;# leave unset, testcases check for whether it is defined
+} else {
+    set_board_info gdb,no_hardware_watchpoints 1
+}
+
+set gdb_server_prog "[pwd]/../gdbserver/gdbserver"
+# Hack into sockethost to pass our peculiar remote connection string.
+set_board_info sockethost "stdio"
+set_board_info gdb,socketport ""
+set_board_info gdb,get_remote_address ${board}_get_remote_address
+set_board_info use_gdb_stub 1
+
+# We will be using the standard GDB remote protocol.
+set_board_info gdb_protocol "remote"
+# Test the copy of gdbserver in the build directory.
+set_board_info gdb_server_prog "$gdb_server_prog"
+
+set stdio_gdbserver_template "| @GDBSERVER_PROG@ @ARGS@ --wrapper /bin/sh -c 'exec \"$@\" >/dev/null </dev/null' exec -- stdio @PROG_AND_ARGS@"
+
+set stdio_gdbserver_command "--unset--"
+
+proc ${board}_get_remote_address { host port } {
+    global 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}_spawn { board cmd } {
+    global board_info
+
+    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
+    # ${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 baseboard [lindex [split $board "/"] 0]
+
+    # We don't spawn gdbserver here, that is done by the subsequent
+    # "target remote | ..." command.
+    set board_info($baseboard,isremote) 0
+    #set result [remote_spawn $board $cmd]
+    # Pretend as if we've started gdbserver, provide the test harness
+    # with what it's waiting for.
+    set result [remote_spawn $board "echo Listening on stdio"]
+    set board_info($baseboard,isremote) 1
+
+    return $result
+}
+
+proc ${board}_download { board host dest } {
+    return $host
+}
+
+proc ${board}_file { dest op args } {
+    if { $op == "delete" } {
+	return 0
+    }
+    return [eval [list standard_file $dest $op] $args]
+}


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