]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
Fix GDB build failure when $development is false
authorYao Qi <yao.qi@linaro.org>
Mon, 8 Jan 2018 10:09:32 +0000 (10:09 +0000)
committerYao Qi <yao.qi@linaro.org>
Mon, 8 Jan 2018 10:16:28 +0000 (10:16 +0000)
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
Selftests are not available in a non-development build.
(gdb) maintenance selftest foo
Selftests are not available in a non-development build.
(gdb) maintenance info selftests
Selftests are not available in a non-development build.

gdb:

2018-01-08  Yao Qi  <yao.qi@linaro.org>
    Simon Marchi  <simon.marchi@ericsson.com>

* 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/testsuite:

2018-01-08  Simon Marchi  <simon.marchi@ericsson.com>

* gdb.gdb/unittest.exp: Match output in non-development mode.

gdb/ChangeLog
gdb/Makefile.in
gdb/configure
gdb/configure.ac
gdb/maint.c
gdb/testsuite/ChangeLog
gdb/testsuite/gdb.gdb/unittest.exp

index d2c6def2aac46ef2843a895bd80434e10c1c7e5f..05203a1f43b719241c64fdec5e190dfbac88e71c 100644 (file)
@@ -1,3 +1,16 @@
+2018-01-08  Yao Qi  <yao.qi@linaro.org>
+           Simon Marchi  <simon.marchi@ericsson.com>
+
+       * 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.
+
 2018-01-05  Pedro Alves  <palves@redhat.com>
 
        PR gdb/18653
index c0486c42ec65fe7d91852a58bde5d276c54aa15b..17b71c6e7c63fa782ee1d69a3dccfe1534fb249b 100644 (file)
@@ -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 \
index 7b250079dedcbcc39c5b44228f242020b82ccc20..db610f32fc26ccb043d0b50389e9ee120bbccdce 100755 (executable)
@@ -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
 
 
index 3e073b506ed68e918867ccacbc70c4e1691413f8..3db44ae758eaed61d39be9263c3406debf3d41e7 100644 (file)
@@ -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])
index a924f8363cd23209207e59d053f8c43aa9f7fc12..70e00110e52bbbddccd0a632e1d6d0737e804e3a 100644 (file)
@@ -939,16 +939,26 @@ 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);
+#else
+  printf_filtered (_("\
+Selftests are not available in a non-development build.\n"));
+#endif
 }
 
 static void
 maintenance_info_selftests (const char *arg, int from_tty)
 {
+#if GDB_SELF_TEST
   printf_filtered ("Registered selftests:\n");
   selftests::for_each_selftest ([] (const std::string &name) {
     printf_filtered (" - %s\n", name.c_str ());
   });
+#else
+  printf_filtered (_("\
+Selftests are not available in a non-development build.\n"));
+#endif
 }
 
 \f
index 6ceefccd8ca61a691f85475f08cb6b21ab48a22f..95485d2b85d9a3ebc773facc8fdeee7dfdee8248 100644 (file)
@@ -1,3 +1,7 @@
+2018-01-08  Simon Marchi  <simon.marchi@ericsson.com>
+
+       * gdb.gdb/unittest.exp: Match output in non-development mode.
+
 2018-01-05  Pedro Alves  <palves@redhat.com>
 
        PR gdb/18653
index 44e93290b6202a039ddc5ac47a3cf32c443f7fa2..1c835850b8d30ef9cb0ddebddf70ee79ec56f473 100644 (file)
 set do_xml_test [expr ![gdb_skip_xml_test]]
 
 gdb_start
-gdb_test "maintenance selftest" "Ran $decimal unit tests, 0 failed"
+
+set test "maintenance selftest"
+gdb_test_multiple $test $test {
+  -re "Ran ($decimal) unit tests, 0 failed\r\n$gdb_prompt $" {
+       set num_ran $expect_out(1,string)
+       gdb_assert "$num_ran > 0" $test
+  }
+
+  -re "Selftests are not available in a non-development build.\r\n$gdb_prompt $" {
+       unsupported $test
+  }
+}
 
 if { ![is_remote host] && $do_xml_test } {
     gdb_test "maintenance check xml-descriptions ${srcdir}/../features" \