Module Name: src Committed By: matt Date: Fri Feb 14 18:38:16 UTC 2014
Modified Files: src/sys/arch/mips/mips [matt-nb5-mips64]: mips_softint.c pmap.c pmap_tlb.c vm_machdep.c src/sys/arch/mips/rmi [matt-nb5-mips64]: rmixl_intr.c rmixl_nand_pci.c src/sys/dev/ic [matt-nb5-mips64]: siisata.c src/sys/kern [matt-nb5-mips64]: subr_prf.c src/sys/lib/libkern [matt-nb5-mips64]: __assert.c libkern.h src/sys/sys [matt-nb5-mips64]: cdefs.h systm.h Log Message: Change KASSERTMSG/KDASSERTMSG to use varadic arguments like HEAD. panic -> vpanic, add panic wrapper to vpanic. To generate a diff of this commit: cvs rdiff -u -r1.1.2.8 -r1.1.2.9 src/sys/arch/mips/mips/mips_softint.c cvs rdiff -u -r1.179.16.46 -r1.179.16.47 src/sys/arch/mips/mips/pmap.c cvs rdiff -u -r1.1.2.24 -r1.1.2.25 src/sys/arch/mips/mips/pmap_tlb.c cvs rdiff -u -r1.121.6.1.2.30 -r1.121.6.1.2.31 \ src/sys/arch/mips/mips/vm_machdep.c cvs rdiff -u -r1.1.2.38 -r1.1.2.39 src/sys/arch/mips/rmi/rmixl_intr.c cvs rdiff -u -r1.1.2.3 -r1.1.2.4 src/sys/arch/mips/rmi/rmixl_nand_pci.c cvs rdiff -u -r1.2.14.2 -r1.2.14.3 src/sys/dev/ic/siisata.c cvs rdiff -u -r1.124.4.1.4.1 -r1.124.4.1.4.2 src/sys/kern/subr_prf.c cvs rdiff -u -r1.11 -r1.11.40.1 src/sys/lib/libkern/__assert.c cvs rdiff -u -r1.82.8.4 -r1.82.8.5 src/sys/lib/libkern/libkern.h cvs rdiff -u -r1.69.10.1 -r1.69.10.2 src/sys/sys/cdefs.h cvs rdiff -u -r1.228.4.2.4.3 -r1.228.4.2.4.4 src/sys/sys/systm.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/arch/mips/mips/mips_softint.c diff -u src/sys/arch/mips/mips/mips_softint.c:1.1.2.8 src/sys/arch/mips/mips/mips_softint.c:1.1.2.9 --- src/sys/arch/mips/mips/mips_softint.c:1.1.2.8 Fri Apr 29 08:26:29 2011 +++ src/sys/arch/mips/mips/mips_softint.c Fri Feb 14 18:38:15 2014 @@ -28,7 +28,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: mips_softint.c,v 1.1.2.8 2011/04/29 08:26:29 matt Exp $"); +__KERNEL_RCSID(0, "$NetBSD: mips_softint.c,v 1.1.2.9 2014/02/14 18:38:15 matt Exp $"); #include <sys/param.h> #include <sys/cpu.h> @@ -103,7 +103,7 @@ softint_trigger(uintptr_t si) softint_fast_dispatch(ci->ci_softlwps[SOFTINT_##level], \ IPL_SOFT##level); \ KASSERT(ci->ci_softlwps[SOFTINT_##level]->l_ctxswtch == 0); \ - KASSERTMSG(ci->ci_cpl == IPL_HIGH, ("cpl (%d) != HIGH", ci->ci_cpl)); \ + KASSERTMSG(ci->ci_cpl == IPL_HIGH, "cpl (%d) != HIGH", ci->ci_cpl); \ continue; \ } @@ -117,8 +117,8 @@ softint_process(uint32_t ipending) KASSERT((ipending & ~MIPS_SOFT_INT_MASK) == 0); KASSERT(ci->ci_cpl == IPL_HIGH); KASSERTMSG(ci->ci_mtx_count == 0, - ("%s: cpu%u (%p): ci_mtx_count (%d) != 0", - __func__, cpu_index(ci), ci, ci->ci_mtx_count)); + "%s: cpu%u (%p): ci_mtx_count (%d) != 0", + __func__, cpu_index(ci), ci, ci->ci_mtx_count); if (ipending & MIPS_SOFT_INT_MASK_0) { /* Index: src/sys/arch/mips/mips/pmap.c diff -u src/sys/arch/mips/mips/pmap.c:1.179.16.46 src/sys/arch/mips/mips/pmap.c:1.179.16.47 --- src/sys/arch/mips/mips/pmap.c:1.179.16.46 Sat Aug 4 07:20:31 2012 +++ src/sys/arch/mips/mips/pmap.c Fri Feb 14 18:38:16 2014 @@ -1446,8 +1446,8 @@ pmap_enter(pmap_t pmap, vaddr_t va, padd #endif const bool good_color = PMAP_PAGE_COLOROK_P(pa, va); KASSERTMSG(good_color, - ("%s(%p, %#"PRIxVADDR", %#"PRIxPADDR", %x, %x): color mismatch\n", - __func__, pmap, va, pa, prot, flags)); + "%s(%p, %#"PRIxVADDR", %#"PRIxPADDR", %x, %x): color mismatch\n", + __func__, pmap, va, pa, prot, flags); if (kernel_pmap_p) { PMAP_COUNT(kernel_mappings); if (!good_color) @@ -1673,8 +1673,8 @@ pmap_kenter_pa(vaddr_t va, paddr_t pa, v #endif PMAP_COUNT(kenter_pa); KASSERTMSG(!managed || PMAP_PAGE_COLOROK_P(pa, va), - ("%s(%#"PRIxVADDR", %#"PRIxPADDR", %x): color mismatch\n", - __func__, va, pa, prot)); + "%s(%#"PRIxVADDR", %#"PRIxPADDR", %x): color mismatch\n", + __func__, va, pa, prot); if (!PMAP_PAGE_COLOROK_P(pa, va) && managed) { PMAP_COUNT(kenter_pa_bad); } Index: src/sys/arch/mips/mips/pmap_tlb.c diff -u src/sys/arch/mips/mips/pmap_tlb.c:1.1.2.24 src/sys/arch/mips/mips/pmap_tlb.c:1.1.2.25 --- src/sys/arch/mips/mips/pmap_tlb.c:1.1.2.24 Mon Jul 9 17:23:37 2012 +++ src/sys/arch/mips/mips/pmap_tlb.c Fri Feb 14 18:38:16 2014 @@ -453,8 +453,8 @@ pmap_tlb_shootdown_process(void) #if 0 KASSERT(cpu_intr_p()); KASSERTMSG(ci->ci_cpl >= IPL_SCHED, - ("%s: cpl (%d) < IPL_SCHED (%d)", - __func__, ci->ci_cpl, IPL_SCHED)); + "%s: cpl (%d) < IPL_SCHED (%d)", + __func__, ci->ci_cpl, IPL_SCHED); #endif TLBINFO_LOCK(ti); @@ -862,8 +862,8 @@ pmap_tlb_asid_deactivate(pmap_t pm) const uint32_t cpu_mask = 1 << cpu_index(ci); KASSERT(!cpu_intr_p()); KASSERTMSG(pm->pm_onproc & cpu_mask, - ("%s: pmap %p onproc %#x doesn't include cpu %d (%p)", - __func__, pm, pm->pm_onproc, cpu_index(ci), ci)); + "%s: pmap %p onproc %#x doesn't include cpu %d (%p)", + __func__, pm, pm->pm_onproc, cpu_index(ci), ci); /* * The bits in pm_onproc that belong to this TLB can * be changed while this TLBs lock is not held as long @@ -928,8 +928,8 @@ pmap_tlb_asid_check(void) __asm("mfc0 %0,$%1" : "=r"(tlb_hi) : "n"(MIPS_COP_0_TLB_HI)); uint32_t asid = (tlb_hi & MIPS_TLB_PID) >> MIPS_TLB_PID_SHIFT; KDASSERTMSG(asid == curcpu()->ci_pmap_asid_cur, - ("tlb_hi (%#x) asid (%#x) != current asid (%#x)", - tlb_hi, asid, curcpu()->ci_pmap_asid_cur)); + "tlb_hi (%#x) asid (%#x) != current asid (%#x)", + tlb_hi, asid, curcpu()->ci_pmap_asid_cur); kpreempt_enable(); #endif } Index: src/sys/arch/mips/mips/vm_machdep.c diff -u src/sys/arch/mips/mips/vm_machdep.c:1.121.6.1.2.30 src/sys/arch/mips/mips/vm_machdep.c:1.121.6.1.2.31 --- src/sys/arch/mips/mips/vm_machdep.c:1.121.6.1.2.30 Sat Aug 4 07:20:31 2012 +++ src/sys/arch/mips/mips/vm_machdep.c Fri Feb 14 18:38:16 2014 @@ -263,10 +263,10 @@ cpu_uarea_remap(struct lwp *l) uarea_ok = uarea_ok && (pa + USPACE - 1 <= MIPS_PHYS_MASK); #endif KASSERTMSG(pcb->pcb_context.val[_L_SP] == (intptr_t)l->l_md.md_utf, - ("%s: %s (%#"PRIxREGISTER") != %s (%p)", + "%s: %s (%#"PRIxREGISTER") != %s (%p)", __func__, - "pcb->pcb_context.val[_L_SP]", pcb->pcb_context.val[_L_SP], - "(intptr_t)l->l_md.md_utf", l->l_md.md_utf)); + "pcb->pcb_context.val[_L_SP]", pcb->pcb_context.val[_L_SP], + "(intptr_t)l->l_md.md_utf", l->l_md.md_utf); if (!uarea_ok) { struct pglist pglist; Index: src/sys/arch/mips/rmi/rmixl_intr.c diff -u src/sys/arch/mips/rmi/rmixl_intr.c:1.1.2.38 src/sys/arch/mips/rmi/rmixl_intr.c:1.1.2.39 --- src/sys/arch/mips/rmi/rmixl_intr.c:1.1.2.38 Tue Nov 5 18:43:31 2013 +++ src/sys/arch/mips/rmi/rmixl_intr.c Fri Feb 14 18:38:16 2014 @@ -1615,9 +1615,9 @@ evbmips_iointr(int ipl, vaddr_t pc, uint KASSERT(ipl == iv->iv_ipl); KASSERTMSG(curcpu()->ci_cpl >= ipl, - ("%s: after %s: cpl (%d) < ipl %d", + "%s: after %s: cpl (%d) < ipl %d", __func__, sc->sc_vec_evcnts[vec].ev_name, - ipl, curcpu()->ci_cpl)); + ipl, curcpu()->ci_cpl); } } } Index: src/sys/arch/mips/rmi/rmixl_nand_pci.c diff -u src/sys/arch/mips/rmi/rmixl_nand_pci.c:1.1.2.3 src/sys/arch/mips/rmi/rmixl_nand_pci.c:1.1.2.4 --- src/sys/arch/mips/rmi/rmixl_nand_pci.c:1.1.2.3 Tue Nov 5 18:44:02 2013 +++ src/sys/arch/mips/rmi/rmixl_nand_pci.c Fri Feb 14 18:38:16 2014 @@ -31,7 +31,7 @@ #include <sys/cdefs.h> -__KERNEL_RCSID(1, "$NetBSD: rmixl_nand_pci.c,v 1.1.2.3 2013/11/05 18:44:02 matt Exp $"); +__KERNEL_RCSID(1, "$NetBSD: rmixl_nand_pci.c,v 1.1.2.4 2014/02/14 18:38:16 matt Exp $"); #include <sys/param.h> #include <sys/condvar.h> @@ -355,7 +355,7 @@ xlnand_busy(device_t self) break; } } - KASSERTMSG(i < __arraycount(xlnand_cmdseqs), ("%#x", xlch->xlch_cmds)); + KASSERTMSG(i < __arraycount(xlnand_cmdseqs), "%#x", xlch->xlch_cmds); xlch->xlch_addrs = 0; xlch->xlch_cmds = 0; xlch->xlch_datalen = 0; Index: src/sys/dev/ic/siisata.c diff -u src/sys/dev/ic/siisata.c:1.2.14.2 src/sys/dev/ic/siisata.c:1.2.14.3 --- src/sys/dev/ic/siisata.c:1.2.14.2 Fri Apr 29 08:20:50 2011 +++ src/sys/dev/ic/siisata.c Fri Feb 14 18:38:15 2014 @@ -1,4 +1,4 @@ -/* $NetBSD: siisata.c,v 1.2.14.2 2011/04/29 08:20:50 matt Exp $ */ +/* $NetBSD: siisata.c,v 1.2.14.3 2014/02/14 18:38:15 matt Exp $ */ /* from ahcisata_core.c */ @@ -1194,7 +1194,7 @@ siisata_activate_prb(struct siisata_chan sc = (struct siisata_softc *)schp->ata_channel.ch_atac; KASSERTMSG(((schp->sch_active_slots & __BIT(slot)) == 0), - ("%s: trying to activate active slot %d", SIISATANAME(sc), slot)); + "%s: trying to activate active slot %d", SIISATANAME(sc), slot); SIISATA_PRB_SYNC(sc, schp, slot, BUS_DMASYNC_PREWRITE); /* keep track of what's going on */ @@ -1216,8 +1216,7 @@ siisata_deactivate_prb(struct siisata_ch sc = (struct siisata_softc *)schp->ata_channel.ch_atac; KASSERTMSG(((schp->sch_active_slots & __BIT(slot)) != 0), - ("%s: trying to deactivate inactive slot %d", SIISATANAME(sc), - slot)); + "%s: trying to deactivate inactive slot %d", SIISATANAME(sc), slot); schp->sch_active_slots &= ~__BIT(slot); /* mark free */ SIISATA_PRB_SYNC(sc, schp, slot, BUS_DMASYNC_POSTWRITE); Index: src/sys/kern/subr_prf.c diff -u src/sys/kern/subr_prf.c:1.124.4.1.4.1 src/sys/kern/subr_prf.c:1.124.4.1.4.2 --- src/sys/kern/subr_prf.c:1.124.4.1.4.1 Thu Nov 14 17:34:02 2013 +++ src/sys/kern/subr_prf.c Fri Feb 14 18:38:15 2014 @@ -1,4 +1,4 @@ -/* $NetBSD: subr_prf.c,v 1.124.4.1.4.1 2013/11/14 17:34:02 matt Exp $ */ +/* $NetBSD: subr_prf.c,v 1.124.4.1.4.2 2014/02/14 18:38:15 matt Exp $ */ /*- * Copyright (c) 1986, 1988, 1991, 1993 @@ -37,7 +37,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: subr_prf.c,v 1.124.4.1.4.1 2013/11/14 17:34:02 matt Exp $"); +__KERNEL_RCSID(0, "$NetBSD: subr_prf.c,v 1.124.4.1.4.2 2014/02/14 18:38:15 matt Exp $"); #include "opt_ddb.h" #include "opt_ipkdb.h" @@ -167,14 +167,22 @@ twiddle(void) * call) we avoid trying to sync the disk and just reboot (to avoid * recursive panics). */ - void panic(const char *fmt, ...) { + va_list ap; + + va_start(ap, fmt); + vpanic(fmt, ap); + va_end(ap); +} + +void +vpanic(const char *fmt, va_list ap) +{ CPU_INFO_ITERATOR cii; struct cpu_info *ci, *oci; int bootopt; - va_list ap; /* * Disable preemption. If already panicing on another CPU, sit @@ -211,11 +219,9 @@ panic(const char *fmt, ...) if (msgbufenabled && msgbufp->msg_magic == MSG_MAGIC) panicstart = msgbufp->msg_bufx; - va_start(ap, fmt); printf("panic: "); vprintf(fmt, ap); printf("\n"); - va_end(ap); if (msgbufenabled && msgbufp->msg_magic == MSG_MAGIC) panicend = msgbufp->msg_bufx; Index: src/sys/lib/libkern/__assert.c diff -u src/sys/lib/libkern/__assert.c:1.11 src/sys/lib/libkern/__assert.c:1.11.40.1 --- src/sys/lib/libkern/__assert.c:1.11 Mon Sep 24 14:19:03 2007 +++ src/sys/lib/libkern/__assert.c Fri Feb 14 18:38:15 2014 @@ -1,4 +1,4 @@ -/* $NetBSD: __assert.c,v 1.11 2007/09/24 14:19:03 pooka Exp $ */ +/* $NetBSD: __assert.c,v 1.11.40.1 2014/02/14 18:38:15 matt Exp $ */ /* * Copyright (c) 1996 Christopher G. Demetriou @@ -34,19 +34,22 @@ #include <sys/types.h> #include <sys/systm.h> +#include <machine/stdarg.h> + #ifdef _STANDALONE #include <lib/libkern/libkern.h> #endif void -__kernassert(const char *t, const char *f, int l, const char *e) +__kernassert(const char *fmt, ...) { - + va_list ap; #ifdef _KERNEL if (panicstr != NULL) return; #endif - panic("kernel %sassertion \"%s\" failed: file \"%s\", line %d", - t, e, f, l); + va_start(ap, fmt); + vpanic(fmt, ap); + va_end(ap); } Index: src/sys/lib/libkern/libkern.h diff -u src/sys/lib/libkern/libkern.h:1.82.8.4 src/sys/lib/libkern/libkern.h:1.82.8.5 --- src/sys/lib/libkern/libkern.h:1.82.8.4 Tue Dec 27 19:21:00 2011 +++ src/sys/lib/libkern/libkern.h Fri Feb 14 18:38:15 2014 @@ -1,4 +1,4 @@ -/* $NetBSD: libkern.h,v 1.82.8.4 2011/12/27 19:21:00 matt Exp $ */ +/* $NetBSD: libkern.h,v 1.82.8.5 2014/02/14 18:38:15 matt Exp $ */ /*- * Copyright (c) 1992, 1993 @@ -174,15 +174,18 @@ tolower(int ch) #define __NULL_STMT do { } while (/* CONSTCOND */ 0) +#define _KASSERTSTR "kernel %sassertion \"%s\" failed: file \"%s\", line %d " + + #ifdef NDEBUG /* tradition! */ #define assert(e) ((void)0) #else #ifdef __STDC__ #define assert(e) (__predict_true((e)) ? (void)0 : \ - __kernassert("", __FILE__, __LINE__, #e)) + __kernassert(_KASSERTSTR, __FILE__, __LINE__, #e)) #else #define assert(e) (__predict_true((e)) ? (void)0 : \ - __kernassert("", __FILE__, __LINE__, "e")) + __kernassert(_KASSERTSTR, __FILE__, __LINE__, "e")) #endif #endif @@ -197,46 +200,46 @@ tolower(int ch) #ifndef DIAGNOSTIC #define _DIAGASSERT(a) (void)0 #ifdef lint -#define KASSERTMSG(e, msg) /* NOTHING */ +#define KASSERTMSG(e, msg, ...) /* NOTHING */ #define KASSERT(e) /* NOTHING */ #else /* !lint */ -#define KASSERTMSG(e, msg) ((void)0) +#define KASSERTMSG(e, msg, ...) ((void)0) #define KASSERT(e) ((void)0) #endif /* !lint */ #else /* DIAGNOSTIC */ #define _DIAGASSERT(a) assert(a) -#define KASSERTMSG(e, msg) do { \ - if (__predict_false(!(e))) \ - panic msg; \ - } while (/*CONSTCOND*/ 0) +#define KASSERTMSG(e, msg, ...) \ + (__predict_true((e)) ? (void)0 \ + : __kernassert(_KASSERTSTR msg, "diagnostic ", #e, \ + __FILE__, __LINE__, ## __VA_ARGS__ )) #ifdef __STDC__ #define KASSERT(e) (__predict_true((e)) ? (void)0 : \ - __kernassert("diagnostic ", __FILE__, __LINE__, #e)) + __kernassert(_KASSERTSTR, "diagnostic ", __FILE__, __LINE__, #e)) #else #define KASSERT(e) (__predict_true((e)) ? (void)0 : \ - __kernassert("diagnostic ", __FILE__, __LINE__,"e")) + __kernassert(_KASSERTSTR, "diagnostic ", __FILE__, __LINE__,"e")) #endif #endif #ifndef DEBUG #ifdef lint -#define KDASSERTMSG(e, msg) /* NOTHING */ +#define KDASSERTMSG(e, msg, ...) /* NOTHING */ #define KDASSERT(e) /* NOTHING */ #else /* lint */ -#define KDASSERTMSG(e, msg) ((void)0) +#define KDASSERTMSG(e, msg, ...) ((void)0) #define KDASSERT(e) ((void)0) #endif /* lint */ #else -#define KDASSERTMSG(e, msg) do { \ - if (__predict_false(!(e))) \ - panic msg; \ - } while (/*CONSTCOND*/ 0) +#define KDASSERTMSG(e, msg, ...) \ + (__predict_true((e)) ? (void)0 \ + : __kernassert(_KASSERTSTR msg, "debuggin ", #e, \ + __FILE__, __LINE__, ## __VA_ARGS__ )) #ifdef __STDC__ #define KDASSERT(e) (__predict_true((e)) ? (void)0 : \ - __kernassert("debugging ", __FILE__, __LINE__, #e)) + __kernassert(_KASSERTSTR, "debugging ", __FILE__, __LINE__, #e)) #else #define KDASSERT(e) (__predict_true((e)) ? (void)0 : \ - __kernassert("debugging ", __FILE__, __LINE__, "e")) + __kernassert(_KASSERTSTR, "debugging ", __FILE__, __LINE__, "e")) #endif #endif /* @@ -308,7 +311,7 @@ int ffs __P((int)); #define ffs(x) __builtin_ffs(x) #endif -void __kernassert __P((const char *, const char *, int, const char *)); +void __kernassert (const char *, ...); unsigned int bcdtobin __P((unsigned int)); unsigned int Index: src/sys/sys/cdefs.h diff -u src/sys/sys/cdefs.h:1.69.10.1 src/sys/sys/cdefs.h:1.69.10.2 --- src/sys/sys/cdefs.h:1.69.10.1 Fri Apr 29 08:10:38 2011 +++ src/sys/sys/cdefs.h Fri Feb 14 18:38:15 2014 @@ -1,4 +1,4 @@ -/* $NetBSD: cdefs.h,v 1.69.10.1 2011/04/29 08:10:38 matt Exp $ */ +/* $NetBSD: cdefs.h,v 1.69.10.2 2014/02/14 18:38:15 matt Exp $ */ /* * Copyright (c) 1991, 1993 @@ -220,6 +220,27 @@ #define __used __unused #endif +/* + * __diagused: Note that item is used in diagnostic code, but may be + * unused in non-diagnostic code. + */ +#if (defined(_KERNEL) && defined(DIAGNOSTIC)) \ + || (!defined(_KERNEL) && !defined(NDEBUG)) +#define __diagused /* empty */ +#else +#define __diagused __unused +#endif + +/* + * __debugused: Note that item is used in debug code, but may be + * unused in non-debug code. + */ +#if defined(DEBUG) +#define __debugused /* empty */ +#else +#define __debugused __unused +#endif + #if __GNUC_PREREQ__(2, 7) #define __packed __attribute__((__packed__)) #define __aligned(x) __attribute__((__aligned__(x))) @@ -408,4 +429,6 @@ #define __SHIFTIN(__x, __mask) ((__x) * __LOWEST_SET_BIT(__mask)) #define __SHIFTOUT_MASK(__mask) __SHIFTOUT((__mask), (__mask)) +#define __USE(a) ((void)(a)) + #endif /* !_SYS_CDEFS_H_ */ Index: src/sys/sys/systm.h diff -u src/sys/sys/systm.h:1.228.4.2.4.3 src/sys/sys/systm.h:1.228.4.2.4.4 --- src/sys/sys/systm.h:1.228.4.2.4.3 Thu Nov 14 17:34:02 2013 +++ src/sys/sys/systm.h Fri Feb 14 18:38:15 2014 @@ -1,4 +1,4 @@ -/* $NetBSD: systm.h,v 1.228.4.2.4.3 2013/11/14 17:34:02 matt Exp $ */ +/* $NetBSD: systm.h,v 1.228.4.2.4.4 2014/02/14 18:38:15 matt Exp $ */ /*- * Copyright (c) 1982, 1988, 1991, 1993 @@ -236,6 +236,7 @@ void twiddle(void); void panic(const char *, ...) __dead __attribute__((__format__(__printf__,1,2))); +void vpanic(const char *, _BSD_VA_LIST_); void uprintf(const char *, ...) __attribute__((__format__(__printf__,1,2))); void uprintf_locked(const char *, ...)