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 1B9FF388451F for ; Fri, 18 Mar 2022 18:23:28 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 1B9FF388451F 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 22IINDbi029500 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 18 Mar 2022 14:23:19 -0400 DKIM-Filter: OpenDKIM Filter v2.11.0 smtp.polymtl.ca 22IINDbi029500 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) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPSA id 5DBAE1EDF0; Fri, 18 Mar 2022 14:23:13 -0400 (EDT) Message-ID: <98853a0a-4da0-bde5-fe11-640664742474@polymtl.ca> Date: Fri, 18 Mar 2022 14:23:12 -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 v3 2/4] gdb: testsuite: add new gdb_attach to check "attach" command Content-Language: tl To: Tiezhu Yang , Pedro Alves , gdb-patches@sourceware.org References: <1647525661-8607-1-git-send-email-yangtiezhu@loongson.cn> <1647525661-8607-3-git-send-email-yangtiezhu@loongson.cn> <0d25ccda-c26d-672f-6321-8a39aec9c1c6@palves.net> <25e1d92c-6b7e-9df3-640e-92227cf9e8ae@palves.net> From: Simon Marchi In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Poly-FromMTA: (simark.ca [158.69.221.121]) at Fri, 18 Mar 2022 18:23:13 +0000 X-Spam-Status: No, score=-3033.2 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, 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: Fri, 18 Mar 2022 18:23:29 -0000 > (1) parse_options > gdb/testsuite/lib/gdb.exp > proc gdb_attach { testpid {options {}} } { > parse_options { > {pattern ""} > } > > 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 > } > } > } > > gdb/testsuite/gdb.base/attach-pie-noexec.exp > if { ![gdb_attach $testpid] } { > kill_wait_spawned_process $test_spawn_id > return > } > > gdb/testsuite/gdb.base/jit-elf.exp > set attach_opts { > "pattern" "main.*at .*$::main_srcfile:.*" > } > > if { ![gdb_attach $testpid $attach_opts] } { > return 0 > } > > (2) parse_args > gdb/testsuite/lib/gdb.exp > 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 > } > } > } > > gdb/testsuite/gdb.base/attach-pie-noexec.exp > if { ![gdb_attach $testpid] } { > kill_wait_spawned_process $test_spawn_id > return > } > > gdb/testsuite/gdb.base/jit-elf.exp > if { ![gdb_attach $testpid \ > -pattern "main.*at .*$::main_srcfile:.*"] } { > return 0 > } > > I will wait for your feedback and then send v4 later. Go with parse_args (the version Pedro suggested). Thanks, Simon