From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp.polymtl.ca (smtp.polymtl.ca [132.207.4.11]) by sourceware.org (Postfix) with ESMTPS id 605D43858403 for ; Mon, 21 Mar 2022 15:00:40 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 605D43858403 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 22LF0Qgp018545 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 21 Mar 2022 11:00:31 -0400 DKIM-Filter: OpenDKIM Filter v2.11.0 smtp.polymtl.ca 22LF0Qgp018545 Received: from [172.16.0.95] (192-222-180-24.qc.cable.ebox.net [192.222.180.24]) (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 4B8FE1F0BB; Mon, 21 Mar 2022 11:00:26 -0400 (EDT) Message-ID: <54270fdb-4067-4be9-7621-e12f2d2e2361@polymtl.ca> Date: Mon, 21 Mar 2022 11:00:25 -0400 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.5.0 Subject: Re: [PATCH v4 2/4] gdb: testsuite: add new gdb_attach to check "attach" command Content-Language: tl To: Tiezhu Yang , gdb-patches@sourceware.org Cc: Pedro Alves References: <1647655887-13964-1-git-send-email-yangtiezhu@loongson.cn> <1647655887-13964-3-git-send-email-yangtiezhu@loongson.cn> From: Simon Marchi In-Reply-To: <1647655887-13964-3-git-send-email-yangtiezhu@loongson.cn> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Poly-FromMTA: (simark.ca [158.69.221.121]) at Mon, 21 Mar 2022 15:00:26 +0000 X-Spam-Status: No, score=-3039.2 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, NICE_REPLY_A, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_PASS, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org 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: , X-List-Received-Date: Mon, 21 Mar 2022 15:00:41 -0000 On 2022-03-18 22:11, Tiezhu Yang wrote: > This commit adds new gdb_attach to centralize the failure checking of > "attach" command. Return 0 if attach failed, otherwise return 1. > > Signed-off-by: Tiezhu Yang > --- > gdb/testsuite/lib/gdb.exp | 24 ++++++++++++++++++++++++ > 1 file changed, 24 insertions(+) > > diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp > index 89dcd0a..149a1c3 100644 > --- a/gdb/testsuite/lib/gdb.exp > +++ b/gdb/testsuite/lib/gdb.exp > @@ -5111,6 +5111,30 @@ proc can_spawn_for_attach { } { > return 1 > } > > +# Centralize the failure checking of "attach" command. > +# Return 0 if attach failed, otherwise return 1. > + > +proc gdb_attach { testpid args } { > + parse_args { > + {pattern ""} > + } > + > + if { [llength $args] != 0 } { > + error "Unexpected arguments: $args" > + } > + > + gdb_test_multiple "attach $testpid" "attach" { > + -re -wrap "Attaching to.*ptrace: Operation not permitted\\." { > + unsupported "$gdb_test_name (Operation not permitted)" > + return 0 > + } > + -re -wrap "$pattern" { > + pass $gdb_test_name > + return 1 > + } > + } > +} I guess we need a "return 0" at the end of the function, in case the test does fail? Simon