Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Carl Love via Gdb-patches <gdb-patches@sourceware.org>
To: Simon Marchi <simon.marchi@polymtl.ca>,
	Pedro Franco de Carvalho <pedromfc@linux.ibm.com>,
	gdb-patches@sourceware.org
Cc: ulrich.weigand@de.ibm.com, tom@tromey.com, rogealve@br.ibm.com
Subject: RE: [PATCH] kill all threadapply processes at end of test
Date: Tue, 01 Jun 2021 08:42:04 -0700	[thread overview]
Message-ID: <5c776f594a2cb584423ba95d9b3d7ea1ae527def.camel@us.ibm.com> (raw)
In-Reply-To: <95a322dd-8059-8a48-acf5-07b965585995@polymtl.ca>

GDB maintainers, Simon:

On Fri, 2021-05-28 at 21:48 -0400, Simon Marchi wrote:
> <snip>
> Hi,
> 
> The code looks good to me, but please add a suitable commit message,
> it should contain a description and explanation of the observed
> problem and the chosen solution, such that somebody not familiar with
> the issue can understand the rationale of the patch.
> 
> Simon

I have added a commit message describing the issue with the test and
how the patch fixes the issue. 

Please let me know if the patch is acceptable for committing to GDB
mainline.   Thanks.

                   Carl

---------------------------------------------------------------------
Fix threadapply test

The current test case leaves detached processes running at the end of
the test.  This patch changes the test to use a barrier wait to ensure all
processes exit cleanly at the end of the tests.

gdb/testsuite/ChangeLog:

2021-05-22  Carl Love  <cel@us.ibm.com>

	* gdb.threads/threadapply.c: Add global mybarrier.
	(main): Add pthread_barrier_init.
	(thread_function): Replace while loop with myp increment and
	pthread_barrier_wait.
---
 gdb/testsuite/gdb.threads/threadapply.c | 12 +++++-------
 1 file changed, 5 insertions(+), 7 deletions(-)

diff --git a/gdb/testsuite/gdb.threads/threadapply.c b/gdb/testsuite/gdb.threads/threadapply.c
index 93a3fc8e82d..1ac99b07fc1 100644
--- a/gdb/testsuite/gdb.threads/threadapply.c
+++ b/gdb/testsuite/gdb.threads/threadapply.c
@@ -27,6 +27,7 @@ void *thread_function(void *arg); /* Pointer to function executed by each thread
 #define NUM 5
 
 unsigned int args[NUM+1];
+pthread_barrier_t mybarrier;
 
 int main() {
     int res;
@@ -35,6 +36,8 @@ int main() {
     void *thread_result;
     long i;
 
+    pthread_barrier_init(&mybarrier, NULL, NUM + 1);
+
     for (i = 0; i < NUM; i++)
       {
 	args[i] = 1; /* Init value.  */
@@ -69,12 +72,7 @@ void *thread_function(void *arg) {
     int my_number =  (long) arg;
     int *myp = (int *) &args[my_number];
 
-    /* Don't run forever.  Run just short of it :)  */
-    while (*myp > 0)
-      {
-	(*myp) ++;  /* Loop increment.  */
-      }
-
-    pthread_exit(NULL);
+    (*myp) ++;  /* Increment so parent knows child started.  */
+    pthread_barrier_wait(&mybarrier);
 }
 
-- 
2.27.0



  reply	other threads:[~2021-06-01 15:43 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-12 16:36 Carl Love via Gdb-patches
2021-05-13 14:30 ` Simon Marchi via Gdb-patches
2021-05-13 15:44 ` Tom Tromey
2021-05-13 18:10   ` Carl Love via Gdb-patches
2021-05-18 15:29     ` Carl Love via Gdb-patches
2021-05-18 21:56       ` Pedro Franco de Carvalho via Gdb-patches
2021-05-19  0:11         ` Pedro Franco de Carvalho via Gdb-patches
2021-05-20 15:42           ` Carl Love via Gdb-patches
2021-05-20 16:01           ` Carl Love via Gdb-patches
2021-05-24 15:30             ` Carl Love via Gdb-patches
2021-05-29  1:48               ` Simon Marchi via Gdb-patches
2021-06-01 15:42                 ` Carl Love via Gdb-patches [this message]
2021-06-01 16:08                   ` Simon Marchi via Gdb-patches
2021-06-02 15:08                     ` Carl Love via Gdb-patches

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=5c776f594a2cb584423ba95d9b3d7ea1ae527def.camel@us.ibm.com \
    --to=gdb-patches@sourceware.org \
    --cc=cel@us.ibm.com \
    --cc=pedromfc@linux.ibm.com \
    --cc=rogealve@br.ibm.com \
    --cc=simon.marchi@polymtl.ca \
    --cc=tom@tromey.com \
    --cc=ulrich.weigand@de.ibm.com \
    /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