From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wr1-f49.google.com (mail-wr1-f49.google.com [209.85.221.49]) by sourceware.org (Postfix) with ESMTPS id EA7E23858D1E for ; Thu, 17 Mar 2022 16:50:34 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org EA7E23858D1E Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=palves.net Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-wr1-f49.google.com with SMTP id b19so8153126wrh.11 for ; Thu, 17 Mar 2022 09:50:34 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent:subject :content-language:to:cc:references:from:in-reply-to :content-transfer-encoding; bh=BCrtVg8q5aMlHQW+VsRQ0Hre6WP8A++WjtzMSQ+fH7I=; b=fZ43HsVdIu19VC5FS8gZHvASGNUmdq+f8JL8WUyRbAku3GI2kGB9v8Q1ozBFUnMw20 flCzvn/ioL3eOhEXft+rflyiy3eVUR9z35KfvUf6cf9cg9GMOsRPvuRuAC6jioHlw+7L VrJdtlK3w89/x3Nu5A6cmJZ2S8sp3G5loIZrCBRtMcNYZc4UMv++kW2MN6mBvX7ihG6Q rocTxUknN8CEbZVMuzqcRFhb6jG9X57Oujh9De56mLx3ZRTpr72mdrh+8rXKDtChPlE5 Z4l/6mEo7nymUWwFuebXjBouPPz/nEainIhZt3bxI+3Y2xxCrfeWr4I1YZglnV3oKJjO w1lA== X-Gm-Message-State: AOAM5332Xb3T8Pou9gmqWMLfYfr4SM6iraZewyZikkvhsG9F6RsMTi7X UByZ3nUBhv2HTFWSI0OaQMA= X-Google-Smtp-Source: ABdhPJzIqhAcddbht5mPXDE3FdYyNBn+SWY89fHXAUdBZ2L+XtHqy/5F6o7U+c82o0PdF+wVpOXUNQ== X-Received: by 2002:adf:fdc8:0:b0:1f1:f134:433c with SMTP id i8-20020adffdc8000000b001f1f134433cmr4703708wrs.305.1647535833853; Thu, 17 Mar 2022 09:50:33 -0700 (PDT) Received: from ?IPV6:2001:8a0:f924:2600:209d:85e2:409e:8726? ([2001:8a0:f924:2600:209d:85e2:409e:8726]) by smtp.gmail.com with ESMTPSA id n6-20020a1c7206000000b0038c6e5fcb6dsm4251912wmc.19.2022.03.17.09.50.32 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 17 Mar 2022 09:50:32 -0700 (PDT) Message-ID: <0d25ccda-c26d-672f-6321-8a39aec9c1c6@palves.net> Date: Thu, 17 Mar 2022 16:50:31 +0000 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.7.0 Subject: Re: [PATCH v3 2/4] gdb: testsuite: add new gdb_attach to check "attach" command Content-Language: en-US To: Tiezhu Yang , gdb-patches@sourceware.org References: <1647525661-8607-1-git-send-email-yangtiezhu@loongson.cn> <1647525661-8607-3-git-send-email-yangtiezhu@loongson.cn> From: Pedro Alves In-Reply-To: <1647525661-8607-3-git-send-email-yangtiezhu@loongson.cn> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-9.7 required=5.0 tests=BAYES_00, FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM, GIT_PATCH_0, HEADER_FROM_DIFFERENT_DOMAINS, KAM_DMARC_STATUS, NICE_REPLY_A, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, 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 16:50:37 -0000 On 2022-03-17 14:00, 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 | 20 ++++++++++++++++++++ > 1 file changed, 20 insertions(+) > > diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp > index 89dcd0a..abbe79e 100644 > --- a/gdb/testsuite/lib/gdb.exp > +++ b/gdb/testsuite/lib/gdb.exp > @@ -5111,6 +5111,26 @@ 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 {options {}} } { > + parse_options { > + {pattern ""} > + } I'm surprised to see parse_options used instead of parse_args. Like, in patch #4: + set attach_opts { + "pattern" "main.*at .*$::main_srcfile:.*" + } + + if { ![gdb_attach $testpid $attach_opts] } { + return 0 } That looks odd to me -- it's not obvious that "pattern" is the option name. If we instead use parse_args, the option would be specified with "-pattern" (leading dash), and we'd use the magic TCL args array, so we wouldn't need to wrap the options in a list. Like so (on top of the whole series): >From 86aa3249e0d6362fef7f784982949fb6422acf18 Mon Sep 17 00:00:00 2001 From: Pedro Alves Date: Thu, 17 Mar 2022 16:35:49 +0000 Subject: [PATCH] parse_args Change-Id: Ia7234f34efbd6bcdad3aa7e39075df47abfbe24e --- gdb/testsuite/gdb.base/jit-elf.exp | 7 ++----- gdb/testsuite/lib/gdb.exp | 8 ++++++-- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/gdb/testsuite/gdb.base/jit-elf.exp b/gdb/testsuite/gdb.base/jit-elf.exp index e63f0863e99..efa1dc036b3 100644 --- a/gdb/testsuite/gdb.base/jit-elf.exp +++ b/gdb/testsuite/gdb.base/jit-elf.exp @@ -58,11 +58,8 @@ proc clean_reattach {} { clean_restart ${main_binfile} - set attach_opts { - "pattern" "main.*at .*$::main_srcfile:.*" - } - - if { ![gdb_attach $testpid $attach_opts] } { + if { ![gdb_attach $testpid \ + -pattern "main.*at .*$::main_srcfile:.*"] } { return 0 } diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp index abbe79e1a88..149a1c31776 100644 --- a/gdb/testsuite/lib/gdb.exp +++ b/gdb/testsuite/lib/gdb.exp @@ -5114,11 +5114,15 @@ proc can_spawn_for_attach { } { # Centralize the failure checking of "attach" command. # Return 0 if attach failed, otherwise return 1. -proc gdb_attach { testpid {options {}} } { - parse_options { +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)"