]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - arch/x86/kernel/dumpstack_64.c
sysfs: crash debugging
[linux-2.6-omap-h63xx.git] / arch / x86 / kernel / dumpstack_64.c
index 521c833cdc3b8a63fab92b1f2eb26b465b3bf430..96a5db7da8a747e5192f410c60fe9494e8d8e8d1 100644 (file)
 #include <linux/kexec.h>
 #include <linux/bug.h>
 #include <linux/nmi.h>
+#include <linux/sysfs.h>
 
 #include <asm/stacktrace.h>
 
+#define STACKSLOTS_PER_LINE 4
+#define get_bp(bp) asm("movq %%rbp, %0" : "=r" (bp) :)
+
 int panic_on_unrecovered_nmi;
-int kstack_depth_to_print = 12;
+int kstack_depth_to_print = 3 * STACKSLOTS_PER_LINE;
 static unsigned int code_bytes = 64;
 static int die_counter;
 
@@ -177,7 +181,7 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
        if (!bp) {
                if (task == current) {
                        /* Grab bp right from our regs */
-                       asm("movq %%rbp, %0" : "=r" (bp) : );
+                       get_bp(bp);
                } else {
                        /* bp is the last reg pushed by switch_to */
                        bp = *(unsigned long *) task->thread.sp;
@@ -284,7 +288,7 @@ static void
 show_trace_log_lvl(struct task_struct *task, struct pt_regs *regs,
                unsigned long *stack, unsigned long bp, char *log_lvl)
 {
-       printk("Call Trace:\n");
+       printk("%sCall Trace:\n", log_lvl);
        dump_trace(task, regs, stack, bp, &print_trace_ops, log_lvl);
 }
 
@@ -329,8 +333,8 @@ show_stack_log_lvl(struct task_struct *task, struct pt_regs *regs,
                if (((long) stack & (THREAD_SIZE-1)) == 0)
                        break;
                }
-               if (i && ((i % 4) == 0))
-                       printk("\n");
+               if (i && ((i % STACKSLOTS_PER_LINE) == 0))
+                       printk("\n%s", log_lvl);
                printk(" %016lx", *stack++);
                touch_nmi_watchdog();
        }
@@ -353,7 +357,7 @@ void dump_stack(void)
 
 #ifdef CONFIG_FRAME_POINTER
        if (!bp)
-               asm("movq %%rbp, %0" : "=r" (bp) : );
+               get_bp(bp);
 #endif
 
        printk("Pid: %d, comm: %.20s %s %s %.*s\n",
@@ -388,15 +392,15 @@ void show_registers(struct pt_regs *regs)
                unsigned char c;
                u8 *ip;
 
-               printk("Stack: ");
+               printk(KERN_EMERG "Stack:\n");
                show_stack_log_lvl(NULL, regs, (unsigned long *)sp,
-                               regs->bp, "");
+                               regs->bp, KERN_EMERG);
 
                printk(KERN_EMERG "Code: ");
 
                ip = (u8 *)regs->ip - code_prologue;
                if (ip < (u8 *)PAGE_OFFSET || probe_kernel_address(ip, c)) {
-                       /* try starting at RIP */
+                       /* try starting at IP */
                        ip = (u8 *)regs->ip;
                        code_len = code_len - code_prologue + 1;
                }
@@ -475,7 +479,7 @@ void __kprobes oops_end(unsigned long flags, struct pt_regs *regs, int signr)
 
 int __kprobes __die(const char *str, struct pt_regs *regs, long err)
 {
-       printk(KERN_EMERG "%s: %04lx [%u] ", str, err & 0xffff, ++die_counter);
+       printk(KERN_EMERG "%s: %04lx [#%d] ", str, err & 0xffff, ++die_counter);
 #ifdef CONFIG_PREEMPT
        printk("PREEMPT ");
 #endif
@@ -486,6 +490,7 @@ int __kprobes __die(const char *str, struct pt_regs *regs, long err)
        printk("DEBUG_PAGEALLOC");
 #endif
        printk("\n");
+       sysfs_printk_last_file();
        if (notify_die(DIE_OOPS, str, regs, err,
                        current->thread.trap_no, SIGSEGV) == NOTIFY_STOP)
                return 1;