This is the mail archive of the
dwarf2@corp.sgi.com
mailing list for the dwarf2 project.
Re: location lists revisited
Michael Eager wrote:
>
> I'm unclear why you suggest that the lifetime for a variable is not
> decidable. This may be true for unnamed objects, but a variable has
> a well defined lifetime. Certainly a compiler knows when a variable
> is live and can describe this in Dwarf 2 (at least, in most cases).
No. Consider the case where a subroutine declares a local static
variable (C/C++ static or Fortran SAVE), initializes it, and exits,
and then reuses it the next time it's entered. Whether or not the
value's lifetime includes code executed outside the defining procedure
depends on whether it has already been called, an undecidable
problem in general.
> Whether a variable is live or not in any particular context can be
> determined by following the thread of execution (i.e., walking the
> stack) to see if the variable is live in any of the scopes along this
> thread. Are there circumstances when this would not be decidable?
The problem is much easier if you only consider the intersection of
the lifetime with the scope, which is what I now assume you were
originally doing, and what is probably a quite reasonable thing for
the debugging information to do. Your paragraph above appears to
imply that you're looking for a containing scope which is part of
the variable's scope, which is the context in which the compiler can
tell you that the variable is in scope (though perhaps hidden) and
allocated somewhere (live). It is NOT, strictly speaking, specifying
the full lifetime of a variable, which can extend outside that defining
scope (to places that can't even see a declaration). So the original
statement that got me started:
> > > >
> > > > The second definition for "global" declares that it's lifetime is
> > > > limited to source2.c.
was confusing, to me at least.
Jim
--
- Jim Dehnert dehnert@transmeta.com
(408)919-6984 dehnertj@acm.org