From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 114392 invoked by alias); 30 Aug 2018 21:19:42 -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 113963 invoked by uid 89); 30 Aug 2018 21:19:42 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-1.8 required=5.0 tests=BAYES_00,KAM_ASCII_DIVIDERS,RCVD_IN_DNSWL_LOW,SPF_PASS autolearn=no version=3.3.2 spammy= X-HELO: mailsec105.isp.belgacom.be Received: from mailsec105.isp.belgacom.be (HELO mailsec105.isp.belgacom.be) (195.238.20.101) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 30 Aug 2018 21:19:39 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=skynet.be; i=@skynet.be; q=dns/txt; s=securemail; t=1535663979; x=1567199979; h=message-id:subject:from:to:cc:date:in-reply-to: references:mime-version:content-transfer-encoding; bh=ujq/UmRrTRyOHzrlxa0Fhv5knf43tY1dT7FHjG0M5vU=; b=fOJpz/9fLFcMXXke8/uPIfDbp/n99a9hP5H3tLOnrFdU748qVvALTHK+ r/6DKSGt1ppD6rnvn3eXg46ZOn99iw==; Received: from 232.142-134-109.adsl-dyn.isp.belgacom.be (HELO md) ([109.134.142.232]) by relay.skynet.be with ESMTP/TLS/AES256-GCM-SHA384; 30 Aug 2018 23:19:36 +0200 Message-ID: <1535663976.7778.12.camel@skynet.be> Subject: Re: [PATCH 2/2] gdb: Allow parenthesis to group arguments to user-defined commands From: Philippe Waroquiers To: Andrew Burgess Cc: Tom Tromey , gdb-patches@sourceware.org Date: Thu, 30 Aug 2018 21:19:00 -0000 In-Reply-To: <20180828232948.GK32506@embecosm.com> References: <1535225533.1438.5.camel@skynet.be> <1535230403.1438.10.camel@skynet.be> <20180825224310.GA32506@embecosm.com> <87lg8q7ai7.fsf@tromey.com> <20180828184331.GJ32506@embecosm.com> <1535488137.7778.4.camel@skynet.be> <20180828232948.GK32506@embecosm.com> Content-Type: text/plain; charset="UTF-8" Mime-Version: 1.0 Content-Transfer-Encoding: 7bit X-IsSubscribed: yes X-SW-Source: 2018-08/txt/msg00845.txt.bz2 On Wed, 2018-08-29 at 00:29 +0100, Andrew Burgess wrote: > > Maybe you could help me work through a few examples, in the following > table I've outlined a few examples, and have the following questions: > > [1] What argument(s) would be passed under the new scheme? > [2] What argument(s) would be passed under the new scheme? > [3] How would I write {unsigned long} &var to pass this as a single > argument? If with quotes, how does this relate to 1 & 2? > > | Input | Current Arguments(s) | Proposed Argument(s) | > |----------------------+----------------------+----------------------| > | a b | a | a | > | | b | b | > |----------------------+----------------------+----------------------| > | "a b" | "a b" | [1] | > |----------------------+----------------------+----------------------| > | 'a b' | 'a b' | [2] | > |----------------------+----------------------+----------------------| > | {unsigned long} &var | {unsigned | | > | | long} | N/A | > | | &var | | > |----------------------+----------------------+----------------------| > | [3] | | | > |----------------------+----------------------+----------------------| > > In general I'm happy to rework this part of GDB, but ideally I'd like > some feedback from a global maintainer that such a change, which might > would break backward compatibility, would be acceptable... Humph, now I understand that user defined commands already handle specially single and double quotes, as you explained above. This seems not documented in the gdb documentation, which tells that 'Note the arguments are text substitutions, so they may reference variables, use complex expressions, or even perform inferior functions calls.' I have not found a description of this single and double quote behaviour. Maybe the only thing we might need is something like: $unquoted_arg1 or something like that to allow to remove the quotes inside the user defined command, when desired ? Or as you suggested, some new flags to the define command, such as define some_command -unquote_arg3 would indicate that if arg3 is a single quoted argument as in your table above, that it must be given without the quote to some_command. For what concerns the parenthesis based solution, it looks to not work for some cases. E.g. if I want to pass one argument (I am using single quotes to show the args I want in the below examples): 'a b) (c d' then I need to use: some_user_defined (a b) (c d) but that is the same notation as if I want to pass 2 arguments 'a b' and 'c d' So, the parenthesis mechanism would need escaping or something like that, to allow a general grouping. As it stands now, it only works based on the assumption that the content inside the parenthesis Still, it looks strange to me that we introduce another mechanism on top of the single/double quotes to quote. And it would be nice if the mechanism used to quote args would be compatible between user defined commands and native gdb commands. I have not understood the reference given by Tom that expressions are terminated with , and that parenthesis stops this termination. Is that described somewhere in the doc ? The doc (or an example if this is not documented) will help me to understand. Philippe