Re: [PATCH] make CALLER_ADDRx overwriteable

From: KOSAKI Motohiro
Date: Fri Feb 27 2009 - 02:33:00 EST


> The current definition of CALLER_ADDRx isn't suitable for all platforms.
> E.g. for ARM __builtin_return_address(N) doesn't work for N > 0 and
> AFAIK for powerpc there are no frame pointers needed to have a working
> __builtin_return_address. This patch allows defining the CALLER_ADDRx
> macros in <asm/ftrace.h> and let these take precedence.
>
> Because now <asm/ftrace.h> is included unconditionally in
> <linux/ftrace.h> all archs that don't already had this include get an
> empty one for free.

AFAIK, ia64 also doesn't work for N > 0.
thanks, good patch.



> -#ifdef CONFIG_FRAME_POINTER
> -/* TODO: need to fix this for ARM */
> -# define CALLER_ADDR0 ((unsigned long)__builtin_return_address(0))
> -# define CALLER_ADDR1 ((unsigned long)__builtin_return_address(1))
> -# define CALLER_ADDR2 ((unsigned long)__builtin_return_address(2))
> -# define CALLER_ADDR3 ((unsigned long)__builtin_return_address(3))
> -# define CALLER_ADDR4 ((unsigned long)__builtin_return_address(4))
> -# define CALLER_ADDR5 ((unsigned long)__builtin_return_address(5))
> -# define CALLER_ADDR6 ((unsigned long)__builtin_return_address(6))
> -#else
> -# define CALLER_ADDR0 ((unsigned long)__builtin_return_address(0))
> -# define CALLER_ADDR1 0UL
> -# define CALLER_ADDR2 0UL
> -# define CALLER_ADDR3 0UL
> -# define CALLER_ADDR4 0UL
> -# define CALLER_ADDR5 0UL
> -# define CALLER_ADDR6 0UL
> -#endif
> +#ifndef CALLER_ADDR0

but I think this "#ifndef CALLER_ADDR0" don't explain developer intention at all.
ARCH_HAS_XXXXX macro is better?

I would like to hear another developer opinions.


> +# ifdef CONFIG_FRAME_POINTER
> +# define CALLER_ADDR0 ((unsigned long)__builtin_return_address(0))
> +# define CALLER_ADDR1 ((unsigned long)__builtin_return_address(1))
> +# define CALLER_ADDR2 ((unsigned long)__builtin_return_address(2))
> +# define CALLER_ADDR3 ((unsigned long)__builtin_return_address(3))
> +# define CALLER_ADDR4 ((unsigned long)__builtin_return_address(4))
> +# define CALLER_ADDR5 ((unsigned long)__builtin_return_address(5))
> +# define CALLER_ADDR6 ((unsigned long)__builtin_return_address(6))
> +# else
> +# define CALLER_ADDR0 ((unsigned long)__builtin_return_address(0))
> +# define CALLER_ADDR1 0UL
> +# define CALLER_ADDR2 0UL
> +# define CALLER_ADDR3 0UL
> +# define CALLER_ADDR4 0UL
> +# define CALLER_ADDR5 0UL
> +# define CALLER_ADDR6 0UL
> +# endif
> +#endif /* ifndef CALLER_ADDR0 */




--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/