Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/arch/sh5/sh5 Add a function which dumps the machine stat...
details: https://anonhg.NetBSD.org/src/rev/4f8b61fffb61
branches: trunk
changeset: 535960:4f8b61fffb61
user: scw <scw%NetBSD.org@localhost>
date: Mon Sep 02 14:02:03 2002 +0000
description:
Add a function which dumps the machine state following a nested
critical section fault.
Also, in the regular trap() handler, use &proc0 if curproc is NULL.
diffstat:
sys/arch/sh5/sh5/trap.c | 79 ++++++++++++++++++++++++++++++++++++++++++++++--
1 files changed, 75 insertions(+), 4 deletions(-)
diffs (119 lines):
diff -r cab54ba4c712 -r 4f8b61fffb61 sys/arch/sh5/sh5/trap.c
--- a/sys/arch/sh5/sh5/trap.c Mon Sep 02 14:00:25 2002 +0000
+++ b/sys/arch/sh5/sh5/trap.c Mon Sep 02 14:02:03 2002 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: trap.c,v 1.7 2002/09/01 11:40:54 scw Exp $ */
+/* $NetBSD: trap.c,v 1.8 2002/09/02 14:02:03 scw Exp $ */
/*
* Copyright 2002 Wasabi Systems, Inc.
@@ -102,6 +102,10 @@
/* Used to trap faults while probing */
label_t *onfault;
+#ifdef DEBUG
+static int trap_debug;
+#endif
+
void
userret(struct proc *p)
{
@@ -136,9 +140,12 @@
traptype = tf->tf_state.sf_expevt;
if (USERMODE(tf)) {
+ KDASSERT(p != NULL);
traptype |= T_USER;
p->p_md.md_regs = tf;
- }
+ } else
+ if (p == NULL)
+ p = &proc0;
vaddr = (vaddr_t) tf->tf_state.sf_tea;
@@ -153,11 +160,11 @@
(uintptr_t)tf->tf_state.sf_spc,
(uintptr_t)tf->tf_state.sf_tea,
(u_int)tf->tf_state.sf_tra);
- if (curproc != NULL)
+ if (p != NULL)
printf("pid=%d cmd=%s, usp=0x%lx ",
p->p_pid, p->p_comm, (uintptr_t)tf->tf_caller.r15);
else
- printf("curproc == NULL ");
+ printf("no process context ");
printf("ksp=0x%lx\n", (vaddr_t)tf);
#if defined(DDB)
kdb_trap(traptype, tf);
@@ -403,6 +410,70 @@
panic("panic_trap");
}
+void panic_critical_fault(struct trapframe *, struct exc_scratch_frame *);
+void
+panic_critical_fault(struct trapframe *tf, struct exc_scratch_frame *es)
+{
+ extern int sh5_vector_table;
+ uintptr_t vector;
+
+ printf("\nFAULT IN CRITICAL SECTION!\n");
+
+ printf("Post Fault State: %s\n",
+ trap_type((int)tf->tf_state.sf_expevt));
+
+ printf("SSR=0x%x, SPC=0x%lx, TEA=0x%lx\n\n",
+ (u_int)tf->tf_state.sf_ssr, (uintptr_t)tf->tf_state.sf_spc,
+ (uintptr_t)tf->tf_state.sf_tea);
+
+ printf("Pre Fault State: ");
+
+ vector = (uintptr_t)tf->tf_state.sf_tea - (uintptr_t)&sh5_vector_table;
+ vector &= ~0xff;
+
+ switch (vector) {
+ case 0x0: printf("panic handler\n"); /* Can't happen */
+ break;
+
+ case 0x100: printf("General exception handler\n");
+ printf("\t%s in %s mode\n",
+ trap_type((int)es->es_expevt),
+ (es->es_ssr & SH5_CONREG_SR_MD)?"kernel":"user");
+ break;
+
+ case 0x200: printf("debug interrupt handler\n"); /* Can't happen */
+ break;
+
+ case 0x600: printf("H/W interrupt handler\n");
+ break;
+
+ default: printf("Not sure. Probably Ltlbmiss_dotrap\n");
+ break;
+ }
+
+ printf("STACKPTR=0x%x, SSR=0x%x, SPC=0x%lx\n",
+ (u_int)tf->tf_caller.r15, (u_int)es->es_ssr, (uintptr_t)es->es_spc);
+ printf("TEA=0x%lx, TRA=0x%x, INTEVT=0x%lx\n\n",
+ (uintptr_t)es->es_tea, (u_int)es->es_tra, (u_int)es->es_intevt);
+
+ printf("Exception temporaries:\n");
+ printf("r0=0x%08x%08x, r1=0x%08x%08x, r2=0x%08x%08x\n",
+ (u_int)(tf->tf_caller.r0 >> 32), (u_int)tf->tf_caller.r0,
+ (u_int)(tf->tf_caller.r1 >> 32), (u_int)tf->tf_caller.r1,
+ (u_int)(tf->tf_caller.r2 >> 32), (u_int)tf->tf_caller.r2);
+
+ printf("\nPre-exception Context:\n");
+ tf->tf_caller.r0 = es->es_r[0];
+ tf->tf_caller.r1 = es->es_r[1];
+ tf->tf_caller.r2 = es->es_r[2];
+ tf->tf_caller.r15 = es->es_r15;
+ tf->tf_caller.tr0 = es->es_tr0;
+
+ dump_trapframe(tf);
+
+ panic("panic_critical_fault");
+}
+
const char *
trap_type(int traptype)
{
Home |
Main Index |
Thread Index |
Old Index