[sheepdog] [PATCH] Fix hardcode AMD64 assembly code (RSP)

Hitoshi Mitake mitake.hitoshi at gmail.com
Wed Jul 31 03:43:11 CEST 2013


At Tue, 30 Jul 2013 10:48:54 +0800,
Liu Yuan wrote:
> 
> On Tue, Jul 30, 2013 at 08:35:23AM +0900, MORITA Kazutaka wrote:
> > At Mon, 29 Jul 2013 14:41:35 +0800,
> > Liu Yuan wrote:
> > > 
> > > diff --git a/lib/logger.c b/lib/logger.c
> > > index 253163d..da1221b 100644
> > > --- a/lib/logger.c
> > > +++ b/lib/logger.c
> > > @@ -697,11 +697,15 @@ static bool check_gdb(void)
> > >  	return system("which gdb > /dev/null") == 0;
> > >  }
> > >  
> > > +#define STACK_POINTER	\
> > > +	((char *)__builtin_frame_address(0) + __SIZEOF_POINTER__ * 2)
> > > +
> > 
> > I think we should add some explanation why this would work.
> > 
> >  - IIUC, we have to add (__SIZEOF_POINTER__ * 2) since the old ebp and
> >    eip are saved in the stack.
> 
> I thought of it too, but I have some questions with this assumption.
>  - Your old asm("esp") means the end of the caller's frame or begin of the
>    callee's frame?

IIUC, the stack pointer points the end of callee's frame.

>  - so GDB expect the address of end of the frame or the begin of the frame?

I don't know well about gdb, but it seems that gdb assumes the end of
the frame.

Thanks,
Hitoshi



More information about the sheepdog mailing list