On Mon, 2010-01-25 at 23:13 -0500, Mike Frysinger wrote:
> On Mon, Jan 25, 2010 at 23:02,  <[email protected]> wrote:
> > Revision 8232 Author adamliyi Date 2010-01-25 23:02:44 -0500 (Mon, 25 Jan
> > 2010)
> >
> > Log Message
> >
> > Add CALLER_ADDR macro used by ftrace.
> >
> > trunk/arch/blackfin/include/asm/ftrace.h
> >
> > +extern inline void *return_address(unsigned int level)
> > +{
> > +   unsigned long *endstack, *fp, *ret_addr;
> > +   unsigned int current_level = 0;
> > +
> > +   ret_addr = (unsigned long *)__builtin_return_address(0);
> > +   fp = (unsigned long *)__builtin_frame_address(0);
> > +   endstack = (unsigned long *)PAGE_ALIGN((unsigned int)&level);
> > +
> > +   if (level == 0
> > +           || !(fp && ((unsigned int)fp & 0x3) == 0 && fp < endstack))
> > +           return ret_addr;
> > +
> > +   fp = (unsigned long *)*fp;
> > +   while (current_level < level && fp && ((unsigned int)fp & 0x3) == 0
> > +           && (fp + 1) < endstack) {
> > +           ret_addr = (unsigned long *)*(fp + 1);
> > +           current_level++;
> > +           fp = (unsigned long *)*fp;
> 
> what if we declared fp as unsigned long ** ?  then we wouldnt need
> these casts ...
> 
I think even declared fp as unsigned long **, the cast is still required
to avoid warning:

fp = (unsigned long **)*fp;

> > +   }
> > +
> > +   if (current_level < level)
> > +           ret_addr = NULL;
> > +
> > +   return ret_addr;
> > +}
> 
> we have similar code in traps.c:show_stack() ... wonder if we can
> unify these some how ...
> 
Yes. I copied idea from show_stack().. Maybe something like
"get_frame(int frame_num)" - but show_stack() is much complex..

> > +/* inline function or macro may lead to unexpected result */
> > +#define CALLER_ADDR0 ((unsigned long)__builtin_return_address(0))
> > +#define CALLER_ADDR1 ((unsigned long)return_address(1))
> > +#define CALLER_ADDR2 ((unsigned long)return_address(2))
> > +#define CALLER_ADDR3 ((unsigned long)return_address(3))
> > +#define CALLER_ADDR4 ((unsigned long)return_address(4))
> > +#define CALLER_ADDR5 ((unsigned long)return_address(5))
> > +#define CALLER_ADDR6 ((unsigned long)return_address(6))
> 
> be nice if __builtin_return_address() supported these ...
Yes.

-Yi


_______________________________________________
Linux-kernel-commits mailing list
[email protected]
https://blackfin.uclinux.org/mailman/listinfo/linux-kernel-commits

Reply via email to