From owner-freebsd-current@FreeBSD.ORG Sat Jan 17 05:26:43 2004 Return-Path: Delivered-To: freebsd-current@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id BE41016A4CE for ; Sat, 17 Jan 2004 05:26:43 -0800 (PST) Received: from critter.freebsd.dk (critter.freebsd.dk [212.242.86.163]) by mx1.FreeBSD.org (Postfix) with ESMTP id C4EA243D5F for ; Sat, 17 Jan 2004 05:26:41 -0800 (PST) (envelope-from phk@phk.freebsd.dk) Received: from critter.freebsd.dk (localhost [127.0.0.1]) by critter.freebsd.dk (8.12.10/8.12.10) with ESMTP id i0HDQeCf074633 for ; Sat, 17 Jan 2004 14:26:40 +0100 (CET) (envelope-from phk@phk.freebsd.dk) To: current@freebsd.org From: Poul-Henning Kamp Date: Sat, 17 Jan 2004 14:26:40 +0100 Message-ID: <74632.1074346000@critter.freebsd.dk> Subject: Review: add lineno+source file info to panic output X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 17 Jan 2004 13:26:43 -0000 This patch adds sourcefile and linenumber to panics output: db> panic panic: from debugger >>> at line 450 in file ../../../ddb/db_command.c cpuid = 0; I'm not 100% sure about the assembler bits. Poul-Henning Index: alpha/alpha/support.s =================================================================== RCS file: /home/ncvs/src/sys/alpha/alpha/support.s,v retrieving revision 1.15 diff -u -r1.15 support.s --- alpha/alpha/support.s 24 Jul 2003 07:49:45 -0000 1.15 +++ alpha/alpha/support.s 17 Jan 2004 13:21:33 -0000 @@ -680,8 +680,10 @@ longjmp_botch: lda a0, longjmp_botchmsg - mov ra, a1 - CALL(panic) + mov 0, a1 + mov 0, a2 + mov ra, a3 + CALL(__panic) call_pal PAL_bugchk .data Index: i386/i386/swtch.s =================================================================== RCS file: /home/ncvs/src/sys/i386/i386/swtch.s,v retrieving revision 1.143 diff -u -r1.143 swtch.s --- i386/i386/swtch.s 30 Sep 2003 08:11:35 -0000 1.143 +++ i386/i386/swtch.s 17 Jan 2004 13:21:33 -0000 @@ -303,20 +303,26 @@ #ifdef INVARIANTS badsw1: pushal + pushl $0 + pushl $0 pushl $sw0_1 - call panic + call __panic sw0_1: .asciz "cpu_throw: no newthread supplied" badsw2: pushal + pushl $0 + pushl $0 pushl $sw0_2 - call panic + call __panic sw0_2: .asciz "cpu_switch: no curthread supplied" badsw3: pushal + pushl $0 + pushl $0 pushl $sw0_3 - call panic + call __panic sw0_3: .asciz "cpu_switch: no newthread supplied" #endif Index: kern/kern_shutdown.c =================================================================== RCS file: /home/ncvs/src/sys/kern/kern_shutdown.c,v retrieving revision 1.146 diff -u -r1.146 kern_shutdown.c --- kern/kern_shutdown.c 16 Aug 2003 16:57:57 -0000 1.146 +++ kern/kern_shutdown.c 17 Jan 2004 13:23:10 -0000 @@ -476,7 +476,7 @@ * MPSAFE */ void -panic(const char *fmt, ...) +__panic(const char *file, int line, const char *fmt, ...) { struct thread *td = curthread; int bootopt, newpanic; @@ -510,11 +510,11 @@ if (newpanic) { (void)vsnprintf(buf, sizeof(buf), fmt, ap); panicstr = buf; - printf("panic: %s\n", buf); + printf("panic: %s\nat line %d in file %s\n", buf, line, file); } else { printf("panic: "); vprintf(fmt, ap); - printf("\n"); + printf("\nat line %d in file %s", line, file); } va_end(ap); #ifdef SMP Index: sys/systm.h =================================================================== RCS file: /home/ncvs/src/sys/sys/systm.h,v retrieving revision 1.201 diff -u -r1.201 systm.h --- sys/systm.h 26 Dec 2003 05:54:35 -0000 1.201 +++ sys/systm.h 17 Jan 2004 13:21:33 -0000 @@ -136,10 +136,12 @@ void *phashinit(int count, struct malloc_type *type, u_long *nentries); #ifdef RESTARTABLE_PANICS -void panic(const char *, ...) __printflike(1, 2); +void __panic(const char *file, int line, const char *, ...) __printflike(3, 4); #else -void panic(const char *, ...) __dead2 __printflike(1, 2); +void __panic(const char *file, int line, const char *, ...) __dead2 __printflike(3, 4); #endif + +#define panic(...) __panic(__FILE__, __LINE__, __VA_ARGS__) void backtrace(void); void cpu_boot(int); -- Poul-Henning Kamp | UNIX since Zilog Zeus 3.20 phk@FreeBSD.ORG | TCP/IP since RFC 956 FreeBSD committer | BSD since 4.3-tahoe Never attribute to malice what can adequately be explained by incompetence.