Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Simon Marchi <simon.marchi@efficios.com>
To: gdb-patches@sourceware.org
Cc: Simon Marchi <simon.marchi@efficios.com>
Subject: [PATCH 3/4] Don't include selftests objects in build when unit tests are disabled
Date: Thu, 05 Mar 2020 19:30:00 -0000	[thread overview]
Message-ID: <20200305193011.25939-3-simon.marchi@efficios.com> (raw)
In-Reply-To: <20200305193011.25939-1-simon.marchi@efficios.com>

While working on the preceding selftests patches, I noticed that some
selftests-specific files are included in the build even when selftests
are disabled, namely disasm-selftest.c and gdbarch-selftests.c.  These
files are entirely #if'ed out when building with selftests disabled.

This is not a huge problem, but I think it would make more sense if
these files were simply not built.

With this patch, I propose to put all the selftests-specific source
files into a SELFTESTS_SRCS Makefile variable (even selftest-arch.c,
which is currently added by the configure script).

gdb/ChangeLog:

	* Makefile.in (SUBDIR_UNITTESTS_SRCS): Rename to...
	(SELFTESTS_SRCS): ... this.  Add disasm-selftests.c,
	gdbarch-selfselftests.c and selftest-arch.c.
	(SUBDIR_UNITTESTS_OBS): Rename to...
	(SELFTESTS_OBS): ... this.
	(COMMON_SFILES): Remove disasm-selftests.c and
	gdbarch-selftests.c.
	* configure.ac: Don't add selftest-arch.{c,o} to
	CONFIG_{SRCS,OBS}.
	* disasm-selftests.c, gdbarch-selftests.c: Remove GDB_SELF_TEST
	preprocessor conditions.
---
 gdb/Makefile.in         | 9 +++++----
 gdb/configure           | 4 ++--
 gdb/configure.ac        | 4 ++--
 gdb/disasm-selftests.c  | 5 -----
 gdb/gdbarch-selftests.c | 4 ----
 5 files changed, 9 insertions(+), 17 deletions(-)

diff --git a/gdb/Makefile.in b/gdb/Makefile.in
index 7c0a0aefbc..0e457f3ba1 100644
--- a/gdb/Makefile.in
+++ b/gdb/Makefile.in
@@ -420,7 +420,10 @@ SUBDIR_PYTHON_DEPS =
 SUBDIR_PYTHON_LDFLAGS =
 SUBDIR_PYTHON_CFLAGS =
 
-SUBDIR_UNITTESTS_SRCS = \
+SELFTESTS_SRCS = \
+	disasm-selftests.c \
+	gdbarch-selftests.c \
+	selftest-arch.c \
 	unittests/array-view-selftests.c \
 	unittests/child-path-selftests.c \
 	unittests/cli-utils-selftests.c \
@@ -454,7 +457,7 @@ SUBDIR_UNITTESTS_SRCS = \
 	unittests/vec-utils-selftests.c \
 	unittests/xml-utils-selftests.c
 
-SUBDIR_UNITTESTS_OBS = $(patsubst %.c,%.o,$(SUBDIR_UNITTESTS_SRCS))
+SELFTESTS_OBS = $(patsubst %.c,%.o,$(SELFTESTS_SRCS))
 
 SUBDIR_TARGET_SRCS = target/waitstatus.c
 SUBDIR_TARGET_OBS = $(patsubst %.c,%.o,$(SUBDIR_TARGET_SRCS))
@@ -995,7 +998,6 @@ COMMON_SFILES = \
 	debuginfod-support.c \
 	dictionary.c \
 	disasm.c \
-	disasm-selftests.c \
 	dummy-frame.c \
 	dwarf2/abbrev.c \
 	dwarf2/attribute.c \
@@ -1034,7 +1036,6 @@ COMMON_SFILES = \
 	gdb_obstack.c \
 	gdb_regex.c \
 	gdbarch.c \
-	gdbarch-selftests.c \
 	gdbtypes.c \
 	gnu-v2-abi.c \
 	gnu-v3-abi.c \
diff --git a/gdb/configure b/gdb/configure
index a8a1419326..5c463df462 100755
--- a/gdb/configure
+++ b/gdb/configure
@@ -19209,8 +19209,8 @@ if $enable_unittests; then
 $as_echo "#define GDB_SELF_TEST 1" >>confdefs.h
 
 
