Patchwork [2/2,master/8.1] Fix GDBserver build failure when $development is false

login
register
mail settings
Submitter Simon Marchi
Date Jan. 6, 2018, 5:20 p.m.
Message ID <090380b2-388c-2ba4-c7ee-d2a1f8e20e85@ericsson.com>
Download mbox | patch
Permalink /patch/25253/
State New
Headers show

Comments

Simon Marchi - Jan. 6, 2018, 5:20 p.m.
On 2018-01-05 05:34 AM, Yao Qi wrote:
> 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
> $

Hi Yao,

Same comment as the for the GDB patch, and here's a fixup patch that does what
I suggest.

Simon


From 1f610a553d226e00ef3832c518c45e36da6d0702 Mon Sep 17 00:00:00 2001
From: Simon Marchi <simon.marchi@ericsson.com>
Date: Sat, 6 Jan 2018 12:17:18 -0500
Subject: [PATCH] Same for gdbserver

---
 gdb/gdbserver/server.c                |  2 ++
 gdb/testsuite/gdb.server/unittest.exp | 13 ++++++++++---
 2 files changed, 12 insertions(+), 3 deletions(-)

Patch

diff --git a/gdb/gdbserver/server.c b/gdb/gdbserver/server.c
index 881ee48..3a4661d 100644
--- a/gdb/gdbserver/server.c
+++ b/gdb/gdbserver/server.c
@@ -3768,6 +3768,8 @@  captured_main (int argc, char *argv[])
     {
 #if GDB_SELF_TEST
       selftests::run_tests (selftest_filter);
+#else
+      printf (_("Selftests are not available in a non-development build.\n"));
 #endif
       throw_quit ("Quit");
     }
diff --git a/gdb/testsuite/gdb.server/unittest.exp b/gdb/testsuite/gdb.server/unittest.exp
index 646babc..e947ff2 100644
--- a/gdb/testsuite/gdb.server/unittest.exp
+++ b/gdb/testsuite/gdb.server/unittest.exp
@@ -30,12 +30,19 @@  set gdbserver_command "$gdbserver --selftest"

 set server_spawn_id [remote_spawn target $gdbserver_command]

+set test "unit tests"
 gdb_expect {
     -i $server_spawn_id
-    -re "Ran $decimal unit tests, 0 failed" {
-	pass "unit tests"
+    -re "Ran ($decimal) unit tests, 0 failed" {
+	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$" {
+	unsupported $test
+    }
+
     default {
-	fail "unit tests"
+	fail $test
     }
 }