Fix gdb.threads/watchpoint-fork*.c compilation
authorPedro Alves <palves@redhat.com>
Tue, 1 Mar 2016 17:25:56 +0000 (17:25 +0000)
committerPedro Alves <palves@redhat.com>
Tue, 1 Mar 2016 17:25:56 +0000 (17:25 +0000)
This testcase currently fails to compile on Fedora 23:

 .../src/gdb/testsuite/gdb.threads/watchpoint-fork-mt.c: In function 'start':
 .../src/gdb/testsuite/gdb.threads/watchpoint-fork-mt.c:70:11: warning: implicit declaration of function 'pthread_yield' [-Wimplicit-function-declaration]
i = pthread_yield ();
    ^
 .../src/gdb/testsuite/gdb.threads/watchpoint-fork-child.c: In function 'forkoff':
 .../src/gdb/testsuite/gdb.threads/watchpoint-fork-child.c:114:8: warning: implicit declaration of function 'pthread_yield' [-Wimplicit-function-declaratio
 n]
     i = pthread_yield ();
 ^
 /tmp/ccUkNIsI.o: In function `start':
 .../src/gdb/testsuite/gdb.threads/watchpoint-fork-mt.c:70: undefined reference to `pthread_yield'
 (...)
 collect2: error: ld returned 1 exit status

 UNSUPPORTED: gdb.threads/watchpoint-fork.exp: child: multithreaded: Couldn't compile watchpoint-fork-child.c: unrecognized error
 UNTESTED: gdb.threads/watchpoint-fork.exp: child: multithreaded: watchpoint-fork.exp
 testcase .../src/gdb/testsuite/gdb.threads/watchpoint-fork.exp completed i

The glibc manual says, on _GNU_SOURCE:

 "You should define these macros by using ‘#define’ preprocessor
 directives at the top of your source code files. These directives must
 come before any #include of a system header file."

I instead put it in the header all the .c files of the testcase must
include anyway.

gdb/testsuite/ChangeLog:
2016-03-01  Pedro Alves  <palves@redhat.com>

* gdb.threads/watchpoint-fork-child.c: Include "watchpoint-fork.h"
before anything else.
* gdb.threads/watchpoint-fork-mt.c: Likewise.  Don't define
_GNU_SOURCE here.
* gdb.threads/watchpoint-fork-st.c: Include "watchpoint-fork.h"
before anything else.
* gdb.threads/watchpoint-fork.h: Define _GNU_SOURCE.

gdb/testsuite/ChangeLog
gdb/testsuite/gdb.threads/watchpoint-fork-child.c
gdb/testsuite/gdb.threads/watchpoint-fork-mt.c
gdb/testsuite/gdb.threads/watchpoint-fork-st.c
gdb/testsuite/gdb.threads/watchpoint-fork.h

index 49e87bc17e59b8174d088da63488974597de1acc..c992a59d889e4a9d9617ee38878c3ed3b2f20626 100644 (file)
@@ -1,3 +1,13 @@
+2016-03-01  Pedro Alves  <palves@redhat.com>
+
+       * gdb.threads/watchpoint-fork-child.c: Include "watchpoint-fork.h"
+       before anything else.
+       * gdb.threads/watchpoint-fork-mt.c: Likewise.  Don't define
+       _GNU_SOURCE here.
+       * gdb.threads/watchpoint-fork-st.c: Include "watchpoint-fork.h"
+       before anything else.
+       * gdb.threads/watchpoint-fork.h: Define _GNU_SOURCE.
+
 2016-03-01  Pedro Alves  <palves@redhat.com>
 
        * gdb.base/catch-fork-kill.c: Include <sys/wait.h>.
index 92ca0e5aeeaa0f82d3cef50968f908dac23019fa..b84a12201f0ecfc6a84c86e649085d8e92f9cd25 100644 (file)
@@ -17,6 +17,8 @@
    You should have received a copy of the GNU General Public License
    along with this program; if not, see <http://www.gnu.org/licenses/>.  */
 
+#include "watchpoint-fork.h"
+
 #include <string.h>
 #include <errno.h>
 #include <unistd.h>
@@ -24,8 +26,6 @@
 #include <signal.h>
 #include <stdio.h>
 
-#include "watchpoint-fork.h"
-
 /* `pid_t' may not be available.  */
 
 static volatile int usr1_got;
index f603b6df69b0b2e8b7456f5d8c696c771033758e..bc967ce51028a3da0a5514b6f3082ad1f777fc41 100644 (file)
    You should have received a copy of the GNU General Public License
    along with this program; if not, see <http://www.gnu.org/licenses/>.  */
 
+#include "watchpoint-fork.h"
+
 #include <assert.h>
 #include <unistd.h>
 #include <sys/wait.h>
 #include <stdio.h>
 #include <stdlib.h>
-
-/* pthread_yield is a GNU extension.  */
-#define _GNU_SOURCE
 #include <pthread.h>
 
 #include <asm/unistd.h>
 #include <unistd.h>
 #define gettid() syscall (__NR_gettid)
 
-#include "watchpoint-fork.h"
-
 /* Non-atomic `var++' should not hurt as we synchronize the threads by the STEP
    variable.  Hit-comments need to be duplicated there to catch both at-stops
    and behind-stops, depending on the target.  */
index 41ddf135764df63e822f1c62a7d5cec655262f05..bd3a3f24e1bd5a1a36b0a0a54a8cf0db17919448 100644 (file)
    You should have received a copy of the GNU General Public License
    along with this program; if not, see <http://www.gnu.org/licenses/>.  */
 
+#include "watchpoint-fork.h"
+
 #include <assert.h>
 #include <unistd.h>
 #include <sys/wait.h>
 #include <stdio.h>
 #include <stdlib.h>
 
-#include "watchpoint-fork.h"
-
 volatile int var;
 
 void
index 8ea193782e775e58afc95305dcd2de92aa3e6bc2..87307aeed0b851499cad1716155d8a29673dd62f 100644 (file)
@@ -17,6 +17,9 @@
    You should have received a copy of the GNU General Public License
    along with this program; if not, see <http://www.gnu.org/licenses/>.  */
 
+/* pthread_yield is a GNU extension.  */
+#define _GNU_SOURCE
+
 #ifdef THREAD
 #include <pthread.h>