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]

New board file to run the whole testsuite with a local gdbserver in extended-remote mode


This adds a new board file to run the whole testsuite with a local gdbserver in
extended-remote mode (gdbserver --multi).  Ideally, a test run this way
should give identical results to a run with the native target, but unfortunately,
there's still a bit to reach that state.

I should note that a test run with this shows a few hundred FAILs, with a lot of
cascading time outs, making the run take an uncomfortable long time, mostly related
to two things:

 - tests that do "attach" fail because the output in extended-remote
   mode is different compared to a native run.
 - many tests that do "attach" assume GDB can figure out what executable
   the process is running, and load it automatically (target_pid_to_exec_file).
   This doesn't work in the remote targets.
 - No follow/catch fork support in the remote protocol.

There many other FAILs due to missing gdbserver functionality (e.g., catch syscall),
but those don't bother me as much due to not causing cascading timeouts.

The results are stable though -- the set of tests that FAIL is consistent across runs.

gdbserver is presently spawned whenever gdb is.  The non-stop tests don't work with
this, since they flip non-stop on after gdb having connected to gdbserver,
which doesn't work presently.  I still haven't thought much on how to address
that (change gdb, or change the board file).

I think this should be good enough to check in as is, and improve as follow-ups.

Comments?

gdb/testsuite/
2012-01-25  Pedro Alves  <palves@redhat.com>

	* config/extended-gdbserver.exp: New file.
	* lib/gdbserver-support.exp (gdbserver_start_extended): Extend
	comment.
	(gdbserver_start_multi, mi_gdbserver_start_multi): New.
	* boards/native-extended-gdbserver.exp: New file.
---

 gdb/testsuite/boards/native-extended-gdbserver.exp |  150 ++++++++++++++++++++
 1 files changed, 150 insertions(+), 0 deletions(-)
 create mode 100644 gdb/testsuite/boards/native-extended-gdbserver.exp

