aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMikael Starvik <mikael.starvik@axis.com>2005-07-27 14:44:32 -0400
committerLinus Torvalds <torvalds@g5.osdl.org>2005-07-27 19:25:59 -0400
commit059163cabc01a15b9e2cf10e5de5b6dc06e0da1f (patch)
treed053763ad90eeb4a6835d2ff888f2d36428f881c
parent05b4c28cba8dc48505322988340307073c353b1e (diff)
[PATCH] CRIS update: debug
Improvements to crash debug code. Signed-off-by: Mikael Starvik <starvik@axis.com> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
-rw-r--r--arch/cris/arch-v10/kernel/traps.c37
-rw-r--r--arch/cris/kernel/traps.c64
2 files changed, 75 insertions, 26 deletions
diff --git a/arch/cris/arch-v10/kernel/traps.c b/arch/cris/arch-v10/kernel/traps.c
index da491f438a6..34a27ea2052 100644
--- a/arch/cris/arch-v10/kernel/traps.c
+++ b/arch/cris/arch-v10/kernel/traps.c
@@ -1,4 +1,4 @@
1/* $Id: traps.c,v 1.2 2003/07/04 08:27:41 starvik Exp $ 1/* $Id: traps.c,v 1.4 2005/04/24 18:47:55 starvik Exp $
2 * 2 *
3 * linux/arch/cris/arch-v10/traps.c 3 * linux/arch/cris/arch-v10/traps.c
4 * 4 *
@@ -16,6 +16,8 @@
16#include <asm/uaccess.h> 16#include <asm/uaccess.h>
17#include <asm/arch/sv_addr_ag.h> 17#include <asm/arch/sv_addr_ag.h>
18 18
19extern int raw_printk(const char *fmt, ...);
20
19void 21void
20show_registers(struct pt_regs * regs) 22show_registers(struct pt_regs * regs)
21{ 23{
@@ -26,18 +28,18 @@ show_registers(struct pt_regs * regs)
26 register. */ 28 register. */
27 unsigned long usp = rdusp(); 29 unsigned long usp = rdusp();
28 30
29 printk("IRP: %08lx SRP: %08lx DCCR: %08lx USP: %08lx MOF: %08lx\n", 31 raw_printk("IRP: %08lx SRP: %08lx DCCR: %08lx USP: %08lx MOF: %08lx\n",
30 regs->irp, regs->srp, regs->dccr, usp, regs->mof ); 32 regs->irp, regs->srp, regs->dccr, usp, regs->mof );
31 printk(" r0: %08lx r1: %08lx r2: %08lx r3: %08lx\n", 33 raw_printk(" r0: %08lx r1: %08lx r2: %08lx r3: %08lx\n",
32 regs->r0, regs->r1, regs->r2, regs->r3); 34 regs->r0, regs->r1, regs->r2, regs->r3);
33 printk(" r4: %08lx r5: %08lx r6: %08lx r7: %08lx\n", 35 raw_printk(" r4: %08lx r5: %08lx r6: %08lx r7: %08lx\n",
34 regs->r4, regs->r5, regs->r6, regs->r7); 36 regs->r4, regs->r5, regs->r6, regs->r7);
35 printk(" r8: %08lx r9: %08lx r10: %08lx r11: %08lx\n", 37 raw_printk(" r8: %08lx r9: %08lx r10: %08lx r11: %08lx\n",
36 regs->r8, regs->r9, regs->r10, regs->r11); 38 regs->r8, regs->r9, regs->r10, regs->r11);
37 printk("r12: %08lx r13: %08lx oR10: %08lx\n", 39 raw_printk("r12: %08lx r13: %08lx oR10: %08lx sp: %08lx\n",
38 regs->r12, regs->r13, regs->orig_r10); 40 regs->r12, regs->r13, regs->orig_r10, regs);
39 printk("R_MMU_CAUSE: %08lx\n", (unsigned long)*R_MMU_CAUSE); 41 raw_printk("R_MMU_CAUSE: %08lx\n", (unsigned long)*R_MMU_CAUSE);
40 printk("Process %s (pid: %d, stackpage=%08lx)\n", 42 raw_printk("Process %s (pid: %d, stackpage=%08lx)\n",
41 current->comm, current->pid, (unsigned long)current); 43 current->comm, current->pid, (unsigned long)current);
42 44
43 /* 45 /*
@@ -53,7 +55,7 @@ show_registers(struct pt_regs * regs)
53 if (usp != 0) 55 if (usp != 0)
54 show_stack (NULL, NULL); 56 show_stack (NULL, NULL);
55 57
56 printk("\nCode: "); 58 raw_printk("\nCode: ");
57 if(regs->irp < PAGE_OFFSET) 59 if(regs->irp < PAGE_OFFSET)
58 goto bad; 60 goto bad;
59 61
@@ -70,16 +72,16 @@ show_registers(struct pt_regs * regs)
70 unsigned char c; 72 unsigned char c;
71 if(__get_user(c, &((unsigned char*)regs->irp)[i])) { 73 if(__get_user(c, &((unsigned char*)regs->irp)[i])) {
72bad: 74bad:
73 printk(" Bad IP value."); 75 raw_printk(" Bad IP value.");
74 break; 76 break;
75 } 77 }
76 78
77 if (i == 0) 79 if (i == 0)
78 printk("(%02x) ", c); 80 raw_printk("(%02x) ", c);
79 else 81 else
80 printk("%02x ", c); 82 raw_printk("%02x ", c);
81 } 83 }
82 printk("\n"); 84 raw_printk("\n");
83 } 85 }
84} 86}
85 87
@@ -121,7 +123,7 @@ die_if_kernel(const char * str, struct pt_regs * regs, long err)
121 stop_watchdog(); 123 stop_watchdog();
122#endif 124#endif
123 125
124 printk("%s: %04lx\n", str, err & 0xffff); 126 raw_printk("%s: %04lx\n", str, err & 0xffff);
125 127
126 show_registers(regs); 128 show_registers(regs);
127 129
@@ -130,3 +132,8 @@ die_if_kernel(const char * str, struct pt_regs * regs, long err)
130#endif 132#endif
131 do_exit(SIGSEGV); 133 do_exit(SIGSEGV);
132} 134}
135
136void arch_enable_nmi(void)
137{
138 asm volatile("setf m");
139}
diff --git a/arch/cris/kernel/traps.c b/arch/cris/kernel/traps.c
index d4dfa050e3a..520d92205fe 100644
--- a/arch/cris/kernel/traps.c
+++ b/arch/cris/kernel/traps.c
@@ -1,4 +1,4 @@
1/* $Id: traps.c,v 1.9 2004/05/11 12:28:26 starvik Exp $ 1/* $Id: traps.c,v 1.11 2005/01/24 16:03:19 orjanf Exp $
2 * 2 *
3 * linux/arch/cris/traps.c 3 * linux/arch/cris/traps.c
4 * 4 *
@@ -20,13 +20,15 @@
20 20
21static int kstack_depth_to_print = 24; 21static int kstack_depth_to_print = 24;
22 22
23extern int raw_printk(const char *fmt, ...);
24
23void show_trace(unsigned long * stack) 25void show_trace(unsigned long * stack)
24{ 26{
25 unsigned long addr, module_start, module_end; 27 unsigned long addr, module_start, module_end;
26 extern char _stext, _etext; 28 extern char _stext, _etext;
27 int i; 29 int i;
28 30
29 printk("\nCall Trace: "); 31 raw_printk("\nCall Trace: ");
30 32
31 i = 1; 33 i = 1;
32 module_start = VMALLOC_START; 34 module_start = VMALLOC_START;
@@ -37,7 +39,7 @@ void show_trace(unsigned long * stack)
37 /* This message matches "failing address" marked 39 /* This message matches "failing address" marked
38 s390 in ksymoops, so lines containing it will 40 s390 in ksymoops, so lines containing it will
39 not be filtered out by ksymoops. */ 41 not be filtered out by ksymoops. */
40 printk ("Failing address 0x%lx\n", (unsigned long)stack); 42 raw_printk ("Failing address 0x%lx\n", (unsigned long)stack);
41 break; 43 break;
42 } 44 }
43 stack++; 45 stack++;
@@ -54,8 +56,8 @@ void show_trace(unsigned long * stack)
54 (addr <= (unsigned long) &_etext)) || 56 (addr <= (unsigned long) &_etext)) ||
55 ((addr >= module_start) && (addr <= module_end))) { 57 ((addr >= module_start) && (addr <= module_end))) {
56 if (i && ((i % 8) == 0)) 58 if (i && ((i % 8) == 0))
57 printk("\n "); 59 raw_printk("\n ");
58 printk("[<%08lx>] ", addr); 60 raw_printk("[<%08lx>] ", addr);
59 i++; 61 i++;
60 } 62 }
61 } 63 }
@@ -96,25 +98,59 @@ show_stack(struct task_struct *task, unsigned long *sp)
96 98
97 stack = sp; 99 stack = sp;
98 100
99 printk("\nStack from %08lx:\n ", (unsigned long)stack); 101 raw_printk("\nStack from %08lx:\n ", (unsigned long)stack);
100 for(i = 0; i < kstack_depth_to_print; i++) { 102 for(i = 0; i < kstack_depth_to_print; i++) {
101 if (((long) stack & (THREAD_SIZE-1)) == 0) 103 if (((long) stack & (THREAD_SIZE-1)) == 0)
102 break; 104 break;
103 if (i && ((i % 8) == 0)) 105 if (i && ((i % 8) == 0))
104 printk("\n "); 106 raw_printk("\n ");
105 if (__get_user (addr, stack)) { 107 if (__get_user (addr, stack)) {
106 /* This message matches "failing address" marked 108 /* This message matches "failing address" marked
107 s390 in ksymoops, so lines containing it will 109 s390 in ksymoops, so lines containing it will
108 not be filtered out by ksymoops. */ 110 not be filtered out by ksymoops. */
109 printk ("Failing address 0x%lx\n", (unsigned long)stack); 111 raw_printk ("Failing address 0x%lx\n", (unsigned long)stack);
110 break; 112 break;
111 } 113 }
112 stack++; 114 stack++;
113 printk("%08lx ", addr); 115 raw_printk("%08lx ", addr);
114 } 116 }
115 show_trace(sp); 117 show_trace(sp);
116} 118}
117 119
120static void (*nmi_handler)(struct pt_regs*);
121extern void arch_enable_nmi(void);
122
123void set_nmi_handler(void (*handler)(struct pt_regs*))
124{
125 nmi_handler = handler;
126 arch_enable_nmi();
127}
128
129void handle_nmi(struct pt_regs* regs)
130{
131 if (nmi_handler)
132 nmi_handler(regs);
133}
134
135#ifdef CONFIG_DEBUG_NMI_OOPS
136void oops_nmi_handler(struct pt_regs* regs)
137{
138 stop_watchdog();
139 raw_printk("NMI!\n");
140 show_registers(regs);
141}
142
143static int
144__init oops_nmi_register(void)
145{
146 set_nmi_handler(oops_nmi_handler);
147 return 0;
148}
149
150__initcall(oops_nmi_register);
151
152#endif
153
118#if 0 154#if 0
119/* displays a short stack trace */ 155/* displays a short stack trace */
120 156
@@ -123,9 +159,9 @@ show_stack()
123{ 159{
124 unsigned long *sp = (unsigned long *)rdusp(); 160 unsigned long *sp = (unsigned long *)rdusp();
125 int i; 161 int i;
126 printk("Stack dump [0x%08lx]:\n", (unsigned long)sp); 162 raw_printk("Stack dump [0x%08lx]:\n", (unsigned long)sp);
127 for(i = 0; i < 16; i++) 163 for(i = 0; i < 16; i++)
128 printk("sp + %d: 0x%08lx\n", i*4, sp[i]); 164 raw_printk("sp + %d: 0x%08lx\n", i*4, sp[i]);
129 return 0; 165 return 0;
130} 166}
131#endif 167#endif
@@ -142,3 +178,9 @@ trap_init(void)
142{ 178{
143 /* Nothing needs to be done */ 179 /* Nothing needs to be done */
144} 180}
181
182void spinning_cpu(void* addr)
183{
184 raw_printk("CPU %d spinning on %X\n", smp_processor_id(), addr);
185 dump_stack();
186}