From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 19359 invoked by alias); 10 Dec 2009 17:08:38 -0000 Received: (qmail 19349 invoked by uid 22791); 10 Dec 2009 17:08:37 -0000 X-SWARE-Spam-Status: No, hits=-2.5 required=5.0 tests=AWL,BAYES_00,SPF_HELO_PASS,SPF_PASS X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 10 Dec 2009 17:08:32 +0000 Received: from int-mx05.intmail.prod.int.phx2.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.18]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id nBAH7JIl019189 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Thu, 10 Dec 2009 12:07:19 -0500 Received: from ns3.rdu.redhat.com (ns3.rdu.redhat.com [10.11.255.199]) by int-mx05.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id nBAH7I2o013675; Thu, 10 Dec 2009 12:07:18 -0500 Received: from opsy.redhat.com (ovpn01.gateway.prod.ext.phx2.redhat.com [10.5.9.1]) by ns3.rdu.redhat.com (8.13.8/8.13.8) with ESMTP id nBAH7HmU017093; Thu, 10 Dec 2009 12:07:17 -0500 Received: by opsy.redhat.com (Postfix, from userid 500) id B8F3F3782A3; Thu, 10 Dec 2009 10:07:15 -0700 (MST) From: Tom Tromey To: Hui Zhu Cc: Michael Snyder , Joel Brobecker , gdb-patches ml Subject: Re: [RFC] Let "gcore" command accept a suffix argument References: <4B11DA3C.3000203@vmware.com> <20091130162246.GE4034@adacore.com> <4B141157.3070709@vmware.com> <20091130185341.GI4034@adacore.com> <4B141469.5030402@vmware.com> <20091130190619.GJ4034@adacore.com> <4B1428F0.7090608@vmware.com> Reply-To: tromey@redhat.com Date: Thu, 10 Dec 2009 17:08:00 -0000 In-Reply-To: (Hui Zhu's message of "Thu, 10 Dec 2009 10:32:25 +0800") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii 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: 2009-12/txt/msg00143.txt.bz2 >>>>> ">" == Hui Zhu writes: >> I make a patch to make gdb support "eval gcore foo.$a" command. Thanks! >> +{ >> +#define CMDSIZE 1024 >> + char cmd[CMDSIZE + 1]; Don't use a fixed-size buffer. Allocate on the heap and use a cleanup. >> + value = parse_and_eval (eval_begin); This is going to give an error if anything appears after "$foo". Try something like: eval echo $foo $bar You have multiple choices here. You could make it only support convenience variables. Then you would just have to extract the name and then look up the value. Or you could try to introduce syntax allowing arbitrary expressions. One idea that comes to mind is to reuse some code and make eval work like printf: eval "echo %s %d", $foo, $bar + 87 Now that I write it that seems weird :-) >> + add_com ("eval", no_class, eval_command, _("\ >> +Call command with variable.")); Exactly what to write depends on how it is implemented. This also needs a documentation change, a NEWS entry, and test cases. Tom