From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 15719 invoked by alias); 28 Nov 2006 19:43:48 -0000 Received: (qmail 15703 invoked by uid 22791); 28 Nov 2006 19:43:47 -0000 X-Spam-Check-By: sourceware.org Received: from mail.codesourcery.com (HELO mail.codesourcery.com) (65.74.133.4) by sourceware.org (qpsmtpd/0.31) with ESMTP; Tue, 28 Nov 2006 19:43:39 +0000 Received: (qmail 26887 invoked from network); 28 Nov 2006 19:43:36 -0000 Received: from unknown (HELO localhost) (jimb@127.0.0.2) by mail.codesourcery.com with ESMTPA; 28 Nov 2006 19:43:36 -0000 To: "Rob Quill" Cc: gdb@sourceware.org Subject: Re: Checking variable scope References: From: Jim Blandy Date: Tue, 28 Nov 2006 19:43:00 -0000 In-Reply-To: (Rob Quill's message of "Tue, 28 Nov 2006 11:46:55 +0000") Message-ID: User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii 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/msg00202.txt.bz2 "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.