This is the mail archive of the
mailing list for the GDB project.
Re: Lifetime of local variables
Momchil Velikov <firstname.lastname@example.org> writes:
> I think ypu are mixing two different concepts here, the language
> notion of scope and the compiler/runtime notion of lifetime. I guess
> the lifetime is of interest for a debugger.
Yes, I was mixing them up a bit.
However, my understanding of this was that for a debugger, "scope"
means where a variable actually exists (so it should be listed by
"info locals" and "print", possibly stating that it's address is
unknown) and "lifetime" means where a variable can be accessed,
ie. it's actually stored somewhere and it's address/register is known
to the debugger.
> > I want to use this to debug machine
> > generated IL code and the JIT may want to create local variables
> > on-the-fly. For variables which have actually been defined by a human
> > programmer, listing them and claiming that their value is no longer
> > available is IMHO the right thing to do - but I'd like to tell the
> > debugger to make a machine-generated variable disappear when it's no
> > longer used, otherwise you'd get a large number of automatic variables
> > (having numbers, not names, which makes it even more confusing to the
> > user) and only a very few of them are actually used.
> One can use DT_AT_artificial to distinguish machine generated
> temporaries and the .debug_loc ranges to decide whether to display the
What happens if you're outside any of the ranges listed in .debug_loc -
will the variable be listed or not or will this depend on DW_AT_artificial ?
IMHO variables which have been created by a human should always be
listed, but machine generated ones (since there can be a large number
of them) should only be listed withing their lifetime ranges.