aboutsummaryrefslogtreecommitdiff
path: root/gdb/gdbserver
diff options
context:
space:
mode:
authorYao Qi <yao.qi@linaro.org>2017-08-18 09:20:43 +0100
committerYao Qi <yao.qi@linaro.org>2017-08-18 09:20:43 +0100
commit6d580b635f8963183540b816b20bb9c240154497 (patch)
tree4f5c35be79f4293a8c716415ba104debe1a27160 /gdb/gdbserver
parent86dcbf50fe5f59fbc35f38f02ab6c1803c29f383 (diff)
downloadbinutils-6d580b635f8963183540b816b20bb9c240154497.zip
binutils-6d580b635f8963183540b816b20bb9c240154497.tar.gz
binutils-6d580b635f8963183540b816b20bb9c240154497.tar.bz2
GDBserver self tests
This patch uses GDB self test in GDBserver. The self tests are run if GDBserver is started with option --selftest. gdb: 2017-08-18 Yao Qi <yao.qi@linaro.org> * NEWS: Mention GDBserver's new option "--selftest". * Makefile.in (SFILES): Remove selftest.c, add common/selftest.c. * selftest.c: Move it to common/selftest.c. * selftest.h: Move it to common/selftest.h. * selftest-arch.c (reset): New function. (tests_with_arch): Call reset. gdb/gdbserver: 2017-08-18 Yao Qi <yao.qi@linaro.org> * Makefile.in (OBS): Add selftest.o. * configure.ac: AC_DEFINE GDB_SELF_TEST if $development. * configure, config.in: Re-generated. * server.c: Include common/sefltest.h. (captured_main): Handle option --selftest. gdb/testsuite: 2017-08-18 Yao Qi <yao.qi@linaro.org> * gdb.server/unittest.exp: New. gdb/doc: 2017-08-18 Yao Qi <yao.qi@linaro.org> * gdb.texinfo (Server): Document "--selftest".
Diffstat (limited to 'gdb/gdbserver')
-rw-r--r--gdb/gdbserver/ChangeLog8
-rw-r--r--gdb/gdbserver/Makefile.in1
-rw-r--r--gdb/gdbserver/config.in3
-rwxr-xr-xgdb/gdbserver/configure6
-rw-r--r--gdb/gdbserver/configure.ac5
-rw-r--r--gdb/gdbserver/server.c28
6 files changed, 49 insertions, 2 deletions
diff --git a/gdb/gdbserver/ChangeLog b/gdb/gdbserver/ChangeLog
index 0059b913..04dac06 100644
--- a/gdb/gdbserver/ChangeLog
+++ b/gdb/gdbserver/ChangeLog
@@ -1,3 +1,11 @@
+2017-08-18 Yao Qi <yao.qi@linaro.org>
+
+ * Makefile.in (OBS): Add selftest.o.
+ * configure.ac: AC_DEFINE GDB_SELF_TEST if $development.
+ * configure, config.in: Re-generated.
+ * server.c: Include common/sefltest.h.
+ (captured_main): Handle option --selftest.
+
2017-08-09 Yao Qi <yao.qi@linaro.org>
* configure.srv (srv_i386_regobj): Remove i386-avx.o,
diff --git a/gdb/gdbserver/Makefile.in b/gdb/gdbserver/Makefile.in
index 4e0080e..6cd0959 100644
--- a/gdb/gdbserver/Makefile.in
+++ b/gdb/gdbserver/Makefile.in
@@ -258,6 +258,7 @@ OBS = \
regcache.o \
remote-utils.o \
rsp-low.o \
+ selftest.o \
server.o \
signals.o \
signals-state-save-restore.o \
diff --git a/gdb/gdbserver/config.in b/gdb/gdbserver/config.in
index 34a7443..5dacbac 100644
--- a/gdb/gdbserver/config.in
+++ b/gdb/gdbserver/config.in
@@ -8,6 +8,9 @@
/* Define to 1 if using `alloca.c'. */
#undef C_ALLOCA
+/* Define if self-testing features should be enabled */
+#undef GDB_SELF_TEST
+
/* Define to 1 if you have `alloca', as a function or macro. */
#undef HAVE_ALLOCA
diff --git a/gdb/gdbserver/configure b/gdb/gdbserver/configure
index 35aeabc..30aa95b 100755
--- a/gdb/gdbserver/configure
+++ b/gdb/gdbserver/configure
@@ -5813,6 +5813,12 @@ fi
fi
+if $development; then
+
+$as_echo "#define GDB_SELF_TEST 1" >>confdefs.h
+
+fi
+
case ${build_alias} in
"") build_noncanonical=${build} ;;
*) build_noncanonical=${build_alias} ;;
diff --git a/gdb/gdbserver/configure.ac b/gdb/gdbserver/configure.ac
index 4ea7913..36e21c5 100644
--- a/gdb/gdbserver/configure.ac
+++ b/gdb/gdbserver/configure.ac
@@ -56,6 +56,11 @@ else
fi
GDB_AC_LIBMCHECK(${libmcheck_default})
+if $development; then
+ AC_DEFINE(GDB_SELF_TEST, 1,
+ [Define if self-testing features should be enabled])
+fi
+
ACX_NONCANONICAL_TARGET
ACX_NONCANONICAL_HOST
diff --git a/gdb/gdbserver/server.c b/gdb/gdbserver/server.c
index 3838351..8200aa1 100644
--- a/gdb/gdbserver/server.c
+++ b/gdb/gdbserver/server.c
@@ -40,6 +40,8 @@
#include "job-control.h"
#include "environ.h"
+#include "common/selftest.h"
+
/* The environment to pass to the inferior when creating it. */
static gdb_environ our_environ;
@@ -3521,6 +3523,7 @@ captured_main (int argc, char *argv[])
volatile int multi_mode = 0;
volatile int attach = 0;
int was_running;
+ bool selftest = false;
while (*next_arg != NULL && **next_arg == '-')
{
@@ -3639,6 +3642,8 @@ captured_main (int argc, char *argv[])
startup_with_shell = false;
else if (strcmp (*next_arg, "--once") == 0)
run_once = 1;
+ else if (strcmp (*next_arg, "--selftest") == 0)
+ selftest = true;
else
{
fprintf (stderr, "Unknown argument: %s\n", *next_arg);
@@ -3654,7 +3659,8 @@ captured_main (int argc, char *argv[])
port = *next_arg;
next_arg++;
}
- if (port == NULL || (!attach && !multi_mode && *next_arg == NULL))
+ if ((port == NULL || (!attach && !multi_mode && *next_arg == NULL))
+ && !selftest)
{
gdbserver_usage (stderr);
exit (1);
@@ -3670,7 +3676,8 @@ captured_main (int argc, char *argv[])
starting the inferior. Inferiors created in this scenario have
stdin,stdout redirected. So do this here before we call
start_inferior. */
- remote_prepare (port);
+ if (port != NULL)
+ remote_prepare (port);
bad_attach = 0;
pid = 0;
@@ -3711,6 +3718,12 @@ captured_main (int argc, char *argv[])
own_buf = (char *) xmalloc (PBUFSIZ + 1);
mem_buf = (unsigned char *) xmalloc (PBUFSIZ);
+ if (selftest)
+ {
+ selftests::run_tests ();
+ throw_quit ("Quit");
+ }
+
if (pid == 0 && *next_arg != NULL)
{
int i, n;
@@ -4507,3 +4520,14 @@ handle_target_event (int err, gdb_client_data client_data)
return 0;
}
+
+#if GDB_SELF_TEST
+namespace selftests
+{
+
+void
+reset ()
+{}
+
+} // namespace selftests
+#endif /* GDB_SELF_TEST */