-  CONFIG_OBS="$CONFIG_OBS \$(SUBDIR_UNITTESTS_OBS) selftest-arch.o"
-  CONFIG_SRCS="$CONFIG_SRCS \$(SUBDIR_UNITTESTS_SRCS) selftest-arch.c"
+  CONFIG_OBS="$CONFIG_OBS \$(SELFTESTS_OBS)"
+  CONFIG_SRCS="$CONFIG_SRCS \$(SELFTESTS_SRCS)"
 
 fi
 
diff --git a/gdb/configure.ac b/gdb/configure.ac
index 76c396c6eb..b9dbe13232 100644
--- a/gdb/configure.ac
+++ b/gdb/configure.ac
@@ -2124,8 +2124,8 @@ AC_DEFINE(GDB_DEFAULT_HOST_CHARSET, "UTF-8",
           [Define to be a string naming the default host character set.])
 
 GDB_AC_SELFTEST([
-  CONFIG_OBS="$CONFIG_OBS \$(SUBDIR_UNITTESTS_OBS) selftest-arch.o"
-  CONFIG_SRCS="$CONFIG_SRCS \$(SUBDIR_UNITTESTS_SRCS) selftest-arch.c"
+  CONFIG_OBS="$CONFIG_OBS \$(SELFTESTS_OBS)"
+  CONFIG_SRCS="$CONFIG_SRCS \$(SELFTESTS_SRCS)"
 ])
 
 GDB_AC_TRANSFORM([gdb], [GDB_TRANSFORM_NAME])
diff --git a/gdb/disasm-selftests.c b/gdb/disasm-selftests.c
index b63a35ab1e..a24db7f224 100644
--- a/gdb/disasm-selftests.c
+++ b/gdb/disasm-selftests.c
@@ -19,8 +19,6 @@
 
 #include "defs.h"
 #include "disasm.h"
-
-#if GDB_SELF_TEST
 #include "gdbsupport/selftest.h"
 #include "selftest-arch.h"
 #include "gdbarch.h"
@@ -208,16 +206,13 @@ memory_error_test (struct gdbarch *gdbarch)
 }
 
 } // namespace selftests
-#endif /* GDB_SELF_TEST */
 
 void _initialize_disasm_selftests ();
 void
 _initialize_disasm_selftests ()
 {
-#if GDB_SELF_TEST
   selftests::register_test_foreach_arch ("print_one_insn",
 					 selftests::print_one_insn_test);
   selftests::register_test_foreach_arch ("memory_error",
 					 selftests::memory_error_test);
-#endif
 }
diff --git a/gdb/gdbarch-selftests.c b/gdb/gdbarch-selftests.c
index c99a900dbf..787a3f4058 100644
--- a/gdb/gdbarch-selftests.c
+++ b/gdb/gdbarch-selftests.c
@@ -18,7 +18,6 @@
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
 #include "defs.h"
-#if GDB_SELF_TEST
 #include "gdbsupport/selftest.h"
 #include "selftest-arch.h"
 #include "inferior.h"
@@ -158,14 +157,11 @@ register_to_value_test (struct gdbarch *gdbarch)
 }
 
 } // namespace selftests
-#endif /* GDB_SELF_TEST */
 
 void _initialize_gdbarch_selftests ();
 void
 _initialize_gdbarch_selftests ()
 {
-#if GDB_SELF_TEST
   selftests::register_test_foreach_arch ("register_to_value",
 					 selftests::register_to_value_test);
-#endif
 }
-- 
2.25.1


  reply	other threads:[~2020-03-05 19:30 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-03-05 19:30 [PATCH 1/4] gdb/selftest.m4: ensure $development is set Simon Marchi
2020-03-05 19:30 ` Simon Marchi [this message]
2020-03-05 19:30 ` [PATCH 2/4] Move sourcing of development.sh to GDB_AC_COMMON Simon Marchi
2020-03-05 19:30 ` [PATCH 4/4] Move gdb/selftest.m4 to gdbsupport/selftest.m4 Simon Marchi
2020-03-05 19:42 ` [PATCH 1/4] gdb/selftest.m4: ensure $development is set Simon Marchi
2020-03-12 18:07 ` Tom Tromey
2020-03-12 18:19   ` Simon Marchi

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=20200305193011.25939-3-simon.marchi@efficios.com \
    --to=simon.marchi@efficios.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