This is the mail archive of the
gdb-patches@sources.redhat.com
mailing list for the GDB project.
Re: [RFC/RFA] gdb.cp/classes.exp: Don't try to print local variable out of scope
- From: Daniel Jacobowitz <drow at false dot org>
- To: Andrew Cagney <cagney at gnu dot org>
- Cc: Michael Elizabeth Chastain <mec dot gnu at mindspring dot com>,gdb-patches at sources dot redhat dot com, vinschen at redhat dot com
- Date: Tue, 9 Mar 2004 16:27:36 -0500
- Subject: Re: [RFC/RFA] gdb.cp/classes.exp: Don't try to print local variable out of scope
- References: <20040309161507.9FBF54B104@berman.michael-chastain.com> <404E2B2C.8030201@gnu.org>
On Tue, Mar 09, 2004 at 03:38:04PM -0500, Andrew Cagney wrote:
> >1 void foo ()
> > 2 {
> > 3 int i = 1;
> > 4 {
> > 5 int i = 2;
> > 6 bar(i);
> > 7 }
> > 8 bar (i);
> > 9 }
> >
> >cv> Is line 7 still in the scope of the inner definition of variable `i'?
> >cv> Which `i' should be printed at that point?
> >
> >My intuition says that the inner "i" is in scope at line 7.
>
> Yes, the inner "i" should be in scope. That line, which hasn't yet been
> executed, will destory the inner block. I think that is covered by the
> GCC-O0 rule?
If that's right, it sounds like we should be using the address-in-block
hack to figure out what local variables are in scope for the top
frame. But that runs the risk of, for instance, moving us back into a
preceeding function.
--
Daniel Jacobowitz
MontaVista Software Debian GNU/Linux Developer