Mirror of the gdb mailing list
 help / color / mirror / Atom feed
* Is it possible to access shadowed variables?
@ 2010-11-12 19:36 Marc Khouzam
  2010-11-14 13:22 ` Vladimir Prus
  2010-11-15 10:19 ` André Pönitz
  0 siblings, 2 replies; 3+ messages in thread
From: Marc Khouzam @ 2010-11-12 19:36 UTC (permalink / raw)
  To: 'gdb@sourceware.org'

Hi,

I'm trying to figure out a way to deal with shadowed
variables in Eclipse.  But I can't find a way to
access them from GDB.

If I'm at line 3 of:  

int a = 1; //line 1
{
  bool a = true; // line 3
}

The only thing I found is to use
-stack-list-locals 2
which will show me both variables with their types
and both their values.

-stack-list-locals 2
^done,locals=[{name="a",type="bool",value="true"},
              {name="a",type="int",value="1"}]

Anything else I can do to tell GDB I want access to
some shadowed variable?

Note that floating variable objects don't help
(I think) because I'm already at line 3 by the
time I create the varObject, so it will point
to the inner-most variable.

Thanks for any suggestions.

Marc


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Is it possible to access shadowed variables?
  2010-11-12 19:36 Is it possible to access shadowed variables? Marc Khouzam
@ 2010-11-14 13:22 ` Vladimir Prus
  2010-11-15 10:19 ` André Pönitz
  1 sibling, 0 replies; 3+ messages in thread
From: Vladimir Prus @ 2010-11-14 13:22 UTC (permalink / raw)
  To: gdb

Marc Khouzam wrote:

> Hi,
> 
> I'm trying to figure out a way to deal with shadowed
> variables in Eclipse.  But I can't find a way to
> access them from GDB.
> 
> If I'm at line 3 of:
> 
> int a = 1; //line 1
> {
>   bool a = true; // line 3
> }
> 
> The only thing I found is to use
> -stack-list-locals 2
> which will show me both variables with their types
> and both their values.
> 
> -stack-list-locals 2
> ^done,locals=[{name="a",type="bool",value="true"},
>               {name="a",type="int",value="1"}]
> 
> Anything else I can do to tell GDB I want access to
> some shadowed variable?
> 
> Note that floating variable objects don't help
> (I think) because I'm already at line 3 by the
> time I create the varObject, so it will point
> to the inner-most variable.
> 
> Thanks for any suggestions.

There are no suggestions, I'm afraid. This requires the
ability to create varobj, or evaluate the expression, in
specific "block", or at specific line. I don't know any
way to do this in FSF GDB. Apple version had a way to
specify either address or line -- don't remember exactly.

- Volodya



^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Is it possible to access shadowed variables?
  2010-11-12 19:36 Is it possible to access shadowed variables? Marc Khouzam
  2010-11-14 13:22 ` Vladimir Prus
@ 2010-11-15 10:19 ` André Pönitz
  1 sibling, 0 replies; 3+ messages in thread
From: André Pönitz @ 2010-11-15 10:19 UTC (permalink / raw)
  To: gdb

On Friday 12 November 2010 20:35:58 ext Marc Khouzam wrote:
> Hi,
> 
> I'm trying to figure out a way to deal with shadowed
> variables in Eclipse.  But I can't find a way to
> access them from GDB.
> 
> If I'm at line 3 of:  
> 
> int a = 1; //line 1
> {
>   bool a = true; // line 3
> }

You can get the blocks of a frame using gdb.Frame.block(), iterate the nested
blocks using block.superblock and use gdb.Frame.read_var(name, block) to
access the shadowed variables. 

> The only thing I found is to use
> -stack-list-locals 2
> which will show me both variables with their types
> and both their values.
> 
> -stack-list-locals 2
> ^done,locals=[{name="a",type="bool",value="true"},
>               {name="a",type="int",value="1"}]

I don't think the functionality exists for MI varobjs.

Andre'


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2010-11-15 10:19 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-11-12 19:36 Is it possible to access shadowed variables? Marc Khouzam
2010-11-14 13:22 ` Vladimir Prus
2010-11-15 10:19 ` André Pönitz

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox