linux-mips
[Top] [All Lists]

[PATCH] rearrange show_stack, show_trace

To: linux-mips@linux-mips.org
Subject: [PATCH] rearrange show_stack, show_trace
From: Atsushi Nemoto <anemo@mba.ocn.ne.jp>
Date: Tue, 25 Jul 2006 23:51:36 +0900 (JST)
Cc: ralf@linux-mips.org
Original-recipient: rfc822;linux-mips@linux-mips.org
Sender: linux-mips-bounce@linux-mips.org
Print call-trace in show_stack() (as like as other archs).
Also make show_trace() static and simplify its argument list.

Signed-off-by: Atsushi Nemoto <anemo@mba.ocn.ne.jp>

diff --git a/arch/mips/kernel/traps.c b/arch/mips/kernel/traps.c
index 368fdb7..c6f7046 100644
--- a/arch/mips/kernel/traps.c
+++ b/arch/mips/kernel/traps.c
@@ -79,6 +79,25 @@ void (*board_bind_eic_interrupt)(int irq
  */
 #define MODULE_RANGE (8*1024*1024)
 
+static void show_trace(unsigned long *stack)
+{
+       const int field = 2 * sizeof(unsigned long);
+       unsigned long addr;
+
+       printk("Call Trace:");
+#ifdef CONFIG_KALLSYMS
+       printk("\n");
+#endif
+       while (!kstack_end(stack)) {
+               addr = *stack++;
+               if (__kernel_text_address(addr)) {
+                       printk(" [<%0*lx>] ", field, addr);
+                       print_symbol("%s\n", addr);
+               }
+       }
+       printk("\n");
+}
+
 /*
  * This routine abuses get_user()/put_user() to reference pointers
  * with at least a bit of error checking ...
@@ -88,6 +107,7 @@ void show_stack(struct task_struct *task
        const int field = 2 * sizeof(unsigned long);
        long stackdata;
        int i;
+       unsigned long *stack;
 
        if (!sp) {
                if (task && task != current)
@@ -95,6 +115,7 @@ void show_stack(struct task_struct *task
                else
                        sp = (unsigned long *) &sp;
        }
+       stack = sp;
 
        printk("Stack :");
        i = 0;
@@ -115,32 +136,7 @@ void show_stack(struct task_struct *task
                i++;
        }
        printk("\n");
-}
-
-void show_trace(struct task_struct *task, unsigned long *stack)
-{
-       const int field = 2 * sizeof(unsigned long);
-       unsigned long addr;
-
-       if (!stack) {
-               if (task && task != current)
-                       stack = (unsigned long *) task->thread.reg29;
-               else
-                       stack = (unsigned long *) &stack;
-       }
-
-       printk("Call Trace:");
-#ifdef CONFIG_KALLSYMS
-       printk("\n");
-#endif
-       while (!kstack_end(stack)) {
-               addr = *stack++;
-               if (__kernel_text_address(addr)) {
-                       printk(" [<%0*lx>] ", field, addr);
-                       print_symbol("%s\n", addr);
-               }
-       }
-       printk("\n");
+       show_trace(stack);
 }
 
 /*
@@ -150,7 +146,7 @@ void dump_stack(void)
 {
        unsigned long stack;
 
-       show_trace(current, &stack);
+       show_trace(&stack);
 }
 
 EXPORT_SYMBOL(dump_stack);
@@ -270,7 +266,6 @@ void show_registers(struct pt_regs *regs
        printk("Process %s (pid: %d, threadinfo=%p, task=%p)\n",
                current->comm, current->pid, current_thread_info(), current);
        show_stack(current, (long *) regs->regs[29]);
-       show_trace(current, (long *) regs->regs[29]);
        show_code((unsigned int *) regs->cp0_epc);
        printk("\n");
 }

<Prev in Thread] Current Thread [Next in Thread>
  • [PATCH] rearrange show_stack, show_trace, Atsushi Nemoto <=