inconsistency of get_wchan in x86_32 and x86_64

microstone microstone.l at gmail.com
Wed Dec 12 02:56:03 EST 2012


Hi guys,

While I was reading the code of get_wchan() in x86 32bit and 64bit, I
notice the following difference,

32bit get_wchan

#define top_esp                (THREAD_SIZE - sizeof(unsigned long))
#define top_ebp                (THREAD_SIZE - 2*sizeof(unsigned long))

unsigned long get_wchan(struct task_struct *p)
{
...
    if (!stack_page || sp < stack_page || sp > top_esp+stack_page)
        return 0;
    bp = *(unsigned long *) sp;
    do {
*        if (bp < stack_page || bp > top_ebp+stack_page)*
            return 0;
...
    } while (count++ < 16);
    return 0;
}

64bit get_wchan

unsigned long get_wchan(struct task_struct *p)
{
...
    if (p->thread.sp < stack || p->thread.sp >= stack+THREAD_SIZE)
        return 0;
    fp = *(u64 *)(p->thread.sp);
    do {
  *      if (fp < (unsigned long)stack ||*
*            fp >= (unsigned long)stack+THREAD_SIZE)*
            return 0;
...
    } while (count++ < 16);
    return 0;
}

Question 1:

Could anyone help tell me why in 64 bit, we don't use fp > (THREAD_SIZE -
2*sizeof(unsigned long)) like 32 bit?

Question 2:

Why is the limited count of frame loops 16?

Thanks,
Ye
-- 
We Make every day party day
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20121211/69104be0/attachment.html 


More information about the Kernelnewbies mailing list