From 4e01e6de8b3fc51b8d510bd409ac23e174f52a71 Mon Sep 17 00:00:00 2001 From: tsubai Date: Fri, 24 Nov 2000 21:49:06 +0000 Subject: [PATCH] When fatal trap occurs, enter DDB with trapframe rather than just "Debugger()". --- sys/arch/powerpc/powerpc/db_interface.c | 39 ++++++++++++++++++++++++- sys/arch/powerpc/powerpc/trap.c | 5 ++-- 2 files changed, 41 insertions(+), 3 deletions(-) diff --git a/sys/arch/powerpc/powerpc/db_interface.c b/sys/arch/powerpc/powerpc/db_interface.c index d3a93aabb353..32746d0c84ab 100644 --- a/sys/arch/powerpc/powerpc/db_interface.c +++ b/sys/arch/powerpc/powerpc/db_interface.c @@ -1,4 +1,4 @@ -/* $NetBSD: db_interface.c,v 1.7 2000/06/11 10:02:15 tsubai Exp $ */ +/* $NetBSD: db_interface.c,v 1.8 2000/11/24 21:49:06 tsubai Exp $ */ /* $OpenBSD: db_interface.c,v 1.2 1996/12/28 06:21:50 rahnds Exp $ */ #include "opt_ddb.h" @@ -17,6 +17,8 @@ #include #include +extern label_t *db_recover; + void cpu_Debugger() { @@ -47,3 +49,38 @@ ddb_trap_glue(frame) } return 0; } + +int +kdb_trap(type, v) + int type; + void *v; +{ + struct trapframe *frame = v; + + switch (type) { + case T_BREAKPOINT: + case -1: + break; + default: + if (!db_onpanic && db_recover == 0) + return 0; + if (db_recover != 0) { + db_error("Faulted in DDB; continuing...\n"); + /*NOTREACHED*/ + } + } + + /* XXX Should switch to kdb's own stack here. */ + + bcopy(frame->fixreg, DDB_REGS->r, 32 * sizeof(u_int32_t)); + DDB_REGS->iar = frame->srr0; + DDB_REGS->msr = frame->srr1; + + db_trap(T_BREAKPOINT, 0); + + bcopy(DDB_REGS->r, frame->fixreg, 32 * sizeof(u_int32_t)); + frame->srr0 = DDB_REGS->iar; + frame->srr1 = DDB_REGS->msr; + + return 1; +} diff --git a/sys/arch/powerpc/powerpc/trap.c b/sys/arch/powerpc/powerpc/trap.c index de07c6c24aed..529dca71ee17 100644 --- a/sys/arch/powerpc/powerpc/trap.c +++ b/sys/arch/powerpc/powerpc/trap.c @@ -1,4 +1,4 @@ -/* $NetBSD: trap.c,v 1.29 2000/11/22 14:00:46 tsubai Exp $ */ +/* $NetBSD: trap.c,v 1.30 2000/11/24 21:49:06 tsubai Exp $ */ /* * Copyright (C) 1995, 1996 Wolfgang Solfrank. @@ -295,7 +295,8 @@ syscall_bad: brain_damage: printf("trap type %x at %x\n", type, frame->srr0); #ifdef DDB - Debugger(); /* XXX temporarily */ + if (kdb_trap(type, frame)) + return; #endif #ifdef TRAP_PANICWAIT printf("Press a key to panic.\n");