From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 16194 invoked by alias); 16 Feb 2008 07:37:05 -0000 Received: (qmail 16186 invoked by uid 22791); 16 Feb 2008 07:37:05 -0000 X-Spam-Check-By: sourceware.org Received: from wa-out-1112.google.com (HELO wa-out-1112.google.com) (209.85.146.178) by sourceware.org (qpsmtpd/0.31) with ESMTP; Sat, 16 Feb 2008 07:36:39 +0000 Received: by wa-out-1112.google.com with SMTP id l35so1558540waf.12 for ; Fri, 15 Feb 2008 23:36:37 -0800 (PST) Received: by 10.142.240.9 with SMTP id n9mr2970229wfh.136.1203147397275; Fri, 15 Feb 2008 23:36:37 -0800 (PST) Received: by 10.143.125.5 with HTTP; Fri, 15 Feb 2008 23:36:37 -0800 (PST) Message-ID: Date: Sat, 16 Feb 2008 07:37:00 -0000 From: "Yakov Lerner" To: gdb@sourceware.org Subject: Re: implementing eval command Cc: "Michael Snyder" In-Reply-To: <1203098329.19253.133.camel@localhost.localdomain> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <1203098329.19253.133.camel@localhost.localdomain> X-IsSubscribed: yes Mailing-List: contact gdb-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-owner@sourceware.org X-SW-Source: 2008-02/txt/msg00111.txt.bz2 On Fri, Feb 15, 2008 at 7:58 PM, Michael Snyder wrote: > Moving this to "gdb" list, since it is not a patch. > > > > On Thu, 2008-02-14 at 18:18 +0200, Yakov Lerner wrote: > > I'd like to make a patch that implements eval command, as follows. > > I have following idea to implement eval simply: > > Syntax of eval will be similar to the syntax of 'printf' command: > > eval "string with %..." comma-separated-expressions > > Implementation relies on existing printf_command() function, > > by rewriting printf_command into pair of functions, one that computes > > result of printf as allocated string; both printf_command and eval_command > > will use compute_printf() function. > > What do you think ? > > Hmmm, that would be one way of getting around the > limitations of some commands that can't accept expressions > as arguments (mentioned in another thread). > > What do you see as the context for this eval command? > How do you imagine it will be used? Apparently, the capability to insert variable into arbitrary part of gdb command is missing in gdb. I hit this several days ago when I needed to make a script that uses 'thread apply $num where' to a subset of threads in a program that had hundreds of threads and I was told on the list that this is impossible. I also see other requests for eval command on the mailing list archive. So, instead of enriching just 'thread apply' command to accept variable (or maybe parenthesized expression) I thought it's much more generic to have eval command in the end. I thought about easy way to implement it, and then I got idea of using the print-like format and comma-separated arg list. Yakov