public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Yao Qi <qiyaoltc@gmail.com>
To: gdb-patches@sourceware.org
Subject: [PATCH 2/2 master/8.1] Fix GDBserver build failure when $development is false
Date: Fri, 05 Jan 2018 10:35:00 -0000	[thread overview]
Message-ID: <1515148494-21578-2-git-send-email-yao.qi@linaro.org> (raw)
In-Reply-To: <1515148494-21578-1-git-send-email-yao.qi@linaro.org>

When we set bfd/development.sh:$development to false, GDBserver failed to
build,

selftest.o: In function `selftests::run_tests(char const*)':
binutils-gdb/gdb/gdbserver/../common/selftest.c:97:undefined reference to `selftests::reset()'
collect2: error: ld returned 1 exit status

selftest.o shouldn't be compiled and linked when $development is false.
With this patch, in release mode, GDBserver doesn't nothing with option
--selftest,

$ ./gdbserver --selftest=foo
$ ./gdbserver --selftest
$

gdb/gdbserver:

2018-01-05  Yao Qi  <yao.qi@linaro.org>

	* Makefile.in (OBS): Remove selftest.o.
	* configure.ac: Set srv_selftest_objs if $development is true.
	(GDBSERVER_DEPFILES): Append $srv_selftest_objs.
	* configure: Re-generated.
	* server.c (captured_main): Wrap variable selftest_filter with
	GDB_SELF_TEST.
---
 gdb/gdbserver/Makefile.in  | 1 -
 gdb/gdbserver/configure    | 3 ++-
 gdb/gdbserver/configure.ac | 3 ++-
 gdb/gdbserver/server.c     | 6 ++++++
 4 files changed, 10 insertions(+), 3 deletions(-)

diff --git a/gdb/gdbserver/Makefile.in b/gdb/gdbserver/Makefile.in
index caa94a6..3ce086d 100644
--- a/gdb/gdbserver/Makefile.in
+++ b/gdb/gdbserver/Makefile.in
@@ -261,7 +261,6 @@ 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/configure b/gdb/gdbserver/configure
index 835dcca..ca51321 100755
--- a/gdb/gdbserver/configure
+++ b/gdb/gdbserver/configure
@@ -5815,6 +5815,7 @@ fi
 
 
 if $development; then
+  srv_selftest_objs="selftest.o"
 
 $as_echo "#define GDB_SELF_TEST 1" >>confdefs.h
 
@@ -8287,7 +8288,7 @@ $as_echo "#define USE_XML 1" >>confdefs.h
   done
 fi
 
-GDBSERVER_DEPFILES="$srv_regobj $srv_tgtobj $srv_hostio_err_objs $srv_thread_depfiles $srv_host_obs"
+GDBSERVER_DEPFILES="$srv_regobj $srv_tgtobj $srv_hostio_err_objs $srv_thread_depfiles $srv_host_obs $srv_selftest_objs"
 GDBSERVER_LIBS="$srv_libs"
 
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the target supports __sync_*_compare_and_swap" >&5
diff --git a/gdb/gdbserver/configure.ac b/gdb/gdbserver/configure.ac
index 916384e..7ea3654 100644
--- a/gdb/gdbserver/configure.ac
+++ b/gdb/gdbserver/configure.ac
@@ -57,6 +57,7 @@ fi
 GDB_AC_LIBMCHECK(${libmcheck_default})
 
 if $development; then
+  srv_selftest_objs="selftest.o"
   AC_DEFINE(GDB_SELF_TEST, 1,
             [Define if self-testing features should be enabled])
 fi
@@ -410,7 +411,7 @@ if test "$srv_xmlfiles" != ""; then
   done
 fi
 
-GDBSERVER_DEPFILES="$srv_regobj $srv_tgtobj $srv_hostio_err_objs $srv_thread_depfiles $srv_host_obs"
+GDBSERVER_DEPFILES="$srv_regobj $srv_tgtobj $srv_hostio_err_objs $srv_thread_depfiles $srv_host_obs $srv_selftest_objs"
 GDBSERVER_LIBS="$srv_libs"
 
 dnl Check whether the target supports __sync_*_compare_and_swap.
diff --git a/gdb/gdbserver/server.c b/gdb/gdbserver/server.c
index 3367555..b6eefb4 100644
--- a/gdb/gdbserver/server.c
+++ b/gdb/gdbserver/server.c
@@ -3560,7 +3560,9 @@ captured_main (int argc, char *argv[])
   volatile int attach = 0;
   int was_running;
   bool selftest = false;
+#if GDB_SELF_TEST
   const char *selftest_filter = NULL;
+#endif
 
   while (*next_arg != NULL && **next_arg == '-')
     {
@@ -3684,7 +3686,9 @@ captured_main (int argc, char *argv[])
       else if (startswith (*next_arg, "--selftest="))
 	{
 	  selftest = true;
+#if GDB_SELF_TEST
 	  selftest_filter = *next_arg + strlen ("--selftest=");
+#endif
 	}
       else
 	{
@@ -3762,7 +3766,9 @@ captured_main (int argc, char *argv[])
 
   if (selftest)
     {
+#if GDB_SELF_TEST
       selftests::run_tests (selftest_filter);
+#endif
       throw_quit ("Quit");
     }
 
-- 
1.9.1

  reply	other threads:[~2018-01-05 10:35 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-01-05 10:35 [PATCH 1/2 master/8.1] Fix GDB " Yao Qi
2018-01-05 10:35 ` Yao Qi [this message]
2018-01-06 17:21   ` [PATCH 2/2 master/8.1] Fix GDBserver " Simon Marchi
2018-01-08  9:55     ` Yao Qi
2018-01-06 17:09 ` [PATCH 1/2 master/8.1] Fix GDB " Simon Marchi
2018-01-08  9:53   ` Yao Qi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1515148494-21578-2-git-send-email-yao.qi@linaro.org \
    --to=qiyaoltc@gmail.com \
    --cc=gdb-patches@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).