Hi guys,<div><br></div><div>While I was reading the code of get_wchan() in x86 32bit and 64bit, I notice the following difference,</div><div><br></div><div>32bit get_wchan</div><div><br></div><div><div>#define top_esp (THREAD_SIZE - sizeof(unsigned long))</div>
<div>#define top_ebp (THREAD_SIZE - 2*sizeof(unsigned long))</div></div><div><br></div><div><div>unsigned long get_wchan(struct task_struct *p)</div><div>{</div><div>...</div><div> if (!stack_page || sp < stack_page || sp > top_esp+stack_page)</div>
<div> return 0;</div><div> bp = *(unsigned long *) sp;</div><div> do {</div><div><b> if (bp < stack_page || bp > top_ebp+stack_page)</b></div><div> return 0;</div><div>...</div><div> } while (count++ < 16);</div>
<div> return 0;</div><div>}</div><div><br></div><div>64bit get_wchan</div><div><br></div><div><div>unsigned long get_wchan(struct task_struct *p)</div><div>{</div><div>...</div><div> if (p->thread.sp < stack || p->thread.sp >= stack+THREAD_SIZE)</div>
<div> return 0;</div><div> fp = *(u64 *)(p->thread.sp);</div><div> do { </div><div> <b> if (fp < (unsigned long)stack ||</b></div><div><b> fp >= (unsigned long)stack+THREAD_SIZE)</b></div>
<div> return 0;</div><div>...</div><div> } while (count++ < 16);</div><div> return 0;</div><div>} </div></div><div><br></div><div>Question 1:</div><div><br></div><div>Could anyone help tell me why in 64 bit, we don't use fp > (THREAD_SIZE - 2*sizeof(unsigned long)) like 32 bit?</div>
<div><br></div><div>Question 2:</div><div><br></div><div>Why is the limited count of frame loops 16?</div><div><br></div><div>Thanks,</div><div>Ye</div>-- <br>We Make every day party day<br>
</div>