return err;
}
-static int valid_stack_ptr(struct task_struct *task, void *p)
+static inline int valid_stack_ptr(struct thread_info *tinfo, void *p)
{
- if (p <= (void *)task->thread_info)
- return 0;
- if (kstack_end(p))
- return 0;
- return 1;
+ return p > (void *)tinfo &&
+ p < (void *)tinfo + THREAD_SIZE - 3;
}
-#ifdef CONFIG_FRAME_POINTER
-static void print_context_stack(struct task_struct *task, unsigned long *stack,
- unsigned long ebp)
+static inline unsigned long print_context_stack(struct thread_info *tinfo,
+ unsigned long *stack, unsigned long ebp)
{
unsigned long addr;
- while (valid_stack_ptr(task, (void *)ebp)) {
+#ifdef CONFIG_FRAME_POINTER
+ while (valid_stack_ptr(tinfo, (void *)ebp)) {
addr = *(unsigned long *)(ebp + 4);
printk(" [<%08lx>] ", addr);
print_symbol("%s", addr);
printk("\n");
ebp = *(unsigned long *)ebp;
}
-}
#else
-static void print_context_stack(struct task_struct *task, unsigned long *stack,
- unsigned long ebp)
-{
- unsigned long addr;
-
- while (!kstack_end(stack)) {
+ while (valid_stack_ptr(tinfo, stack)) {
addr = *stack++;
if (__kernel_text_address(addr)) {
printk(" [<%08lx>]", addr);
printk("\n");
}
}
-}
#endif
+ return ebp;
+}
void show_trace(struct task_struct *task, unsigned long * stack)
{
if (!task)
task = current;
- if (!valid_stack_ptr(task, stack)) {
- printk("Stack pointer is garbage, not printing trace\n");
- return;
- }
-
if (task == current) {
/* Grab ebp right from our regs */
asm ("movl %%ebp, %0" : "=r" (ebp) : );
struct thread_info *context;
context = (struct thread_info *)
((unsigned long)stack & (~(THREAD_SIZE - 1)));
- print_context_stack(task, stack, ebp);
+ ebp = print_context_stack(context, stack, ebp);
stack = (unsigned long*)context->previous_esp;
if (!stack)
break;