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 B0F3D3952013 for ; Thu, 17 Mar 2022 12:02:13 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org B0F3D3952013 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 22HC219p030630 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 17 Mar 2022 08:02:06 -0400 DKIM-Filter: OpenDKIM Filter v2.11.0 smtp.polymtl.ca 22HC219p030630 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 3AD511EA69; Thu, 17 Mar 2022 08:02:01 -0400 (EDT) Message-ID: <0596ed71-58be-6694-d2d4-aac666b555e4@polymtl.ca> Date: Thu, 17 Mar 2022 08:02:00 -0400 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.6.1 Subject: Re: [PATCH v2 4/4] gdb: testsuite: use gdb_attach to fix jit-elf.exp Content-Language: en-US To: Tiezhu Yang , gdb-patches@sourceware.org Cc: Pedro Alves References: <1647492213-21824-1-git-send-email-yangtiezhu@loongson.cn> <1647492213-21824-5-git-send-email-yangtiezhu@loongson.cn> From: Simon Marchi In-Reply-To: <1647492213-21824-5-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 Thu, 17 Mar 2022 12:02:01 +0000 X-Spam-Status: No, score=-3038.9 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: Thu, 17 Mar 2022 12:02:15 -0000 On 2022-03-17 00:43, Tiezhu Yang wrote: > If /proc/sys/kernel/yama/ptrace_scope is 1, when execute the following > command without superuser: > > make check-gdb TESTS="gdb.base/jit-elf.exp" > > we can see the following messages in gdb/testsuite/gdb.log: > > (gdb) attach 1650108 > Attaching to program: /home/yangtiezhu/build/gdb/testsuite/outputs/gdb.base/jit-elf/jit-elf-main, process 1650108 > ptrace: Operation not permitted. > (gdb) FAIL: gdb.base/jit-elf.exp: attach: one_jit_test-2: break here 1: attach > > use gdb_attach to fix the above issue. > > Signed-off-by: Tiezhu Yang > --- > gdb/testsuite/gdb.base/jit-elf.exp | 9 ++++----- > 1 file changed, 4 insertions(+), 5 deletions(-) > > diff --git a/gdb/testsuite/gdb.base/jit-elf.exp b/gdb/testsuite/gdb.base/jit-elf.exp > index 8a4c5b7..61ddb2a 100644 > --- a/gdb/testsuite/gdb.base/jit-elf.exp > +++ b/gdb/testsuite/gdb.base/jit-elf.exp > @@ -57,11 +57,10 @@ proc clean_reattach {} { > > clean_restart ${main_binfile} > > - set test "attach" > - gdb_test_multiple "attach $testpid" "$test" { > - -re "Attaching to program.*.*main.*at .*$main_srcfile:.*$gdb_prompt $" { > - pass "$test" > - } > + if {![gdb_attach $testpid { > + "pattern" "main.*at .*$::main_srcfile:.*" > + }]} { > + return > } I suggest writing it like this, it will be more readable: set attach_opts { "pattern" "main.*at .*$::main_srcfile:.*" } if { ![gdb_attach $testpid $attach_opts] } { return } I still get some failures when I run with ptrace_scope=1, meaning we are missing something. I think that the clean_reattach proc should return a value to indicate whether it worked, and the callers should return early as well on failure, all the way up to the top-level of the test. Simon