/* Under heavy swap load I've seen this lose in an ugly way. So do some extra sanity checking on the ranges we expect these pointers to be in so that we can fail gracefully. This is just for ps after all.  */
unsigned long thread_saved_pc(struct task_struct *t)
/* Under heavy swap load I've seen this lose in an ugly way. So do some extra sanity checking on the ranges we expect these pointers to be in so that we can fail gracefully. This is just for ps after all.  */
unsigned long thread_saved_pc(struct task_struct *t)
{
	unsigned long base = (unsigned long)task_stack_page(t);
	unsigned long fp, sp = task_thread_info(t)->pcb.ksp;
	if (sp > base && sp+6*8 < base + 16*1024) {
		fp = ((unsigned long*)sp)[6];
		if (fp > sp && fp < base + 16*1024)
			return *(unsigned long *)fp;
	}
	return 0;
}