[Dwarf-Discuss] Location list entries for caller-saved registers at time of call
andrew.cagney at gmail.com
Sat Dec 8 19:26:18 PST 2018
On Fri, 7 Dec 2018 at 16:56, Jakub Jelinek via Dwarf-Discuss
<dwarf-discuss at lists.dwarfstd.org> wrote:
> On Fri, Dec 07, 2018 at 08:58:42AM -0800, Cary Coutant via Dwarf-Discuss wrote:
> > And that's another reason why on PA-RISC and Itanium we have the rule
> > that the unwind info for the PC of the instruction following the call
> > must be accurate. With that rule, we do not have to anticipate or
> > compensate for the consumer. One hack always begets another hack. (Of
> > course, if some debuggers were to subtract 1 despite that rule, we
> > would have to either compensate or declare them buggy.)
> > Jakub complains that "the compiler would need to emit a nop after
> > every call, which an optimizing compiler is not willing to do." We're
> > not talking about *every* call, just the rare case of a no-return
> > call.
> They aren't that rare, and even if they would, that is still not enough.
> For proper debug info one needs to differentiate between the context inside
> of the call and the context right after the call, while in the %eax case
> that has been discussed it makes no difference, in others it does.
> void bar (void);
> void baz (int);
> foo (void)
> int a = 6;
> bar ();
> long a = 5;
> baz (10);
> return 10;
> If you don't subtract one during unwinding and during the bar call look at
> foo's frame, then it would appear as if you are already at the baz call with
> the inner a variable in scope, but that shouldn't be in scope yet, and if
> user asks for value of a, he should see that 6 and its type should be int,
> not long.
To expand on CFI.
If one isn't subtracted then unwinding may not even work. Compilers,
while generating information to unwind thw 'PC' to the 'return
address', generate unwind information to restore the stack structure
to _before_ the call. This is because the SP immediately before and
immediately after the function call can be different.
For instance, on a VAX, the return instruction discards parameters on
the stack that were pushed before CALLS was executed something like:
# SP includes parameter list
callS foo() -- pushes # parameters along with other stuff
# on return 'parameters' are gone
I've always wondered about generating zero-length location
descriptions (which currently are illegal) to handle these cases. It
would address Cary's 1-instruction call problem.
More information about the Dwarf-Discuss