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

MORITA Kazutaka morita.kazutaka at gmail.com
Tue Jul 30 01:35:23 CEST 2013


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.

 - Even if this doesn't work on other architectures, it is safe to
   calculate a wrong address.  In such case, dump_stack_frames and
   dump_variable don't print anything.

Thanks,

Kazutaka



More information about the sheepdog mailing list