From: Simon Marchi via Gdb-patches <gdb-patches@sourceware.org>
To: Carl Love <cel@us.ibm.com>,
Ulrich.Weigand@de.ibm.com, gdb-patches@sourceware.org
Cc: pedromfc@br.ibm.com, rogealve@br.ibm.com
Subject: Re: [PATCH] kill all threadapply processes at end of test
Date: Thu, 13 May 2021 10:30:28 -0400 [thread overview]
Message-ID: <c9da45df-037f-2483-6499-f493120168ce@polymtl.ca> (raw)
In-Reply-To: <e9d6547f4f9423c792ccadc926ca3240e94cc67e.camel@us.ibm.com>
Hi Carl,
On 2021-05-12 12:36 p.m., Carl Love via Gdb-patches wrote:
> The threadapply test performs a number of tests to detatch and attach
> threads. When the test is all done, some detatched threads are left
> running. The following patch adds code to the end of the patch to kill
> the processes that are still running.
From what I can see, there is not attach in that test, only detach. GDB
starts some processes itself, and tests that detaching in a "thread
apply" command is correctly handled. It's these processes that are
detached that are left running. Fortunately, they exit when the
threads' counters go past INT_MAX, making the condition `*myp > 0`
false. Unfortunately, it means they consume a lot of CPU for some time
after the test.
> Please let me know if this patch is acceptable. Thanks.
>
> Carl Love
>
> --------------------------------------
>
> gdb/testsuite/ChangeLog:
>
> 2021-05-12 Carl Love <cel@us.ibm.com>
>
> * gdb.threads/threadapply.exp: Add foreach loop to kill all remaining
> threadapply processes.
> ---
> gdb/testsuite/gdb.threads/threadapply.exp | 8 ++++++++
> 1 file changed, 8 insertions(+)
>
> diff --git a/gdb/testsuite/gdb.threads/threadapply.exp b/gdb/testsuite/gdb.threads/threadapply.exp
> index ebc1cf15ad6..b3457121e76 100644
> --- a/gdb/testsuite/gdb.threads/threadapply.exp
> +++ b/gdb/testsuite/gdb.threads/threadapply.exp
> @@ -229,3 +229,11 @@ proc kill_and_remove_inferior {thread_set} {
> foreach_with_prefix thread_set {"all" "1.1"} {
> kill_and_remove_inferior $thread_set
> }
> +
> +# Make sure all of the threadapply processes are terminated
> +set data [exec ps -e | grep threadapply]
> +
> +foreach line [split $data \n] {
> + scan $line {%d %s} threadid junk
> + exec kill -9 $threadid
> +}
We could use "kill" if we had no other choice, but it's a bit of a
rabbit hole to make that portable to all targets. Instead, could we
redesign the test so there isn't this CPU-consuming loop? Maybe use
a pthread barrier, such that when we detach, the all threads are
released and the program ends immediately. I don't know if that will
cause complications because the threads' backtraces won't be exactly
predictable, but it would good to give this a try.
Simon
next prev parent reply other threads:[~2021-05-13 14:30 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 [this message]
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
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=c9da45df-037f-2483-6499-f493120168ce@polymtl.ca \
--to=gdb-patches@sourceware.org \
--cc=Ulrich.Weigand@de.ibm.com \
--cc=cel@us.ibm.com \
--cc=pedromfc@br.ibm.com \
--cc=rogealve@br.ibm.com \
--cc=simon.marchi@polymtl.ca \
/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