From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id 1s2vAhQ4nWC2ewAAWB0awg (envelope-from ) for ; Thu, 13 May 2021 10:30:44 -0400 Received: by simark.ca (Postfix, from userid 112) id EFA031F11C; Thu, 13 May 2021 10:30:43 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-0.7 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,MAILING_LIST_MULTI,RDNS_DYNAMIC,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from sourceware.org (ip-8-43-85-97.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id 374FA1E783 for ; Thu, 13 May 2021 10:30:43 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 6DDD83896829; Thu, 13 May 2021 14:30:42 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 6DDD83896829 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1620916242; bh=cJGNwjQj37+Yqn7Jak9GGz61QtPrLGxAAuLu1RFgbgQ=; h=Subject:To:References:Date:In-Reply-To:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=P7mGTgkXxCN9dyfME8EEvWsNes3K7g0vUcWkcTjsJrCzDhQygZuTfmNEemGwYqUVr b/ZVk867uorAIdRBFPiqSNb4nNqgywZ/1aJFteZOxvuWLUp+jri6pYoyHfaSPcTCeM TbPhUcti2NFz/BtjpK7coQOJsGoauwoku0fk6I0U= Received: from smtp.polymtl.ca (smtp.polymtl.ca [132.207.4.11]) by sourceware.org (Postfix) with ESMTPS id CF00B385700D for ; Thu, 13 May 2021 14:30:39 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org CF00B385700D Received: from simark.ca (simark.ca [158.69.221.121]) (authenticated bits=0) by smtp.polymtl.ca (8.14.7/8.14.7) with ESMTP id 14DEUV2c021466 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 13 May 2021 10:30:37 -0400 DKIM-Filter: OpenDKIM Filter v2.11.0 smtp.polymtl.ca 14DEUV2c021466 Received: from [10.0.0.11] (192-222-157-6.qc.cable.ebox.net [192.222.157.6]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by simark.ca (Postfix) with ESMTPSA id 5774D1E783; Thu, 13 May 2021 10:30:28 -0400 (EDT) Subject: Re: [PATCH] kill all threadapply processes at end of test To: Carl Love , Ulrich.Weigand@de.ibm.com, gdb-patches@sourceware.org References: Message-ID: Date: Thu, 13 May 2021 10:30:28 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.7.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-Poly-FromMTA: (simark.ca [158.69.221.121]) at Thu, 13 May 2021 14:30:31 +0000 X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: Simon Marchi via Gdb-patches Reply-To: Simon Marchi Cc: pedromfc@br.ibm.com, rogealve@br.ibm.com Errors-To: gdb-patches-bounces@sourceware.org Sender: "Gdb-patches" 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 > > * 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