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: Checking variable scope


Hi,

I am stepping through the program, so I suppose I'd be looking to see
if the variable is in scope at the location of the PC.

How would I call lookup_symbol, given that information? I had a brief
look, but I wasn't sure what parameters to pass to the function, or
how to get the right values.

Thanks for your help.

Rob

On 22/11/06, Jim Blandy <jimb@codesourcery.com> wrote:

"Rob Quill" <rob.quill@gmail.com> writes: > I am trying to make it possible to be able to check if a variable is > in scope at a given time. My current implementation for this involves > adding a parameter to parse_expression, and the parsing functions it > calls, all the way until it gets to the line: > > if (sym == 0) > error ("No symbol \"%s\" in specified context.", copy_name ($3)); > > in c-exp.y > > as which point it doesn't call error, but calls another function which > returns a value signifing that the variable is not in scope. > > Whilst this is OK, in that it (should) work, I was wondering if anyone > had a neater way of implementing it?

Why not call lookup_symbol directly?  You can get the block that needs
with block_for_pc_sect.  Are you selecting the location by source
position, or PC, or what?



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