public inbox for gdb-cvs@sourceware.org
help / color / mirror / Atom feed
* [binutils-gdb] gdb.threads/execl.c: Ensure all threads are started before execl.
@ 2023-03-07  0:58 John Baldwin
  0 siblings, 0 replies; only message in thread
From: John Baldwin @ 2023-03-07  0:58 UTC (permalink / raw)
  To: gdb-cvs

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

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

    gdb.threads/execl.c: Ensure all threads are started before execl.
    
    Use a pthread_barrier to ensure all threads are started before
    proceeding to the breakpoint where info threads output is checked.

Diff:
---
 gdb/testsuite/gdb.threads/execl.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/gdb/testsuite/gdb.threads/execl.c b/gdb/testsuite/gdb.threads/execl.c
index 8fb42e7e9ed..b9b42a29247 100644
--- a/gdb/testsuite/gdb.threads/execl.c
+++ b/gdb/testsuite/gdb.threads/execl.c
@@ -26,9 +26,13 @@
 #include <string.h>
 #include <stdlib.h>
 
+static pthread_barrier_t threads_started_barrier;
+
 void *
 thread_function (void *arg)
 {
+  pthread_barrier_wait (&threads_started_barrier);
+
   while (1)
     sleep (100);
   return NULL;
@@ -41,9 +45,13 @@ main (int argc, char* argv[])
   pthread_t thread2;
   char *new_image;
 
+  pthread_barrier_init (&threads_started_barrier, NULL, 3);
+
   pthread_create (&thread1, NULL, thread_function, NULL);
   pthread_create (&thread2, NULL, thread_function, NULL);
 
+  pthread_barrier_wait (&threads_started_barrier);
+
   new_image = malloc (strlen (argv[0]) + 2);
   strcpy (new_image, argv[0]);
   strcat (new_image, "1");

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2023-03-07  0:58 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-03-07  0:58 [binutils-gdb] gdb.threads/execl.c: Ensure all threads are started before execl John Baldwin

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).