patch-2.4.8 linux/arch/cris/kernel/traps.c
Next file: linux/arch/cris/lib/Makefile
Previous file: linux/arch/cris/kernel/time.c
Back to the patch index
Back to the overall index
- Lines: 188
- Date:
Thu Jul 26 15:10:06 2001
- Orig file:
v2.4.7/linux/arch/cris/kernel/traps.c
- Orig date:
Wed Jul 25 17:10:17 2001
diff -u --recursive --new-file v2.4.7/linux/arch/cris/kernel/traps.c linux/arch/cris/kernel/traps.c
@@ -1,4 +1,4 @@
-/* $Id: traps.c,v 1.12 2001/05/15 15:46:40 bjornw Exp $
+/* $Id: traps.c,v 1.15 2001/07/18 14:02:37 bjornw Exp $
*
* linux/arch/cris/traps.c
*
@@ -9,6 +9,7 @@
* Copyright (C) 2000,2001 Axis Communications AB
*
* Authors: Bjorn Wesen
+ * Hans-Peter Nilsson
*
*/
@@ -20,6 +21,7 @@
#include <linux/ptrace.h>
#include <linux/timer.h>
#include <linux/mm.h>
+#include <asm/uaccess.h>
#include <asm/system.h>
#include <asm/segment.h>
@@ -36,6 +38,13 @@
#define MODULE_RANGE (8*1024*1024)
+/*
+ * The output (format, strings and order) is adjusted to be usable with
+ * ksymoops-2.4.1 with some necessary CRIS-specific patches. Please don't
+ * change it unless you're serious about adjusting ksymoops and syncing
+ * with the ksymoops maintainer.
+ */
+
void
show_stack(unsigned long *sp)
{
@@ -43,22 +52,31 @@
int i;
extern char _stext, _etext;
- /*
- * debugging aid: "show_stack(NULL);" prints the
- * back trace for this cpu.
- */
+ /*
+ * debugging aid: "show_stack(NULL);" prints a
+ * back trace.
+ */
if(sp == NULL)
sp = (unsigned long*)rdsp();
stack = sp;
+ printk("\nStack from %08lx:\n ", stack);
for(i = 0; i < kstack_depth_to_print; i++) {
if (((long) stack & (THREAD_SIZE-1)) == 0)
break;
if (i && ((i % 8) == 0))
printk("\n ");
- printk("%08lx ", *stack++);
+ if (__get_user (addr, stack)) {
+ /* This message matches "failing address" marked
+ s390 in ksymoops, so lines containing it will
+ not be filtered out by ksymoops. */
+ printk ("Failing address 0x%lx\n", stack);
+ break;
+ }
+ stack++;
+ printk("%08lx ", addr);
}
printk("\nCall Trace: ");
@@ -67,7 +85,15 @@
module_start = VMALLOC_START;
module_end = VMALLOC_END;
while (((long) stack & (THREAD_SIZE-1)) != 0) {
- addr = *stack++;
+ if (__get_user (addr, stack)) {
+ /* This message matches "failing address" marked
+ s390 in ksymoops, so lines containing it will
+ not be filtered out by ksymoops. */
+ printk ("Failing address 0x%lx\n", stack);
+ break;
+ }
+ stack++;
+
/*
* If the address is either in the text segment of the
* kernel, or in the region which contains vmalloc'ed
@@ -105,38 +131,53 @@
void
show_registers(struct pt_regs * regs)
{
+ /* We either use rdusp() - the USP register, which might not
+ correspond to the current process for all cases we're called,
+ or we use the current->thread.usp, which is not up to date for
+ the current process. Experience shows we want the USP
+ register. */
unsigned long usp = rdusp();
- printk("IRP: %08lx SRP: %08lx CCR: %08lx USP: %08lx MOF: %08lx\n",
+ printk("IRP: %08lx SRP: %08lx DCCR: %08lx USP: %08lx MOF: %08lx\n",
regs->irp, regs->srp, regs->dccr, usp, regs->mof );
- printk(" r0: %08lx r1: %08lx r2: %08lx r3: %08lx\n",
+ printk(" r0: %08lx r1: %08lx r2: %08lx r3: %08lx\n",
regs->r0, regs->r1, regs->r2, regs->r3);
- printk(" r4: %08lx r5: %08lx r6: %08lx r7: %08lx\n",
+ printk(" r4: %08lx r5: %08lx r6: %08lx r7: %08lx\n",
regs->r4, regs->r5, regs->r6, regs->r7);
- printk(" r8: %08lx r9: %08lx r10: %08lx r11: %08lx\n",
+ printk(" r8: %08lx r9: %08lx r10: %08lx r11: %08lx\n",
regs->r8, regs->r9, regs->r10, regs->r11);
printk("r12: %08lx r13: %08lx oR10: %08lx\n",
regs->r12, regs->r13, regs->orig_r10);
+ printk("R_MMU_CAUSE: %08lx\n", *R_MMU_CAUSE);
printk("Process %s (pid: %d, stackpage=%08lx)\n",
current->comm, current->pid, (unsigned long)current);
- /* TODO, fix in_kernel detection */
-
-#if 0
/*
* When in-kernel, we also print out the stack and code at the
* time of the fault..
*/
- if (1) {
-
- printk("\nStack: ");
+ if (! user_mode(regs)) {
+ int i;
+
show_stack((unsigned long*)usp);
+ /* Dump kernel stack if the previous dump wasn't one. */
+ if (usp != 0)
+ show_stack (NULL);
+
printk("\nCode: ");
if(regs->irp < PAGE_OFFSET)
goto bad;
- for(i = 0; i < 20; i++)
+ /* Often enough the value at regs->irp does not point to
+ the interesting instruction, which is most often the
+ _previous_ instruction. So we dump at an offset large
+ enough that instruction decoding should be in sync at
+ the interesting point, but small enough to fit on a row
+ (sort of). We point out the regs->irp location in a
+ ksymoops-friendly way by wrapping the byte for that
+ address in parentheses. */
+ for(i = -12; i < 12; i++)
{
unsigned char c;
if(__get_user(c, &((unsigned char*)regs->irp)[i])) {
@@ -144,11 +185,14 @@
printk(" Bad IP value.");
break;
}
- printk("%02x ", c);
+
+ if (i == 0)
+ printk("(%02x) ", c);
+ else
+ printk("%02x ", c);
}
+ printk("\n");
}
- printk("\n");
-#endif
}
void
@@ -157,10 +201,13 @@
if(user_mode(regs))
return;
+ stop_watchdog();
+
printk("%s: %04lx\n", str, err & 0xffff);
show_registers(regs);
- show_stack(NULL); /* print backtrace for kernel stack on this CPU */
+
+ reset_watchdog();
do_exit(SIGSEGV);
}
FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)