From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm1-f46.google.com (mail-wm1-f46.google.com [209.85.128.46]) by sourceware.org (Postfix) with ESMTPS id B6A5E3858D1E for ; Thu, 17 Mar 2022 17:31:29 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org B6A5E3858D1E 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-wm1-f46.google.com with SMTP id bg31-20020a05600c3c9f00b00381590dbb33so3540678wmb.3 for ; Thu, 17 Mar 2022 10:31:29 -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:references:from:in-reply-to :content-transfer-encoding; bh=zVXPJFFlWner6cupM1/MNp+F6MEAH638zo7WD52xM1Q=; b=mCdIHH/79c68zUOUkkOXsIxydZmaa25PGK448yzvgld8Kra9xLXnOmGD/+E6k4I55c 6HOdIf58Fg1w3r2ABkskcGZ4HG8E0HWnrNjRc8NFAaTwipyuyMQmhzdN+A6hhlxUGE4J EcvgDbE80xSTVPS/z3kKtqW0YvAoUVrH5vUp96Elmg6dUtQK2fOCSTY733npdELjIdgh Kl3Qr/k4Q9oRJkvJPm06iRvo/tbgD7eKE8mVG0ZX+w3YlvpGre2Fh5PcMwz6eelFQbMy PhLgEn29BlopaAhObQfqstqdIOPfcwdLKlCghvzw7UbT11aA2WLPZrWQ9f4tTPrcFeM0 DFPQ== X-Gm-Message-State: AOAM532I/YgC/6WayCAnkSjREukGdmm1enga1SgZM1odsO3eD77cfh5d VIRIiJu9atpNoQqjCP5K7vW4xxqKAmfvXw== X-Google-Smtp-Source: ABdhPJw6NenGnMzb3RLEN2OxuAKZnYMx9pesWZpUwPT1lTlPraQwou4SrAFEOV4MULCyeTcBdbT6rw== X-Received: by 2002:a7b:c5d0:0:b0:389:fe85:3d79 with SMTP id n16-20020a7bc5d0000000b00389fe853d79mr12830485wmk.77.1647538288716; Thu, 17 Mar 2022 10:31:28 -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 i206-20020a1c3bd7000000b0038bfc3ab76csm4835190wma.48.2022.03.17.10.31.26 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 17 Mar 2022 10:31:27 -0700 (PDT) Message-ID: <25e1d92c-6b7e-9df3-640e-92227cf9e8ae@palves.net> Date: Thu, 17 Mar 2022 17:31:26 +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: Simon Marchi , 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> <0d25ccda-c26d-672f-6321-8a39aec9c1c6@palves.net> From: Pedro Alves In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-3.7 required=5.0 tests=BAYES_00, FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM, 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=no 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 17:31:34 -0000 On 2022-03-17 17:04, Simon Marchi via Gdb-patches wrote: > On 2022-03-17 12:50, Pedro Alves wrote: >> 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): > > I used parse_options because back when doing the rnglists support in the > DWARF assembler, I had used parse_args and Tom Tromey mentioned he > didn't really like that use of `args`, because it didn't make it clear > what positional arguments were expected.. Unlike what you've done > below, it was something like: > > proc rnglists { args } { > # call parse_args, and then use the remaining args as positional > # arguments > } OK. I'd be fine with that pattern myself, FWIW, as I'd assume the real arguments would be described in a comment, which you always have to look at anyhow, even if you have positional arguments: # Usage: func FOO BAR [-opt OPT] # proc func { args } { Maybe we could instead come up with a proc alternative that would let you specify the options in the args list directly, like: proc_with_opts func { foo bar } { {opt1 "default1"} {opt2 "default2"} } { ... } ... and we'd make it support users passing options before or after positional args. Maybe that's going a bit too far, dunno. > The way you did it here has the advantage that it's clear which > positional arguments are expected. The downside is that flag arguments > can't be put before positional arguments (like you usually can with > shell or some tcl / expect procs). But I think that's an acceptable > tradeoff, I'm fine with it. Yeah, it's what we do with gdb_test_multiple too, for example, even thought we don't use parse_args there for some reason. # gdb_test_multiple COMMAND MESSAGE [ -prompt PROMPT_REGEXP] [ -lbl ] # EXPECT_ARGUMENTS ... proc gdb_test_multiple { command message args } { ... > > Could we add a way to tell parse_args that unexpected arguments are not > allowed, so it could throw the error itself (and therefore be re-used > elsewhere)? I'd guess we could. I wouldn't make that a requirement for this patch, though.