diff --git a/gdb/testsuite/boards/native-extended-gdbserver.exp b/gdb/testsuite/boards/native-extended-gdbserver.exp
new file mode 100644
index 0000000..e7d3838
--- /dev/null
+++ b/gdb/testsuite/boards/native-extended-gdbserver.exp
@@ -0,0 +1,150 @@
+# Copyright 2011-2012 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, in extended-remote mode.
+#
+# 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-extended-gdbserver.exp \
+#   ${my_dejagnu_dir}/boards
+# bash$ cd ${build_dir}/gdb
+# bash$ make check RUNTESTFLAGS="--target_board=native-extended-gdbserver"
+
+load_generic_config "extended-gdbserver"
+
+# By default, dejagnu makes the board remote unless the board name
+# matches localhost.  Force it to be NOT remote.
+global board
+global board_info
+set board_info($board,isremote) 0
+
+process_multilib_options ""
+
+# The default compiler for this target.
+set_board_info compiler "[find_gcc]"
+
+# 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
+
+set_board_info sockethost "localhost:"
+
+# We will be using the extended GDB remote protocol.
+set_board_info gdb_protocol "extended-remote"
+
+# Test the copy of gdbserver in the build directory.
+set_board_info gdb_server_prog "../gdbserver/gdbserver"
+
+send_user "configuring for gdbserver local testing (extended-remote)\n";
+
+# We must load this explicitly here, and rename the procedures we want
+# to override.  If we didn't do this, given that mi-support.exp is
+# loaded later in the test files, the procedures loaded then would
+# override our definitions.
+load_lib mi-support.exp
+
+# Overriden in order to start a "gdbserver --multi" instance whenever
+# GDB is started.  Note nothing is needed for gdb_exit, since
+# gdbserver is started with --once, causing it to exit once GDB
+# disconnects.
+proc gdb_start { } {
+    # Spawn GDB.
+    default_gdb_start
+
+    # And then GDBserver, ready for extended-remote mode.
+    gdbserver_start_multi
+
+    return 0
+}
+
+# Likewise, for MI.
+#
+if { [info procs extended_gdbserver_mi_gdb_start] == "" } {
+    rename mi_gdb_start extended_gdbserver_mi_gdb_start
+}
+proc mi_gdb_start { args } {
+    # Spawn GDB.
+    set res [extended_gdbserver_mi_gdb_start $args]
+    if { $res } {
+	return $res
+    }
+
+    # And then GDBserver, ready for extended-remote mode.
+    mi_gdbserver_start_multi
+    return 0
+}
+
+# Overriden in order to set the remote exec-file whenever a file is
+# loaded to gdb.
+#
+proc gdb_load { arg } {
+    global gdb_prompt
+
+    if { $arg != "" } {
+	if [gdb_file_cmd $arg] then { return -1 }
+    }
+
+    send_gdb "set remote exec-file $arg\n"
+    gdb_expect {
+	-re "$gdb_prompt $" {}
+	timeout {
+	    perror "couldn't set the remote exec-file (timed out)."
+	    return -1
+	}
+    }
+
+    return 0
+}
+
+# Likewise, for MI.
+#
+if { [info procs extended_gdbserver_mi_gdb_load] == "" } {
+    rename mi_gdb_load extended_gdbserver_mi_gdb_load
+}
+proc mi_gdb_load { arg } {
+    global mi_gdb_prompt
+
+    set res [extended_gdbserver_mi_gdb_load $arg]
+    if { $res } then { return -1 }
+
+    send_gdb "100-gdb-set remote exec-file $arg\n"
+    gdb_expect 10 {
+	-re ".*100-gdb-set remote exec-file $arg\r\n100\\\^done\r\n$mi_gdb_prompt$" {
+	    verbose "set the remote exec-file to $arg."
+	}
+	timeout {
+	    perror "couldn't set the remote exec-file (timed out)."
+	}
+    }
+
+    return 0
+}
+
+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]
+}
diff --git a/gdb/testsuite/config/extended-gdbserver.exp b/gdb/testsuite/config/extended-gdbserver.exp
new file mode 100644
index 0000000..7166b66
--- /dev/null
+++ b/gdb/testsuite/config/extended-gdbserver.exp
@@ -0,0 +1,27 @@
+# Copyright 2000, 2002, 2003, 2004, 2005, 2007, 2008, 2009, 2010, 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 module is used for testing GDB using GDBserver in
+# extended-remote mode.
+#
+
+# The guts live in gdbserver-support.exp.
+load_lib gdbserver-support.exp
+
+proc gdb_reconnect { } {
+    return [gdbserver_reconnect]
+}
diff --git a/gdb/testsuite/lib/gdbserver-support.exp b/gdb/testsuite/lib/gdbserver-support.exp
index 11d9107..6d3a0e5 100644
--- a/gdb/testsuite/lib/gdbserver-support.exp
+++ b/gdb/testsuite/lib/gdbserver-support.exp
@@ -355,7 +355,9 @@ proc gdbserver_reconnect { } {
     return [gdb_target_cmd $gdbserver_protocol $gdbserver_gdbport]
 }

-# Start and connect to a gdbserver in extended mode.
+# Start and connect to a gdbserver in extended mode.  Note this frobs
+# $gdbserver_protocol, so should be used only from a board that
+# usually connects in target remote mode.
 proc gdbserver_start_extended { } {
     global gdbserver_protocol
     global gdbserver_gdbport
@@ -372,3 +374,32 @@ proc gdbserver_start_extended { } {

     return [gdb_target_cmd $gdbserver_protocol $gdbserver_gdbport]
 }
+
+# Start and connect to a gdbserver in extended/multi mode.  Unlike
+# gdbserver_start_extended, this does not frob $gdbserver_protocol.
+
+proc gdbserver_start_multi { } {
+    global gdbserver_protocol
+    global gdbserver_gdbport
+
+    set res [gdbserver_start "--multi" ""]
+    set gdbserver_protocol [lindex $res 0]
+    set gdbserver_gdbport [lindex $res 1]
+
+    return [gdb_target_cmd $gdbserver_protocol $gdbserver_gdbport]
+}
+
+# Start a gdbserver process in multi/extended mode, and have GDB
+# connect to it (MI version).  Return 0 on success, or non-zero on
+# failure.
+
+proc mi_gdbserver_start_multi { } {
+    global gdbserver_protocol
+    global gdbserver_gdbport
+
+    set res [gdbserver_start "--multi" ""]
+    set gdbserver_protocol [lindex $res 0]
+    set gdbserver_gdbport [lindex $res 1]
+
+    return [mi_gdb_target_cmd $gdbserver_protocol $gdbserver_gdbport]
+}


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