Use db_recover. Print trap name when entering DDB. Use trap_type and

trap_types like m68k.
This commit is contained in:
mycroft 1994-01-09 22:53:16 +00:00
parent ebc818a088
commit 8d49c8420a
2 changed files with 30 additions and 43 deletions

View File

@ -24,25 +24,26 @@
* rights to redistribute these changes. * rights to redistribute these changes.
* *
* From: db_interface.c,v 2.4 1991/02/05 17:11:13 mrt (CMU) * From: db_interface.c,v 2.4 1991/02/05 17:11:13 mrt (CMU)
* $Id: db_interface.c,v 1.6 1994/01/04 00:24:02 mycroft Exp $ * $Id: db_interface.c,v 1.7 1994/01/09 22:53:31 mycroft Exp $
*/ */
/* /*
* Interface to new debugger. * Interface to new debugger.
*/ */
#include "param.h" #include <sys/param.h>
#include "proc.h" #include <sys/proc.h>
#include <sys/reboot.h>
#include <sys/systm.h> /* just for boothowto --eichin */
#include <setjmp.h>
#include <vm/vm.h>
#include <machine/cpufunc.h> #include <machine/cpufunc.h>
#include <machine/db_machdep.h> #include <machine/db_machdep.h>
#include <sys/reboot.h> extern jmp_buf *db_recover;
#include <vm/vm_statistics.h>
#include <vm/pmap.h>
#include <setjmp.h>
#include <sys/systm.h> /* just for boothowto --eichin */
int db_active = 0; int db_active = 0;
extern jmp_buf db_jmpbuf;
/* /*
* Received keyboard interrupt sequence. * Received keyboard interrupt sequence.
@ -59,9 +60,6 @@ kdb_kbd_trap(regs)
/* /*
* kdb_trap - field a TRACE or BPT trap * kdb_trap - field a TRACE or BPT trap
*/ */
static jmp_buf *db_nofault = 0;
kdb_trap(type, code, regs) kdb_trap(type, code, regs)
int type, code; int type, code;
register struct i386_saved_state *regs; register struct i386_saved_state *regs;
@ -74,21 +72,13 @@ kdb_trap(type, code, regs)
switch (type) { switch (type) {
case T_BPTFLT: /* breakpoint */ case T_BPTFLT: /* breakpoint */
case T_TRCTRAP: /* single_step */ case T_TRCTRAP: /* single_step */
case -1: /* keyboard interrupt */ case -1: /* keyboard interrupt */
break; break;
default: default:
kdbprinttrap(type, code); kdbprinttrap(type, code);
if (db_recover != 0) {
if (db_nofault) { db_error("Faulted in DDB; continuing...\n");
jmp_buf *no_fault = db_nofault; /*NOTREACHED*/
db_nofault = 0;
longjmp(*no_fault, 1);
} else if (db_active) {
db_printf("Faulted in DDB; continuing...\n");
db_flush_lex();
longjmp(db_jmpbuf, 1);
} }
} }
@ -143,6 +133,9 @@ kdb_trap(type, code, regs)
return (1); return (1);
} }
extern char *trap_type[];
extern int trap_types;
/* /*
* Print trap reason. * Print trap reason.
*/ */
@ -150,7 +143,10 @@ kdbprinttrap(type, code)
int type, code; int type, code;
{ {
printf("kernel: "); printf("kernel: ");
if (type >= trap_types || type < 0)
printf("type %d", type); printf("type %d", type);
else
printf("%s", trap_type[type]);
printf(" trap, code=%x\n", code); printf(" trap, code=%x\n", code);
} }
@ -165,13 +161,9 @@ db_read_bytes(addr, size, data)
{ {
register char *src; register char *src;
db_nofault = &db_jmpbuf;
src = (char *)addr; src = (char *)addr;
while (--size >= 0) while (--size >= 0)
*data++ = *src++; *data++ = *src++;
db_nofault = 0;
} }
struct pte *pmap_pte(pmap_t, vm_offset_t); struct pte *pmap_pte(pmap_t, vm_offset_t);
@ -194,8 +186,6 @@ db_write_bytes(addr, size, data)
pt_entry_t oldmap1 = { 0 }; pt_entry_t oldmap1 = { 0 };
extern char etext; extern char etext;
db_nofault = &db_jmpbuf;
if (addr >= VM_MIN_KERNEL_ADDRESS && if (addr >= VM_MIN_KERNEL_ADDRESS &&
addr < (vm_offset_t)&etext) { addr < (vm_offset_t)&etext) {
ptep0 = pmap_pte(kernel_pmap, addr); ptep0 = pmap_pte(kernel_pmap, addr);
@ -217,8 +207,6 @@ db_write_bytes(addr, size, data)
while (--size >= 0) while (--size >= 0)
*dst++ = *data++; *dst++ = *data++;
db_nofault = 0;
if (ptep0) { if (ptep0) {
*ptep0 = oldmap0; *ptep0 = oldmap0;
if (ptep1) if (ptep1)

View File

@ -34,7 +34,7 @@
* SUCH DAMAGE. * SUCH DAMAGE.
* *
* from: @(#)trap.c 7.4 (Berkeley) 5/13/91 * from: @(#)trap.c 7.4 (Berkeley) 5/13/91
* $Id: trap.c,v 1.23 1994/01/04 00:15:28 mycroft Exp $ * $Id: trap.c,v 1.24 1994/01/09 22:53:16 mycroft Exp $
*/ */
/* /*
@ -67,7 +67,6 @@
struct sysent sysent[]; struct sysent sysent[];
int nsysent; int nsysent;
unsigned rcr2();
extern int cpl; extern int cpl;
/* /*
@ -126,7 +125,7 @@ userret(p, pc, syst)
curpri = p->p_pri; curpri = p->p_pri;
} }
char *trapstr[] = { char *trap_type[] = {
"privileged instruction fault", /* 0 T_PRIVINFLT */ "privileged instruction fault", /* 0 T_PRIVINFLT */
"breakpoint trap", /* 1 T_BPTFLT */ "breakpoint trap", /* 1 T_BPTFLT */
"arithmetic trap", /* 2 T_ARITHTRAP */ "arithmetic trap", /* 2 T_ARITHTRAP */
@ -146,6 +145,7 @@ char *trapstr[] = {
"segment not present fault", /* 16 T_SEGNPFLT */ "segment not present fault", /* 16 T_SEGNPFLT */
"stack fault", /* 17 T_STKFLT */ "stack fault", /* 17 T_STKFLT */
}; };
int trap_types = sizeof trap_type / sizeof trap_type[0];
/* /*
* trap(frame): * trap(frame):
@ -219,9 +219,8 @@ trap(frame)
return; return;
#endif #endif
if (frame.tf_trapno < (sizeof(trapstr) / sizeof(trapstr[0])) && if (frame.tf_trapno < trap_types)
trapstr[frame.tf_trapno]) printf("fatal %s", trap_type[frame.tf_trapno]);
printf("fatal %s", trapstr[frame.tf_trapno]);
else else
printf("unknown trap %d", frame.tf_trapno); printf("unknown trap %d", frame.tf_trapno);
printf(" in %s mode\n", (type & T_USER) ? "user" : "supervisor"); printf(" in %s mode\n", (type & T_USER) ? "user" : "supervisor");