From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 24241 invoked by alias); 29 Nov 2006 13:20:56 -0000 Received: (qmail 24216 invoked by uid 22791); 29 Nov 2006 13:20:54 -0000 X-Spam-Check-By: sourceware.org Received: from wx-out-0506.google.com (HELO wx-out-0506.google.com) (66.249.82.232) by sourceware.org (qpsmtpd/0.31) with ESMTP; Wed, 29 Nov 2006 13:20:47 +0000 Received: by wx-out-0506.google.com with SMTP id h26so2413430wxd for ; Wed, 29 Nov 2006 05:20:44 -0800 (PST) Received: by 10.70.27.18 with SMTP id a18mr3980087wxa.1164806444446; Wed, 29 Nov 2006 05:20:44 -0800 (PST) Received: by 10.70.12.7 with HTTP; Wed, 29 Nov 2006 05:20:44 -0800 (PST) Message-ID: Date: Wed, 29 Nov 2006 13:20:00 -0000 From: "Rob Quill" To: gdb@sourceware.org Subject: Checking variable scope In-Reply-To: MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline References: 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: 2006-11/txt/msg00218.txt.bz2 On 28/11/06, Jim Blandy wrote: > > "Rob Quill" writes: > > The aim would be to add a command to gdb, in_scope (or similar) which > > can be used from a GDB script to check if a variable is in scope > > without throwing an error if is isn't. As currently if I do "print a" > > and a is not in scope then I get an error and the script stops, which > > is fine. But even better would be if I were able to check if a was in > > scope and only print (or do other things with it) if it was. > > Why don't you add a new expression operator, $in_scope(a), which > evaluates to zero or one? You could just imitate the other code in > the parser and expression evaluator, so this should be straightforward > to implement, and then you could use it in GDB script conditional > commands. > Could you elaborate on this a bit please? I'm not really sure what you mean and how to go about implementing it. Thanks, Rob