summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Baldwin <jhb@FreeBSD.org>2023-03-06 16:55:22 -0800
committerJohn Baldwin <jhb@FreeBSD.org>2023-03-06 16:55:22 -0800
commitf173b2fc9d03d9e56376ed9ad4c06e82949060dd (patch)
tree6f93e7f4f0a1cc06f9f7594560ee6eb42a8642c7
parent5c1e53c99cf08b55fda078902a7363823e8638cb (diff)
downloadbinutils-gdb-f173b2fc9d03d9e56376ed9ad4c06e82949060dd.tar.gz
gdb.threads/next-bp-other-thread.c: Ensure child thread is started.
Use a pthread_barrier to ensure the child thread is started before the main thread gets to the first breakpoint.
-rw-r--r--gdb/testsuite/gdb.threads/next-bp-other-thread.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/gdb/testsuite/gdb.threads/next-bp-other-thread.c b/gdb/testsuite/gdb.threads/next-bp-other-thread.c
index 60aa029464c..33c6ec11982 100644
--- a/gdb/testsuite/gdb.threads/next-bp-other-thread.c
+++ b/gdb/testsuite/gdb.threads/next-bp-other-thread.c
@@ -22,9 +22,13 @@
/* Always zero, used in breakpoint condition. */
volatile int global_zero;
+static pthread_barrier_t threads_started_barrier;
+
void *
child_function (void *arg)
{
+ pthread_barrier_wait (&threads_started_barrier);
+
while (1)
{
usleep (1); /* set breakpoint child here */
@@ -39,7 +43,12 @@ main (void)
pthread_t child_thread;
int res;
+ pthread_barrier_init (&threads_started_barrier, NULL, 2);
+
res = pthread_create (&child_thread, NULL, child_function, NULL);
+
+ pthread_barrier_wait (&threads_started_barrier);
+
sleep (2); /* set wait-thread breakpoint here */
exit (EXIT_SUCCESS);
}