diff options
author | Niklas Hallqvist <niklas@cvs.openbsd.org> | 1997-07-06 17:18:51 +0000 |
---|---|---|
committer | Niklas Hallqvist <niklas@cvs.openbsd.org> | 1997-07-06 17:18:51 +0000 |
commit | 447a6722ca3bbbaa64dbed101827480c60093754 (patch) | |
tree | d4155debff3b994874d33d8cf8b669a4b50d727c /sys/arch/alpha | |
parent | 067e8027959998ddeebaf8e47951a1d2802d4ab7 (diff) |
Use a string array to get the name of a trap
Diffstat (limited to 'sys/arch/alpha')
-rw-r--r-- | sys/arch/alpha/alpha/trap.c | 39 |
1 files changed, 14 insertions, 25 deletions
diff --git a/sys/arch/alpha/alpha/trap.c b/sys/arch/alpha/alpha/trap.c index 59ee949567f..a2a36e124db 100644 --- a/sys/arch/alpha/alpha/trap.c +++ b/sys/arch/alpha/alpha/trap.c @@ -1,4 +1,4 @@ -/* $OpenBSD: trap.c,v 1.12 1997/07/06 16:23:48 niklas Exp $ */ +/* $OpenBSD: trap.c,v 1.13 1997/07/06 17:18:50 niklas Exp $ */ /* $NetBSD: trap.c,v 1.19 1996/11/27 01:28:30 cgd Exp $ */ /* @@ -122,6 +122,16 @@ userret(p, pc, oticks) curpriority = p->p_priority; } +char *trap_type[] = { + "interrupt", /* 0 ALPHA_KENTRY_INT */ + "arithmetic trap", /* 1 ALPHA_KENTRY_ARITH */ + "memory management fault", /* 2 ALPHA_KENTRY_MM */ + "instruction fault", /* 3 ALPHA_KENTRY_IF */ + "unaligned access fault", /* 4 ALPHA_KENTRY_UNA */ + "system call", /* 5 ALPHA_KENTRY_SYS */ +}; +int trap_types = sizeof trap_type / sizeof trap_type[0]; + /* * Trap is called from locore to handle most types of processor traps. * System calls are broken out for efficiency and ASTs are broken out @@ -442,31 +452,10 @@ out: dopanic: { - const char *entryname; + const char *entryname = "???"; - switch (entry) { - case ALPHA_KENTRY_INT: - entryname = "interrupt"; - break; - case ALPHA_KENTRY_ARITH: - entryname = "arithmetic trap"; - break; - case ALPHA_KENTRY_MM: - entryname = "memory management fault"; - break; - case ALPHA_KENTRY_IF: - entryname = "instruction fault"; - break; - case ALPHA_KENTRY_UNA: - entryname = "unaligned access fault"; - break; - case ALPHA_KENTRY_SYS: - entryname = "system call"; - break; - default: - entryname = "???"; - break; - } + if (entry > 0 && entry < trap_types) + entryname = trap_type[entry]; printf("\n"); printf("fatal %s trap:\n", user ? "user" : "kernel"); |