projects
/
platform
/
upstream
/
gdb.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Imported Upstream version 7.9
[platform/upstream/gdb.git]
/
gdb
/
testsuite
/
gdb.threads
/
watchthreads-reorder.c
diff --git
a/gdb/testsuite/gdb.threads/watchthreads-reorder.c
b/gdb/testsuite/gdb.threads/watchthreads-reorder.c
index
315104a
..
b28a0de
100644
(file)
--- a/
gdb/testsuite/gdb.threads/watchthreads-reorder.c
+++ b/
gdb/testsuite/gdb.threads/watchthreads-reorder.c
@@
-1,6
+1,6
@@
/* This testcase is part of GDB, the GNU debugger.
/* This testcase is part of GDB, the GNU debugger.
- Copyright 2009-201
4
Free Software Foundation, Inc.
+ Copyright 2009-201
5
Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@
-44,6
+44,8
@@
static pthread_mutex_t thread2_tid_mutex = PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_
static pthread_mutex_t terminate_mutex = PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP;
static pthread_mutex_t terminate_mutex = PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP;
+static pthread_barrier_t threads_started_barrier;
+
/* These variables must have lower in-memory addresses than thread1_rwatch and
thread2_rwatch so that they take their watchpoint slots. */
/* These variables must have lower in-memory addresses than thread1_rwatch and
thread2_rwatch so that they take their watchpoint slots. */
@@
-87,6
+89,8
@@
thread1_func (void *unused)
int i;
volatile int rwatch_store;
int i;
volatile int rwatch_store;
+ pthread_barrier_wait (&threads_started_barrier);
+
timed_mutex_lock (&thread1_tid_mutex);
/* THREAD1_TID_MUTEX must be already locked to avoid race. */
timed_mutex_lock (&thread1_tid_mutex);
/* THREAD1_TID_MUTEX must be already locked to avoid race. */
@@
-113,6
+117,8
@@
thread2_func (void *unused)
int i;
volatile int rwatch_store;
int i;
volatile int rwatch_store;
+ pthread_barrier_wait (&threads_started_barrier);
+
timed_mutex_lock (&thread2_tid_mutex);
/* THREAD2_TID_MUTEX must be already locked to avoid race. */
timed_mutex_lock (&thread2_tid_mutex);
/* THREAD2_TID_MUTEX must be already locked to avoid race. */
@@
-279,6
+285,8
@@
main (int argc, char **argv)
timed_mutex_lock (&terminate_mutex);
timed_mutex_lock (&terminate_mutex);
+ pthread_barrier_init (&threads_started_barrier, NULL, 3);
+
i = pthread_create (&thread1, NULL, thread1_func, NULL);
assert (i == 0);
i = pthread_create (&thread1, NULL, thread1_func, NULL);
assert (i == 0);
@@
-305,6
+313,11
@@
main (int argc, char **argv)
atexit (cleanup);
atexit (cleanup);
+ /* Wait until all threads are seen running. On Linux (at least),
+ new threads start stopped, and the debugger must resume them.
+ Need to wait for that before stopping GDB. */
+ pthread_barrier_wait (&threads_started_barrier);
+
printf ("Stopping GDB PID %lu.\n", (unsigned long) tracer);
if (tracer)
printf ("Stopping GDB PID %lu.\n", (unsigned long) tracer);
if (tracer)