[PATCH] m68k: fix show_registers()
authorRoman Zippel <zippel@linux-m68k.org>
Sun, 25 Jun 2006 12:46:58 +0000 (05:46 -0700)
committerLinus Torvalds <torvalds@g5.osdl.org>
Sun, 25 Jun 2006 17:00:56 +0000 (10:00 -0700)
Move some of the prints in die_if_kernel() to show_registers() and call that
instead of show_stack(), so show_registers() prints now similiar info as other
archs.  Clean up the function a little.

Signed-off-by: Roman Zippel <zippel@linux-m68k.org>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
arch/m68k/kernel/traps.c

index 837a88709902b016f1fcc4e0d3e5586ef03db947..9adf378f8f1e044a64e6a60b132361224061efd0 100644 (file)
@@ -927,66 +927,88 @@ void show_trace(unsigned long *stack)
 void show_registers(struct pt_regs *regs)
 {
        struct frame *fp = (struct frame *)regs;
+       mm_segment_t old_fs = get_fs();
+       u16 c, *cp;
        unsigned long addr;
        int i;
 
+       print_modules();
+       printk("PC: [<%08lx>]",regs->pc);
+       print_symbol(" %s", regs->pc);
+       printk("\nSR: %04x  SP: %p  a2: %08lx\n",
+              regs->sr, regs, regs->a2);
+       printk("d0: %08lx    d1: %08lx    d2: %08lx    d3: %08lx\n",
+              regs->d0, regs->d1, regs->d2, regs->d3);
+       printk("d4: %08lx    d5: %08lx    a0: %08lx    a1: %08lx\n",
+              regs->d4, regs->d5, regs->a0, regs->a1);
+
+       printk("Process %s (pid: %d, task=%p)\n",
+               current->comm, current->pid, current);
        addr = (unsigned long)&fp->un;
-       printk("Frame format=%X ", fp->ptregs.format);
-       switch (fp->ptregs.format) {
+       printk("Frame format=%X ", regs->format);
+       switch (regs->format) {
        case 0x2:
-           printk("instr addr=%08lx\n", fp->un.fmt2.iaddr);
-           addr += sizeof(fp->un.fmt2);
-           break;
+               printk("instr addr=%08lx\n", fp->un.fmt2.iaddr);
+               addr += sizeof(fp->un.fmt2);
+               break;
        case 0x3:
-           printk("eff addr=%08lx\n", fp->un.fmt3.effaddr);
-           addr += sizeof(fp->un.fmt3);
-           break;
+               printk("eff addr=%08lx\n", fp->un.fmt3.effaddr);
+               addr += sizeof(fp->un.fmt3);
+               break;
        case 0x4:
-           printk((CPU_IS_060 ? "fault addr=%08lx fslw=%08lx\n"
-                   : "eff addr=%08lx pc=%08lx\n"),
-                  fp->un.fmt4.effaddr, fp->un.fmt4.pc);
-           addr += sizeof(fp->un.fmt4);
-           break;
+               printk((CPU_IS_060 ? "fault addr=%08lx fslw=%08lx\n"
+                       : "eff addr=%08lx pc=%08lx\n"),
+                       fp->un.fmt4.effaddr, fp->un.fmt4.pc);
+               addr += sizeof(fp->un.fmt4);
+               break;
        case 0x7:
-           printk("eff addr=%08lx ssw=%04x faddr=%08lx\n",
-                  fp->un.fmt7.effaddr, fp->un.fmt7.ssw, fp->un.fmt7.faddr);
-           printk("wb 1 stat/addr/data: %04x %08lx %08lx\n",
-                  fp->un.fmt7.wb1s, fp->un.fmt7.wb1a, fp->un.fmt7.wb1dpd0);
-           printk("wb 2 stat/addr/data: %04x %08lx %08lx\n",
-                  fp->un.fmt7.wb2s, fp->un.fmt7.wb2a, fp->un.fmt7.wb2d);
-           printk("wb 3 stat/addr/data: %04x %08lx %08lx\n",
-                  fp->un.fmt7.wb3s, fp->un.fmt7.wb3a, fp->un.fmt7.wb3d);
-           printk("push data: %08lx %08lx %08lx %08lx\n",
-                  fp->un.fmt7.wb1dpd0, fp->un.fmt7.pd1, fp->un.fmt7.pd2,
-                  fp->un.fmt7.pd3);
-           addr += sizeof(fp->un.fmt7);
-           break;
+               printk("eff addr=%08lx ssw=%04x faddr=%08lx\n",
+                       fp->un.fmt7.effaddr, fp->un.fmt7.ssw, fp->un.fmt7.faddr);
+               printk("wb 1 stat/addr/data: %04x %08lx %08lx\n",
+                       fp->un.fmt7.wb1s, fp->un.fmt7.wb1a, fp->un.fmt7.wb1dpd0);
+               printk("wb 2 stat/addr/data: %04x %08lx %08lx\n",
+                       fp->un.fmt7.wb2s, fp->un.fmt7.wb2a, fp->un.fmt7.wb2d);
+               printk("wb 3 stat/addr/data: %04x %08lx %08lx\n",
+                       fp->un.fmt7.wb3s, fp->un.fmt7.wb3a, fp->un.fmt7.wb3d);
+               printk("push data: %08lx %08lx %08lx %08lx\n",
+                       fp->un.fmt7.wb1dpd0, fp->un.fmt7.pd1, fp->un.fmt7.pd2,
+                       fp->un.fmt7.pd3);
+               addr += sizeof(fp->un.fmt7);
+               break;
        case 0x9:
-           printk("instr addr=%08lx\n", fp->un.fmt9.iaddr);
-           addr += sizeof(fp->un.fmt9);
-           break;
+               printk("instr addr=%08lx\n", fp->un.fmt9.iaddr);
+               addr += sizeof(fp->un.fmt9);
+               break;
        case 0xa:
-           printk("ssw=%04x isc=%04x isb=%04x daddr=%08lx dobuf=%08lx\n",
-                  fp->un.fmta.ssw, fp->un.fmta.isc, fp->un.fmta.isb,
-                  fp->un.fmta.daddr, fp->un.fmta.dobuf);
-           addr += sizeof(fp->un.fmta);
-           break;
+               printk("ssw=%04x isc=%04x isb=%04x daddr=%08lx dobuf=%08lx\n",
+                       fp->un.fmta.ssw, fp->un.fmta.isc, fp->un.fmta.isb,
+                       fp->un.fmta.daddr, fp->un.fmta.dobuf);
+               addr += sizeof(fp->un.fmta);
+               break;
        case 0xb:
-           printk("ssw=%04x isc=%04x isb=%04x daddr=%08lx dobuf=%08lx\n",
-                  fp->un.fmtb.ssw, fp->un.fmtb.isc, fp->un.fmtb.isb,
-                  fp->un.fmtb.daddr, fp->un.fmtb.dobuf);
-           printk("baddr=%08lx dibuf=%08lx ver=%x\n",
-                  fp->un.fmtb.baddr, fp->un.fmtb.dibuf, fp->un.fmtb.ver);
-           addr += sizeof(fp->un.fmtb);
-           break;
+               printk("ssw=%04x isc=%04x isb=%04x daddr=%08lx dobuf=%08lx\n",
+                       fp->un.fmtb.ssw, fp->un.fmtb.isc, fp->un.fmtb.isb,
+                       fp->un.fmtb.daddr, fp->un.fmtb.dobuf);
+               printk("baddr=%08lx dibuf=%08lx ver=%x\n",
+                       fp->un.fmtb.baddr, fp->un.fmtb.dibuf, fp->un.fmtb.ver);
+               addr += sizeof(fp->un.fmtb);
+               break;
        default:
-           printk("\n");
+               printk("\n");
        }
        show_stack(NULL, (unsigned long *)addr);
 
-       printk("Code: ");
-       for (i = 0; i < 10; i++)
-               printk("%04x ", 0xffff & ((short *) fp->ptregs.pc)[i]);
+       printk("Code:");
+       set_fs(KERNEL_DS);
+       cp = (u16 *)regs->pc;
+       for (i = -8; i < 16; i++) {
+               if (get_user(c, cp + i) && i >= 0) {
+                       printk(" Bad PC value.");
+                       break;
+               }
+               printk(i ? " %04x" : " <%04x>", c);
+       }
+       set_fs(old_fs);
        printk ("\n");
 }
 
@@ -1190,19 +1212,7 @@ void die_if_kernel (char *str, struct pt_regs *fp, int nr)
 
        console_verbose();
        printk("%s: %08x\n",str,nr);
-       print_modules();
-       printk("PC: [<%08lx>]",fp->pc);
-       print_symbol(" %s\n", fp->pc);
-       printk("\nSR: %04x  SP: %p  a2: %08lx\n",
-              fp->sr, fp, fp->a2);
-       printk("d0: %08lx    d1: %08lx    d2: %08lx    d3: %08lx\n",
-              fp->d0, fp->d1, fp->d2, fp->d3);
-       printk("d4: %08lx    d5: %08lx    a0: %08lx    a1: %08lx\n",
-              fp->d4, fp->d5, fp->a0, fp->a1);
-
-       printk("Process %s (pid: %d, stackpage=%08lx)\n",
-               current->comm, current->pid, PAGE_SIZE+(unsigned long)current);
-       show_stack(NULL, (unsigned long *)fp);
+       show_registers(fp);
        do_exit(SIGSEGV);
 }