https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66960

--- Comment #15 from Goswin von Brederlow <goswin-v-b at web dot de> ---
(In reply to H.J. Lu from comment #14)
> (In reply to Goswin von Brederlow from comment #13)
> > > > Secondly why pass error_code as argument if is already on the stack and
> > > > could be accessed through the frame pointer? The argument register 
> > > > (amd64)
> > > > would have to be saved on the stack too causing an extra push/pop. But 
> > > > if it
> > > > is passed as argument then why not pop it before the call to keep the 
> > > > stack
> > > > frame the same as for interrupts (assuming the saved registers are not
> > > > included in the frame)?
> > > 
> > > error_code is a pseudo parameter, which is mapped to error code on stack
> > > pushed by CPU.  You can write a simple code to see it yourself.
> > 
> > Couldn't the same trick be used for registers? Pass them as pseudo
> > parameters and they either resolve to the location on the stack where gcc
> > did save them or become the original register unchanged.
> 
> No.  We only do it for data pushed onto stack by CPU.

I was thinking of something like:

__attribute__ ((interrupt("save_regs")))
void
f (struct interrupt_frame *frame, uword_t error_code, struct regs regs)
{
    kprintf("user SP = %#016x\n", regs.sp);
}

Reply via email to