From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 8666 invoked by alias); 9 Jan 2010 10:56:15 -0000 Received: (qmail 8647 invoked by uid 22791); 9 Jan 2010 10:56:14 -0000 X-SWARE-Spam-Status: No, hits=-2.4 required=5.0 tests=AWL,BAYES_00 X-Spam-Check-By: sourceware.org Received: from rock.gnat.com (HELO rock.gnat.com) (205.232.38.15) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Sat, 09 Jan 2010 10:56:10 +0000 Received: from localhost (localhost.localdomain [127.0.0.1]) by filtered-rock.gnat.com (Postfix) with ESMTP id 846EA2BAB35; Sat, 9 Jan 2010 05:56:08 -0500 (EST) Received: from rock.gnat.com ([127.0.0.1]) by localhost (rock.gnat.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id KHi7LbBZYHxc; Sat, 9 Jan 2010 05:56:08 -0500 (EST) Received: from joel.gnat.com (localhost.localdomain [127.0.0.1]) by rock.gnat.com (Postfix) with ESMTP id 7D3A12BAAE9; Sat, 9 Jan 2010 05:56:07 -0500 (EST) Received: by joel.gnat.com (Postfix, from userid 1000) id 4E1C6F595E; Sat, 9 Jan 2010 14:55:57 +0400 (RET) Date: Sat, 09 Jan 2010 10:56:00 -0000 From: Joel Brobecker To: Hui Zhu Cc: Stan Shebs , Tom Tromey , Stan Shebs , Michael Snyder , gdb-patches ml , Eli Zaretskii Subject: Re: [RFC] Let "gcore" command accept a suffix argument Message-ID: <20100109105557.GA2007@adacore.com> References: <4B29018C.6060307@codesourcery.com> <4B3BEDCC.9040103@earthlink.net> <20100106075757.GF24777@adacore.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.20 (2009-06-14) 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 X-SW-Source: 2010-01/txt/msg00209.txt.bz2 > This value will be convert to string and execute_command (cmd, > from_tty); will use it. Which parts of the argument will be expanded. To take another language as an example, let's have a look at what a POSIX shell does: echo "1 $foo 2" In double-quoted strings, the dollar sign has a the usual special meaning introducing parameter expansion. As a result, if our parameter "foo" was set to "bar", the final value for the string above would be "1 bar 2". What I would like from you is a formal description of what your command does. "This value will be convert to string" is too vague. How will the conversion be done, and which parts of the string will be evaluated, and which parts won't? Intuitively, I think that you want to do the same as posix shells. In other words, if I borrow and adjust part of the POSIX shell language standard from the opengroup: | Enclosing characters in double-quotes ( "" ) shall preserve the literal | value of all characters within the double-quotes, with the exception of | the characters dollar sign, and backslash, as follows: | | $ The dollar sign shall retain its special meaning introducing | parameter expansion | | \ The backslash shall retain its special meaning as an escape character | only when followed by one of the following characters: | | $ " \ The issue I'm having, which is leading to this discussion about the semantics of your command, is that I do not think that the implementation that you chose follows the semantics above. > value_print print the value VAL in C-ish syntax on stream STREAM > according to OPTIONS. > But cannot find a example how to do it, could you help me with it? In fact, it will print the value in the syntax of the current language. I will fix the comment. What you need to do, in order to convert your value into a string, is create a memory ui_file, call value_print with your value and the memory ui_file, and then extract the contents of your ui_file as a string. See mem_fileopen and ui_file_xstrdup. -- Joel