This is the mail archive of the gdb@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Is it possible to access shadowed variables?


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'


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]