public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Simon Marchi <simon.marchi@ericsson.com>
To: Yao Qi <qiyaoltc@gmail.com>, <gdb-patches@sourceware.org>
Subject: Re: [PATCH 1/2 master/8.1] Fix GDB build failure when $development is false
Date: Sat, 06 Jan 2018 17:09:00 -0000	[thread overview]
Message-ID: <84552133-c6d7-3fd8-de88-bdbf5f7d6e1f@ericsson.com> (raw)
In-Reply-To: <1515148494-21578-1-git-send-email-yao.qi@linaro.org>

On 2018-01-05 05:34 AM, Yao Qi wrote:
> 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)

I would suggest printing a message when selftests are not available, instead
of doing nothing.  It could help people figure out why they are not running
as they would expect.

Also, it would allow changing gdb.gdb/unittest.exp to report "unsupported"
when make checking a non-development build, which is a bit more precise
than reporting a pass.

Otherwise, the patch LGTM.

Here's a fixup patch that does this, feel free to use it if you like the
idea.  Just as a sanity check, I added an assert in unittest.exp to make sure
that when tests are ran, we run at least one test.

Simon


From 19aaacbe970594e077f502e3212a5a22d4dc716e Mon Sep 17 00:00:00 2001
From: Simon Marchi <simon.marchi@ericsson.com>
Date: Sat, 6 Jan 2018 11:49:09 -0500
Subject: [PATCH] Print message when selftests are not available

---
 gdb/maint.c                        |  8 +++++++-
 gdb/testsuite/gdb.gdb/unittest.exp | 13 ++++++++++++-
 2 files changed, 19 insertions(+), 2 deletions(-)

diff --git a/gdb/maint.c b/gdb/maint.c
index 624a80e..70e0011 100644
--- a/gdb/maint.c
+++ b/gdb/maint.c
@@ -941,17 +941,23 @@ 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)
 {
-  printf_filtered ("Registered selftests:\n");
 #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
 }

diff --git a/gdb/testsuite/gdb.gdb/unittest.exp b/gdb/testsuite/gdb.gdb/unittest.exp
index 44e9329..1c83585 100644
--- a/gdb/testsuite/gdb.gdb/unittest.exp
+++ b/gdb/testsuite/gdb.gdb/unittest.exp
@@ -16,7 +16,18 @@
 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" \
-- 
2.7.4

  parent reply	other threads:[~2018-01-06 17:09 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-01-05 10:35 Yao Qi
2018-01-05 10:35 ` [PATCH 2/2 master/8.1] Fix GDBserver " Yao Qi
2018-01-06 17:21   ` Simon Marchi
2018-01-08  9:55     ` Yao Qi
2018-01-06 17:09 ` Simon Marchi [this message]
2018-01-08  9:53   ` [PATCH 1/2 master/8.1] Fix GDB " 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=84552133-c6d7-3fd8-de88-bdbf5f7d6e1f@ericsson.com \
    --to=simon.marchi@ericsson.com \
    --cc=gdb-patches@sourceware.org \
    --cc=qiyaoltc@gmail.com \
    /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).