public inbox for gdb-cvs@sourceware.org
help / color / mirror / Atom feed
From: John Baldwin <jhb@sourceware.org>
To: gdb-cvs@sourceware.org
Subject: [binutils-gdb] gdb.threads/next-bp-other-thread.c: Ensure child thread is started.
Date: Tue,  7 Mar 2023 00:58:50 +0000 (GMT)	[thread overview]
Message-ID: <20230307005850.2735F3858C20@sourceware.org> (raw)

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=f173b2fc9d03d9e56376ed9ad4c06e82949060dd

commit f173b2fc9d03d9e56376ed9ad4c06e82949060dd
Author: John Baldwin <jhb@FreeBSD.org>
Date:   Mon Mar 6 16:55:22 2023 -0800

    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.

Diff:
---
 gdb/testsuite/gdb.threads/next-bp-other-thread.c | 9 +++++++++
 1 file changed, 9 insertions(+)

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);
 }

                 reply	other threads:[~2023-03-07  0:58 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20230307005850.2735F3858C20@sourceware.org \
    --to=jhb@sourceware.org \
    --cc=gdb-cvs@sourceware.org \
    /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).