This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


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

Re: ARM problems with the exception unwinder


>>>>> "Richard" == Richard Earnshaw <rearnsha@arm.com> writes:

> [ Sorry, should have sent this to everyone].
>> Richard Earnshaw writes:
>> 
>> > I've just been looking at execute_cfa_insn() in frame_dwarf2.c and
>> > I've no idea how it is supposed to work when the cfa reg is not the
>> > stack pointer, since it seems to completely ignore any adjustments to
>> > the cfa register.  How is this code supposed to work when the cfa
>> > register changes from frame to frame?
>> 
>> As I understand it, the CFA is *defined* to be the value of SP before
>> the call instruction.  Is that not so in your case?

> Yes it is, but cfa_reg is the register used when describing the frame.  
> Often, this isn't the stack pointer but the frame pointer (I guess this is 
> the crux of the other thread on this issue concerning exception throwing 
> and alloca).

> The problem is that when cfa_reg is set to the frame pointer, the stack 
> pointer value pushed on the stack is updated,

I think that's the bug.  How can that be right?  Surely the value pushed on
the stack in the prologue shouldn't need adjustment?

When unwinding, we should always restore SP using the offset, never using
the value saved in the stack.

> but when cfa_reg is the stack pointer, the value stored on the stack
> isn't updated.  Then when we restore SP we get a number that may be right
> or it may not -- there is no way to tell.  I think the correct thing to
> do is that if there is a save slot for ustate.cfa_reg in mystate we
> should update that value; then the only adjustment that should be applied
> at the end is to add args_size for the initial caller to unwind any
> pushed arguments.

No.  Usually a save slot for ustate.cfa_reg just means that the frame
pointer was saved at the beginning of the prologue.  The code you reference
in frame_dwarf2 refers to "saving" the CFA register after its value from
the caller has already been clobbered with some value derived from SP.

Jason

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