From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail.baldwin.cx (bigwig.baldwin.cx [66.216.25.90]) by sourceware.org (Postfix) with ESMTPS id 63EEC3857BB2 for ; Fri, 17 Feb 2023 20:38:26 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 63EEC3857BB2 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=FreeBSD.org Authentication-Results: sourceware.org; spf=fail smtp.mailfrom=FreeBSD.org Received: from gimli.baldwin.net (c-98-35-126-114.hsd1.ca.comcast.net [98.35.126.114]) by mail.baldwin.cx (Postfix) with ESMTPSA id C82321A84C70 for ; Fri, 17 Feb 2023 15:38:25 -0500 (EST) From: John Baldwin To: gdb-patches@sourceware.org Subject: [PATCH 3/5] gdb.threads/execl.c: Ensure all threads are started before execl. Date: Fri, 17 Feb 2023 12:38:16 -0800 Message-Id: <20230217203818.11287-4-jhb@FreeBSD.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20230217203818.11287-1-jhb@FreeBSD.org> References: <20230217203818.11287-1-jhb@FreeBSD.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.6.4 (mail.baldwin.cx [0.0.0.0]); Fri, 17 Feb 2023 15:38:26 -0500 (EST) X-Virus-Scanned: clamav-milter 0.103.1 at mail.baldwin.cx X-Virus-Status: Clean X-Spam-Status: No, score=-12.0 required=5.0 tests=BAYES_00,FORGED_SPF_HELO,GIT_PATCH_0,KAM_DMARC_STATUS,KHOP_HELO_FCRDNS,SPF_HELO_PASS,SPF_SOFTFAIL,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: Use a pthread_barrier to ensure all threads are started before proceeding to the breakpoint where info threads output is checked. --- 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 #include +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"); -- 2.38.1