From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id cQ7CEGLdo2DFGwAAWB0awg (envelope-from ) for ; Tue, 18 May 2021 11:29:38 -0400 Received: by simark.ca (Postfix, from userid 112) id 373901F11C; Tue, 18 May 2021 11:29:38 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-1.1 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,MAILING_LIST_MULTI,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from sourceware.org (server2.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 5314B1E783 for ; Tue, 18 May 2021 11:29:37 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 9B12E385481A; Tue, 18 May 2021 15:29:36 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 9B12E385481A DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1621351776; bh=BXTKuNW9kXtwdlTJbIlveGygWbr3LI5lWWoL6Zs42Jk=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=bZfJbfqFB5PvOWNjBf0wvhFQYoAswCRg+9WmrVBpiDEWBfXbjbFTLG4F1YjfcWMIa cL1mc2v/QgbsU617pqL2LJ9n3oCQyGtwMzvAmA2fS5Gsn5sLI06iNxZL/eO/6TNQd4 3lJNVVpsXhV6T2pquZREdwltP45iliTQ1sS9REa8= Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) by sourceware.org (Postfix) with ESMTPS id BDDF4385481A for ; Tue, 18 May 2021 15:29:33 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org BDDF4385481A Received: from pps.filterd (m0098396.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.43/8.16.0.43) with SMTP id 14IF3ltJ150214; Tue, 18 May 2021 11:29:24 -0400 Received: from ppma01wdc.us.ibm.com (fd.55.37a9.ip4.static.sl-reverse.com [169.55.85.253]) by mx0a-001b2d01.pphosted.com with ESMTP id 38mewebddr-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 18 May 2021 11:29:24 -0400 Received: from pps.filterd (ppma01wdc.us.ibm.com [127.0.0.1]) by ppma01wdc.us.ibm.com (8.16.0.43/8.16.0.43) with SMTP id 14IFE770007175; Tue, 18 May 2021 15:29:23 GMT Received: from b01cxnp22036.gho.pok.ibm.com (b01cxnp22036.gho.pok.ibm.com [9.57.198.26]) by ppma01wdc.us.ibm.com with ESMTP id 38j5x903e2-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 18 May 2021 15:29:23 +0000 Received: from b01ledav004.gho.pok.ibm.com (b01ledav004.gho.pok.ibm.com [9.57.199.109]) by b01cxnp22036.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 14IFTLMF7340666 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 18 May 2021 15:29:21 GMT Received: from b01ledav004.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 5954C112076; Tue, 18 May 2021 15:29:21 +0000 (GMT) Received: from b01ledav004.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 6EF2711206E; Tue, 18 May 2021 15:29:20 +0000 (GMT) Received: from li-e362e14c-2378-11b2-a85c-87d605f3c641.ibm.com (unknown [9.211.90.242]) by b01ledav004.gho.pok.ibm.com (Postfix) with ESMTP; Tue, 18 May 2021 15:29:20 +0000 (GMT) Message-ID: <74a4549303369eda07c3488ad0bf9dcfef9e00bc.camel@us.ibm.com> To: Tom Tromey , Carl Love via Gdb-patches , Simon Marchi Date: Tue, 18 May 2021 08:29:19 -0700 In-Reply-To: <8ee8a594f30dcdd1506487ea63ca3f8654c5f112.camel@us.ibm.com> References: <87im3m63ke.fsf@tromey.com> <8ee8a594f30dcdd1506487ea63ca3f8654c5f112.camel@us.ibm.com> Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.28.5 (3.28.5-14.el8) Mime-Version: 1.0 Content-Transfer-Encoding: 7bit X-TM-AS-GCONF: 00 X-Proofpoint-GUID: goikoy6vO9Hozi_2VB7ErYz2-ff2Ccdz X-Proofpoint-ORIG-GUID: goikoy6vO9Hozi_2VB7ErYz2-ff2Ccdz Subject: RE: [PATCH] kill all threadapply processes at end of test X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.391, 18.0.761 definitions=2021-05-18_07:2021-05-18, 2021-05-18 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 bulkscore=0 priorityscore=1501 lowpriorityscore=0 impostorscore=0 malwarescore=0 spamscore=0 clxscore=1011 suspectscore=0 mlxlogscore=999 phishscore=0 mlxscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2104190000 definitions=main-2105180109 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: Carl Love via Gdb-patches Reply-To: Carl Love Cc: pedromfc@br.ibm.com, Ulrich.Weigand@de.ibm.com, rogealve@br.ibm.com Errors-To: gdb-patches-bounces@sourceware.org Sender: "Gdb-patches" Tom, Simon, GDB maintainers: I looked at re-writing the test and using pthread barrier as suggested by Simon. I also went back and worked on my previous attempt to track the pids to be detached, then at the end re-attach the pids. I was able to get the second approach to work. The pthread barrier approach didn't seem to be very obvious how to implement. The following patch passes in a string to proc thr_apply_detach. Each pid is appended to the string before detaching from the pid. After the test is done, the test iterates thru the list of pids attaching to each one then killing the process. The patch has been tested on Power to ensure that it passes successfully and does not leave any threadapply processes running after the test finishes. Please let me know if you have suggestions on the patch and if it is accepatble to commit to mainline. Thanks. Carl ------------------------------------------------------ gdb/testsuite/ChangeLog: 2021-05-18 Carl Love * gdb.threads/threadapply.exp (thr_apply_detach): Add detach_pids argument and return. Add test, gdb_test_multiple, lappend pids to detach_pids. Add foreach i loop on detach_pids, add gdb_test tests to attach and kill each pid. --- gdb/testsuite/gdb.threads/threadapply.exp | 26 +++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/gdb/testsuite/gdb.threads/threadapply.exp b/gdb/testsuite/gdb.threads/threadapply.exp index ebc1cf15ad6..d39a9798d7c 100644 --- a/gdb/testsuite/gdb.threads/threadapply.exp +++ b/gdb/testsuite/gdb.threads/threadapply.exp @@ -69,7 +69,7 @@ gdb_test "down" "#0.*thread_function.*" "go down and check selected frame" # exits due to the command run via thread apply. Regression test for # PR threads/13217. -proc thr_apply_detach {thread_set} { +proc thr_apply_detach {thread_set detach_pids} { with_test_prefix "thread apply $thread_set" { global binfile global break_line @@ -84,15 +84,30 @@ proc thr_apply_detach {thread_set} { gdb_breakpoint "$break_line" gdb_continue_to_breakpoint "all threads started" + set test "get inferior pid" + set pid -1 + + gdb_test_multiple "info inferior 1" "$test" { + -re "process (\[0-9\]*).*" { + set pid $expect_out(1,string) + pass "$test" + } + } + + lappend detach_pids $pid + gdb_test "thread apply $thread_set detach" "Thread .*" gdb_test "thread" "No thread selected" "switched to no thread selected" + return $detach_pids } } # Test both "all" and a thread list, because those are implemented as # different commands in GDB. +set detach_pids "" + foreach thread_set {"all" "1.1 1.2 1.3"} { - thr_apply_detach $thread_set + set detach_pids [thr_apply_detach $thread_set $detach_pids] } # Test killing and removing inferiors from a command run via "thread @@ -229,3 +244,10 @@ 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 +foreach i $detach_pids { +# puts $i + gdb_test "attach $i" ".*" "Attach to $i" ".*A program is being debugged already.*" "y" + gdb_test "kill" ".*" "KILL $i" ".*Kill the program being debugged.*" "y" +} -- 2.27.0