http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53927



--- Comment #6 from Eric Botcazou <ebotcazou at gcc dot gnu.org> 2013-01-31 
22:34:02 UTC ---

> The idea is you can determine which instance by computing the static link,

> then unwind the stack and look for the corresponding CFA.

> The test case here is supposed to confound simplistic approaches to this

> by having multiple instances of 'nestee' on the stack.



Yes, but you can do something useful even with this value of DW_AT_static_link,

albeit not exactly what DWARF means.  In the GDB released by AdaCore, we do use

this value of DW_AT_static_link to deal with up-level references; you can ask

Joel for the details.



> Note also that if the nested function doesn't refer to any variables from

> the outer scope, then GCC seems not to emit DW_AT_static_link at all.

> I guess this is an optimization; but it is a little unfortunate since

> it makes debugging less obvious.



Indeed, that's why in AdaCore's version of the compiler, we always generate

DW_AT_static_link at -O0, and we even force the static chain onto the stack in

this case (as there are no location lists at -O0).

Reply via email to