From owner-p4-projects@FreeBSD.ORG Thu Jul 5 13:57:52 2007 Return-Path: X-Original-To: p4-projects@freebsd.org Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 5463916A46F; Thu, 5 Jul 2007 13:57:52 +0000 (UTC) X-Original-To: perforce@FreeBSD.org Delivered-To: perforce@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 025F616A400 for ; Thu, 5 Jul 2007 13:57:52 +0000 (UTC) (envelope-from gonzo@FreeBSD.org) Received: from repoman.freebsd.org (repoman.freebsd.org [69.147.83.41]) by mx1.freebsd.org (Postfix) with ESMTP id E73C613C4C3 for ; Thu, 5 Jul 2007 13:57:51 +0000 (UTC) (envelope-from gonzo@FreeBSD.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.13.8/8.13.8) with ESMTP id l65DvpwO075541 for ; Thu, 5 Jul 2007 13:57:51 GMT (envelope-from gonzo@FreeBSD.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.13.8/8.13.8/Submit) id l65Dvp18075538 for perforce@freebsd.org; Thu, 5 Jul 2007 13:57:51 GMT (envelope-from gonzo@FreeBSD.org) Date: Thu, 5 Jul 2007 13:57:51 GMT Message-Id: <200707051357.l65Dvp18075538@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to gonzo@FreeBSD.org using -f From: Oleksandr Tymoshenko To: Perforce Change Reviews Cc: Subject: PERFORCE change 122954 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 05 Jul 2007 13:57:52 -0000 http://perforce.freebsd.org/chv.cgi?CH=122954 Change 122954 by gonzo@gonzo_jeeves on 2007/07/05 13:57:25 o Show fields and flags of cp0 status and cause registers on panic. Affected files ... .. //depot/projects/mips2/src/sys/mips/mips/trap.c#22 edit Differences ... ==== //depot/projects/mips2/src/sys/mips/mips/trap.c#22 (text+ko) ==== @@ -129,6 +129,26 @@ trapsignal(td, &ksi); } +/* + * Helper routines to explain content of fields/flags for cp0 registers + */ +#define PRINT_VAL(val, bit, size, name) do { \ + if(coma) \ + printf(","); \ + printf("%s=%x", name, \ + (((val) >> (bit)) & ((1 << ((size)+1))-1))); \ + coma = 1; \ + } while(0) + +#define PRINT_FLAG(val, bit, name) do { \ + if(((val) >> (bit)) & 1) { \ + if(coma) \ + printf(","); \ + printf("%s", name); \ + coma = 1; \ + } \ + } while(0) + void trap(struct trapframe * tf, u_int cause, void *badvaddr) { @@ -138,6 +158,7 @@ struct trap_identifier *tid; int code, kernelmode; int ftype, error; + u_int coma = 0, status; platform_trap_enter(); @@ -303,8 +324,40 @@ printf("program counter = %#x\n", tf->tf_regs[TF_EPC]); printf("return address = %#x\n", tf->tf_regs[TF_RA]); printf("bad virtual address = %p\n", badvaddr); - printf("cause = %#x\n", cause); - printf("status = %#x\n", tf->tf_regs[TF_SR]); + + printf("cause = %#x <", cause); + PRINT_VAL(cause, 2, 5, "ExcCode"); + PRINT_VAL(cause, 8, 2, "IPSW"); + PRINT_VAL(cause, 10, 2, "IPHW"); + PRINT_FLAG(cause, 22, "WP"); + PRINT_FLAG(cause, 23, "IV"); + PRINT_VAL(cause, 28, 2, "CE"); + PRINT_FLAG(cause, 31, "BD"); + printf(">\n"); + + coma = 0; + status = tf->tf_regs[TF_SR]; + printf("status = %#x <", status); + PRINT_VAL(status, 28, 4, "CU"); + PRINT_FLAG(status, 27, "RP"); + PRINT_FLAG(status, 26, "FR"); + PRINT_FLAG(status, 25, "RE"); + PRINT_FLAG(status, 24, "MX"); + PRINT_FLAG(status, 23, "PX"); + PRINT_FLAG(status, 22, "BEV"); + PRINT_FLAG(status, 21, "TS"); + PRINT_FLAG(status, 20, "SR"); + PRINT_FLAG(status, 19, "NMI"); + PRINT_VAL(status, 8, 8, "IM"); + PRINT_FLAG(status, 7, "KX"); + PRINT_FLAG(status, 6, "SX"); + PRINT_FLAG(status, 5, "UX"); + PRINT_FLAG(status, 4, "UM"); + PRINT_FLAG(status, 3, "RO"); + PRINT_FLAG(status, 2, "ERL"); + PRINT_FLAG(status, 1, "EXL"); + PRINT_FLAG(status, 0, "IE"); + printf(">\n"); printf("current thread = %p\n", curthread); if (curthread != NULL) { printf("current process = "); @@ -339,6 +392,9 @@ platform_trap_exit(); } +#undef PRINT_FLAG +#undef PRINT_VAL + int check_address(void *addr) {