From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 49140 invoked by alias); 8 Sep 2018 14:33:57 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 49125 invoked by uid 89); 8 Sep 2018 14:33:56 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-8.9 required=5.0 tests=AWL,BAYES_00,GIT_PATCH_2,RCVD_IN_DNSWL_NONE,SPF_PASS autolearn=ham version=3.3.2 spammy= X-HELO: mail-wm0-f41.google.com Received: from mail-wm0-f41.google.com (HELO mail-wm0-f41.google.com) (74.125.82.41) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sat, 08 Sep 2018 14:33:54 +0000 Received: by mail-wm0-f41.google.com with SMTP id f21-v6so17277443wmc.5 for ; Sat, 08 Sep 2018 07:33:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=embecosm.com; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:content-transfer-encoding:in-reply-to :user-agent; bh=lerG/fsUZojijmjbArYBFm6T1B9uJY2HWbLZWht/dfc=; b=WZdEzzhxYd3XysDVzHcSoOhPteS8hkrttx2VEgh1zeKvfIf73v8gl3f6ozBaLeAzk8 BzAL9uLV/gcKkG4CA14qzBCkWVFFjn2pLKxI+dlJN76Id2RS/qgG8/WY6jYQbSWBHO2I ZCYoDUg46BYNDWnTbpdpopkaq8dmTXHQPNsYm+SsoLXupQ+lxDtobW2Gae+UoHjb99VN R80DMLCU4YAYSHWYe/t7Wyh5VoqwHh4HgN5NnDv07l9kFOk2L4Ao/oMhwwioErxGjsk2 D85kbEv0/XjJJ+sjbSIWoAeQJ79uU4xFJhZhISIW97Gg+2ASIVgz+ILik+Z168RiYPFn 26QA== Return-Path: Received: from localhost ([130.88.240.121]) by smtp.gmail.com with ESMTPSA id w18-v6sm23834712wrc.38.2018.09.08.07.33.51 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 08 Sep 2018 07:33:51 -0700 (PDT) Date: Sat, 08 Sep 2018 14:33:00 -0000 From: Andrew Burgess To: Philippe Waroquiers Cc: gdb-patches@sourceware.org, Tom Tromey Subject: Re: [PATCHv2] gdb: Rewrite argument handling for user-defined commands Message-ID: <20180908143350.GI22193@embecosm.com> References: <20180906232904.13286-1-andrew.burgess@embecosm.com> <1536384914.1459.11.camel@skynet.be> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable In-Reply-To: <1536384914.1459.11.camel@skynet.be> X-Fortune: It is better to wear out than to rust out. X-Editor: GNU Emacs [ http://www.gnu.org/software/emacs ] User-Agent: Mutt/1.9.2 (2017-12-15) X-IsSubscribed: yes X-SW-Source: 2018-09/txt/msg00166.txt.bz2 * Philippe Waroquiers [2018-09-08 07:35:14 = +0200]: > On Fri, 2018-09-07 at 00:29 +0100, Andrew Burgess wrote: > > Here's a new version of the quoting patch which now uses single and > > double quotes for quoting arguments. > >=20 > > I look forward to any feedback. > >=20 > > Eli - I suspect that the documentation changes would need some work, > > but you should probably wait to review, as I suspect this patch will > > change again before it can be merged. > >=20 > > Thanks, > > Andrew > >=20 > > --- > >=20 > > This commit rewrites argument passing for user-defined commands. The > > rewrite was inspired after this mailing list thread: > >=20 > > https://sourceware.org/ml/gdb-patches/2018-08/msg00391.html > >=20 > > The summary is that it was felt that in order to pass arguments that > > include whitespace, then single or double quotes should be used for > > quoting the argument. > Tom felt that we need to support your initial suggestion (parenthesis > quoting) for 'balanced expressions', as parenthesis are used in > some other commands that are evaluating expressions. > I can understand his point of view, see > https://sourceware.org/ml/gdb-patches/2018-09/msg00007.html >=20 > >=20 > > The problem is that currently, the quotes are included in the argument > > that is passed into the user-defined command, so passing the argument > > "1 + 1" will currently litterally pass "1 + 1" (including the quotes) > > to GDB, which is no good if what you want to do is to pass an > > expression. > For this problem, an alternative solution is to have a new > way to expand an argument :=20 > $argX expands the argument X with the quotes > $arguX expands the argument X with the quotes. >=20 > That allows to pass a quoted argument containing spaces, > and use it in the user defined command without quotes where needed, > and with quotes where needed : if the user defined command has to call > another command (user defined or a native) that itself needs quoting, > then use $argX, else use $arguX. > In other words, how to handle a quoted arg is decided by the > user command 'developer' (similarly to some native GDB commands). >=20 > So, adder command would become > print $argu1 + $argu2 + $argu3 >=20 > See https://sourceware.org/ml/gdb-patches/2018-09/msg00005.html > for a patch (only very limited manual testing done) implementing > the arguX approach : Great. OK, lets go with this approach then. Tom, do you feel that we need more is required above and beyond adding argX / arguX as Philippe has suggested? Thanks, Andrew >=20 > (gdb)=A0=A0=A0=A0=A0define adder > Type commands for definition of "adder". > End with a line saying just "end". > >=A0=A0=A0=A0=A0=A0=A0print $arg0 + $arg1 + $arg2 > >=A0=A0=A0=A0=A0end > (gdb) adder '1 + 5' 2 3 > No symbol table is loaded.=A0=A0Use the "file" command. > (gdb) >=20 > (gdb) define adder > Redefine command "adder"? (y or n) y > Type commands for definition of "adder". > End with a line saying just "end". > >print $argu0 + $argu1 + $argu2 > >end > (gdb) adder '1 + 5' 2 3=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 > $4 =3D 11 > (gdb)=A0 >=20 >=20 > >=20 > > This commit changes how quoting works so that the quotes are NOT now > > included in the argument passed. If the user wants to include quotes, > > they would now need to use nested quotes, so "\"abc\"" will pass the > > argument "abc". > >=20 > > It is also possible to use single quotes, so '"abc"' will also pass > > the argument "abc". > >=20 > > As currently there's no documentation for how quoting works in > > user-defined commands this commit adds documentation for the new > > behaviour. > >=20 > > The big risk with this commit is that this does change how arguments > > are passed to user-defined commands, and this might causes issues for > > existing users. > Yes, that has the potential to create a lot of backward incompatibility, > which is not the case for the $arguX and/or the parenthesis approach > you suggested initially. >=20 > Philippe >=20 >=20