From: Joel Brobecker <brobecker@adacore.com>
To: gdb-patches@sourceware.org
Subject: Re: [RFA] no frame needed when computing address of subprogram
Date: Wed, 02 Jan 2008 13:55:00 -0000 [thread overview]
Message-ID: <20080102134910.GE15903@adacore.com> (raw)
In-Reply-To: <20080102125718.GB30490@caradoc.them.org>
> 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
next prev parent reply other threads:[~2008-01-02 13:55 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-01-01 13:48 Joel Brobecker
2008-01-02 13:04 ` Daniel Jacobowitz
2008-01-02 13:55 ` Joel Brobecker [this message]
2008-01-02 14:08 ` Daniel Jacobowitz
2008-01-03 4:18 ` Joel Brobecker
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20080102134910.GE15903@adacore.com \
--to=brobecker@adacore.com \
--cc=gdb-patches@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox