This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
[PATCH 1/2 master/8.1] Fix GDB build failure when $development is false
- From: Yao Qi <qiyaoltc at gmail dot com>
- To: gdb-patches at sourceware dot org
- Date: Fri, 5 Jan 2018 10:34:53 +0000
- Subject: [PATCH 1/2 master/8.1] Fix GDB build failure when $development is false
- Authentication-results: sourceware.org; auth=none
We don't build GDB selftests bits when $development is false. However, if
we turn bfd/development.sh:$development to false, common/selftest.c is
compiled which is not expected. It causes the build failure,
selftest.o: In function `selftests::run_tests(char const*)':
binutils-gdb/gdb/common/selftest.c:97: undefined reference to `selftests::reset()'
collect2: error: ld returned 1 exit status
I fix this issue by putting selftest.o selftest-arch.o into CONFIG_OBS
only when $development is true. After this is fixed, there are other
build failures in maint.c, this patch fixes them as well.
In the release mode, the output of these commands are:
(gdb) maintenance selftest
(gdb) maintenance selftest ffo
(gdb) maintenance info selftest
Registered selftests:
(gdb)
gdb:
2018-01-05 Yao Qi <yao.qi@linaro.org>
* Makefile.in (COMMON_SFILES): Remove selftest-arch.c and
common/selftest.c.
(COMMON_OBS): Remove selftest.o.
* configure.ac: Append selftest-arch.c and common/selftest.c to
CONFIG_SRCS. Append selftest-arch.o and selftest.o to COMMON_OBS.
* configure: Re-generated.
* maint.c (maintenance_selftest): Wrap selftests::run_tests with
GDB_SELF_TEST.
(maintenance_info_selftests): Likewise.
---
gdb/Makefile.in | 3 ---
gdb/configure | 4 ++--
gdb/configure.ac | 4 ++--
gdb/maint.c | 4 ++++
4 files changed, 8 insertions(+), 7 deletions(-)
diff --git a/gdb/Makefile.in b/gdb/Makefile.in
index c0486c4..17b71c6 100644
--- a/gdb/Makefile.in
+++ b/gdb/Makefile.in
@@ -1050,7 +1050,6 @@ COMMON_SFILES = \
remote-notif.c \
reverse.c \
rust-lang.c \
- selftest-arch.c \
sentinel-frame.c \
ser-event.c \
serial.c \
@@ -1139,7 +1138,6 @@ SFILES = \
common/ptid.c \
common/rsp-low.c \
common/run-time-clock.c \
- common/selftest.c \
common/signals.c \
common/signals-state-save-restore.c \
common/vec.c \
@@ -1555,7 +1553,6 @@ COMMON_OBS = $(DEPFILES) $(CONFIG_OBS) $(YYOBJ) \
ptid.o \
rsp-low.o \
run-time-clock.o \
- selftest.o \
signals.o \
signals-state-save-restore.o \
vec.o \
diff --git a/gdb/configure b/gdb/configure
index 7b25007..db610f3 100755
--- a/gdb/configure
+++ b/gdb/configure
@@ -17599,8 +17599,8 @@ if $development; then
$as_echo "#define GDB_SELF_TEST 1" >>confdefs.h
- CONFIG_OBS="$CONFIG_OBS \$(SUBDIR_UNITTESTS_OBS)"
- CONFIG_SRCS="$CONFIG_SRCS \$(SUBDIR_UNITTESTS_SRCS)"
+ CONFIG_OBS="$CONFIG_OBS \$(SUBDIR_UNITTESTS_OBS) selftest.o selftest-arch.o"
+ CONFIG_SRCS="$CONFIG_SRCS \$(SUBDIR_UNITTESTS_SRCS) common/selftest.c selftest-arch.c"
fi
diff --git a/gdb/configure.ac b/gdb/configure.ac
index 3e073b5..3db44ae 100644
--- a/gdb/configure.ac
+++ b/gdb/configure.ac
@@ -2293,8 +2293,8 @@ AC_DEFINE(GDB_DEFAULT_HOST_CHARSET, "UTF-8",
if $development; then
AC_DEFINE(GDB_SELF_TEST, 1,
[Define if self-testing features should be enabled])
- CONFIG_OBS="$CONFIG_OBS \$(SUBDIR_UNITTESTS_OBS)"
- CONFIG_SRCS="$CONFIG_SRCS \$(SUBDIR_UNITTESTS_SRCS)"
+ CONFIG_OBS="$CONFIG_OBS \$(SUBDIR_UNITTESTS_OBS) selftest.o selftest-arch.o"
+ CONFIG_SRCS="$CONFIG_SRCS \$(SUBDIR_UNITTESTS_SRCS) common/selftest.c selftest-arch.c"
fi
GDB_AC_TRANSFORM([gdb], [GDB_TRANSFORM_NAME])
diff --git a/gdb/maint.c b/gdb/maint.c
index a924f83..624a80e 100644
--- a/gdb/maint.c
+++ b/gdb/maint.c
@@ -939,16 +939,20 @@ show_per_command_cmd (const char *args, int from_tty)
static void
maintenance_selftest (const char *args, int from_tty)
{
+#if GDB_SELF_TEST
selftests::run_tests (args);
+#endif
}
static void
maintenance_info_selftests (const char *arg, int from_tty)
{
printf_filtered ("Registered selftests:\n");
+#if GDB_SELF_TEST
selftests::for_each_selftest ([] (const std::string &name) {
printf_filtered (" - %s\n", name.c_str ());
});
+#endif
}
--
1.9.1