PERFORCE change 31848 for review

Juli Mallett jmallett at FreeBSD.org
Sun May 25 01:56:16 PDT 2003


http://perforce.freebsd.org/chv.cgi?CH=31848

Change 31848 by jmallett at jmallett_dalek on 2003/05/25 01:56:03

	Mildly more interesting trap() output.

Affected files ...

.. //depot/projects/mips/sys/mips/mips/trap.c#3 edit

Differences ...

==== //depot/projects/mips/sys/mips/mips/trap.c#3 (text+ko) ====

@@ -32,16 +32,72 @@
 #include <machine/frame.h>
 #include <machine/trap.h>
 
+struct trap_identifier {
+	u_int ExcCode;
+	const char *Mnemonic;
+	const char *Description;
+} trap_ids[] = {
+	{ 0,	"Int",		"Interrupt" },
+	{ 1,	"Mod",		"TLB modification" },
+	{ 2,	"TLBL",		"TLB (fetch" },
+	{ 3,	"TLBS",		"TLB (store)" },
+	{ 4,	"AdEL",		"Address error (fetch)" },
+	{ 5,	"AdES",		"Address error (store)" },
+	{ 6,	"IBE",		"Bus error (instruction)" },
+	{ 7,	"DBE",		"Bus error (data)" },
+	{ 8,	"Sys",		"System call" },
+	{ 9,	"Bp",		"Breakpoint" },
+	{ 10,	"RI",		"Reserved instruction" },
+	{ 11,	"CpU",		"Coprocessor unusable" },
+	{ 12,	"Ov",		"Arithmetic overflow" },
+	{ 13,	"Tr",		"Trap" },
+	{ 14,	"VCEI",		"Virtual coherency (instruction)" },
+	{ 15,	"FPE",		"Floating point" },
+	{ 16,	NULL,		NULL },
+	{ 17,	NULL,		NULL },
+	{ 18,	NULL,		NULL },
+	{ 19,	NULL,		NULL },
+	{ 20,	NULL,		NULL },
+	{ 21,	NULL,		NULL },
+	{ 22,	NULL,		NULL },
+	{ 23,	"WATCH",	"Watchpoint" },
+	{ 24,	NULL,		NULL },
+	{ 25,	NULL,		NULL },
+	{ 26,	NULL,		NULL },
+	{ 27,	NULL,		NULL },
+	{ 28,	NULL,		NULL },
+	{ 29,	NULL,		NULL },
+	{ 30,	NULL,		NULL },
+	{ 31,	"VCED",		"Virtual coherency (data)" }
+};
+#define	MAXTRAPID	31
+
 void
 trap(struct trapframe *tf, u_int cause, void *badvaddr)
 {
+	struct trap_identifier *tid;
 	int code, kernelmode;
 
 	code = (cause & MIPS3_CR_EXC_CODE) >> MIPS_CR_EXC_CODE_SHIFT;
 	kernelmode = (tf->tf_regs[TF_SR] & MIPS_SR_KSU_USER) == 0;
-	printf("Fatal trap type %d in %s mode\n",
+	printf("\n\nFatal trap type %d in %s mode:",
 	       code, kernelmode ? "kernel" : "user");
-	printf("EPC %lx, BadVAddr %p\n", tf->tf_regs[TF_EPC], badvaddr);
+	if (code <= MAXTRAPID && code >= 0) {
+		tid = &trap_ids[code];
+		if (tid->Mnemonic != NULL)
+			printf(" (%s)", tid->Mnemonic);
+		if (tid->Description != NULL)
+			printf(" %s", tid->Description);
+		else
+			printf(" Reserved exception code");
+	} else
+		printf(" (out of range)");
+	printf("\n");
+	printf("    program counter = %lx\n", tf->tf_regs[TF_EPC]);
+	printf("     return address = %lx\n", tf->tf_regs[TF_RA]);
+	printf("bad virtual address = %p\n", badvaddr);
+	printf("              cause = %x\n", cause);
+	printf("             status = %lx\n", tf->tf_regs[TF_SR]);
 	if (panicstr != NULL) {
 		printf("Double panic, resetting...\n");
 		cpu_reset();


More information about the p4-projects mailing list