From 873822cd833c6f125d95130a1fe85df82b78fe3b Mon Sep 17 00:00:00 2001 From: jhb Date: Tue, 15 Jan 2002 14:17:07 +0000 Subject: [PATCH] - Catch up printtrap() to KSE by using curthread and testing it against NULL rather than curproc. Without this, if we trap early before curthread is set, we recursively panic. - In an SMP kernel, if we trap before curthread is set, then trap is going to recursively panic trying to bump td->td_md.md_kernnest. The trap is fatal anyways, so to make debugging easier just call printtrap() to dump the trap info to the console and then halt. --- sys/alpha/alpha/trap.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/sys/alpha/alpha/trap.c b/sys/alpha/alpha/trap.c index 99278faf759b..c4c402a4d739 100644 --- a/sys/alpha/alpha/trap.c +++ b/sys/alpha/alpha/trap.c @@ -235,12 +235,12 @@ printtrap(a0, a1, a2, entry, framep, isfatal, user) printf(" pc = 0x%lx\n", framep->tf_regs[FRAME_PC]); printf(" ra = 0x%lx\n", framep->tf_regs[FRAME_RA]); printf(" sp = 0x%lx\n", framep->tf_regs[FRAME_SP]); - if (curproc != NULL && (curproc->p_flag & P_KTHREAD) == 0) + if (curthread != NULL && (curthread->td_proc->p_flag & P_KTHREAD) == 0) printf(" usp = 0x%lx\n", alpha_pal_rdusp()); - printf(" curproc = %p\n", curproc); - if (curproc != NULL) - printf(" pid = %d, comm = %s\n", curproc->p_pid, - curproc->p_comm); + printf(" curthread = %p\n", curthread); + if (curthread != NULL) + printf(" pid = %d, comm = %s\n", + curthread->td_proc->p_pid, curthread->td_proc->p_comm); printf("\n"); } @@ -275,6 +275,10 @@ trap(a0, a1, a2, entry, framep) pcpup = (struct pcpu *) alpha_pal_rdval(); td = curthread; #ifdef SMP + if (td == NULL) { + printtrap(a0, a1, a2, entry, framep, 1, 0); + cpu_halt(); + } td->td_md.md_kernnest++; cpu_critical_exit(s); #endif