From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 5030 invoked by alias); 22 Nov 2006 19:10:52 -0000 Received: (qmail 5012 invoked by uid 22791); 22 Nov 2006 19:10:50 -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; Wed, 22 Nov 2006 19:10:46 +0000 Received: (qmail 9398 invoked from network); 22 Nov 2006 19:10:44 -0000 Received: from unknown (HELO localhost) (jimb@127.0.0.2) by mail.codesourcery.com with ESMTPA; 22 Nov 2006 19:10:44 -0000 To: "Rob Quill" Cc: gdb@sourceware.org Subject: Re: Checking variable scope References: From: Jim Blandy Date: Wed, 22 Nov 2006 19:10:00 -0000 In-Reply-To: (Rob Quill's message of "Wed, 22 Nov 2006 11:32:07 +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/msg00152.txt.bz2 "Rob Quill" writes: > I am trying to make it possible to be able to check if a variable is > in scope at a given time. My current implementation for this involves > adding a parameter to parse_expression, and the parsing functions it > calls, all the way until it gets to the line: > > if (sym == 0) > error ("No symbol \"%s\" in specified context.", copy_name ($3)); > > in c-exp.y > > as which point it doesn't call error, but calls another function which > returns a value signifing that the variable is not in scope. > > Whilst this is OK, in that it (should) work, I was wondering if anyone > had a neater way of implementing it? Why not call lookup_symbol directly? You can get the block that needs with block_for_pc_sect. Are you selecting the location by source position, or PC, or what?