From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 10167 invoked by alias); 2 Jan 2008 13:55:43 -0000 Received: (qmail 10134 invoked by uid 22791); 2 Jan 2008 13:55:41 -0000 X-Spam-Check-By: sourceware.org Received: from rock.gnat.com (HELO rock.gnat.com) (205.232.38.15) by sourceware.org (qpsmtpd/0.31) with ESMTP; Wed, 02 Jan 2008 13:50:04 +0000 Received: from localhost (localhost.localdomain [127.0.0.1]) by filtered-rock.gnat.com (Postfix) with ESMTP id 2820D2A966D for ; Wed, 2 Jan 2008 08:49:49 -0500 (EST) Received: from rock.gnat.com ([127.0.0.1]) by localhost (rock.gnat.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id mCJi3oPlVEm7 for ; Wed, 2 Jan 2008 08:49:49 -0500 (EST) Received: from joel.gnat.com (localhost.localdomain [127.0.0.1]) by rock.gnat.com (Postfix) with ESMTP id 888BC2A9668 for ; Wed, 2 Jan 2008 08:49:42 -0500 (EST) Received: by joel.gnat.com (Postfix, from userid 1000) id 90C00E7ACB; Wed, 2 Jan 2008 05:49:10 -0800 (PST) Date: Wed, 02 Jan 2008 13:55:00 -0000 From: Joel Brobecker To: gdb-patches@sourceware.org Subject: Re: [RFA] no frame needed when computing address of subprogram Message-ID: <20080102134910.GE15903@adacore.com> References: <20080101134652.GB3770@adacore.com> <20080102125718.GB30490@caradoc.them.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20080102125718.GB30490@caradoc.them.org> User-Agent: Mutt/1.4.2.2i 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: 2008-01/txt/msg00021.txt.bz2 > Seems reasonable - but why does it have a block set? Hmmm, that's an interesting question. ada-exp.y: static void write_var_from_sym (struct block *orig_left_context, struct block *block, struct symbol *sym) { if (orig_left_context == NULL && symbol_read_needs_frame (sym)) { if (innermost_block == 0 || contained_in (block, innermost_block)) innermost_block = block; } But the interesting part is the part that just follows: write_exp_elt_opcode (OP_VAR_VALUE); write_exp_elt_block (block); write_exp_elt_sym (sym); write_exp_elt_opcode (OP_VAR_VALUE); Whereas, for C, we do: /* We want to use the selected frame, not another more inner frame which happens to be in the same block. */ write_exp_elt_block (NULL); IIRC, this is because we provide in Ada support for specifying the "context" of an expression. See "12.4.6.3 Additions to Ada": B::var means "the variable named var that appears in function or file B." When B is a file name, you must typically surround it in single quotes. We use this particularly in the context of up-level reference, when you are inside a nested procedure and trying to print the variable defined in one of the enclosing scopes. Most of the time, this is possible by directly using the variable name, but sometimes it's not, because the variable is actually hidden by another variable of the same name. The rule where we set (or not) the block is: var_or_type: NAME %prec VAR { $$ = write_var_or_type (NULL, $1); } | block NAME %prec VAR { $$ = write_var_or_type ($1, $2); } Still, your question still stands, who sets the block? I found inside write_var_or_type the following code: if (block == NULL) block = expression_context_block; Which at first sight would seem reasonable. This code predates me, so I'm not sure of the consequence of removing it. And there might be some other places down the road where we actually do the same. I will investigate more. I suggest, however, that we still go ahead with the patch I sent, because it protects all languages. -- Joel