119 lines
3.2 KiB
Groff
119 lines
3.2 KiB
Groff
.\" $NetBSD: KASSERT.9,v 1.13 2011/09/27 00:36:51 jym Exp $
|
|
.\"
|
|
.\" Copyright (c) 2006 Igor Sobrado
|
|
.\" All rights reserved.
|
|
.\"
|
|
.\" Redistribution and use in source and binary forms, with or without
|
|
.\" modification, are permitted provided that the following conditions
|
|
.\" are met:
|
|
.\" 1. Redistributions of source code must retain the above copyright
|
|
.\" notice, this list of conditions and the following disclaimer.
|
|
.\" 2. Redistributions in binary form must reproduce the above copyright
|
|
.\" notice, this list of conditions and the following disclaimer in the
|
|
.\" documentation and/or other materials provided with the distribution.
|
|
.\"
|
|
.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
|
|
.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
|
.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
|
.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
|
|
.\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
|
.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
|
.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
|
.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
|
.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
.\" POSSIBILITY OF SUCH DAMAGE.
|
|
.\"
|
|
.Dd September 27, 2011
|
|
.Dt KASSERT 9
|
|
.Os
|
|
.Sh NAME
|
|
.Nm KASSERT ,
|
|
.Nm KASSERTMSG ,
|
|
.Nm KDASSERT ,
|
|
.Nm KDASSERTMSG
|
|
.Nd kernel expression verification macros
|
|
.Sh SYNOPSIS
|
|
.Ft void
|
|
.Fn KASSERT expression
|
|
.Ft void
|
|
.Fn KASSERTMSG expression format ...
|
|
.Ft void
|
|
.Fn KDASSERT expression
|
|
.Ft void
|
|
.Fn KDASSERTMSG expression format ...
|
|
.Sh DESCRIPTION
|
|
These machine independent assertion-checking macros cause a kernel
|
|
.Xr panic 9
|
|
if the given
|
|
.Ar expression
|
|
evaluates to false.
|
|
Two compile-time
|
|
.Xr options 4
|
|
define the behavior of the checks.
|
|
.Bl -enum -offset 2n
|
|
.It
|
|
The
|
|
.Fn KASSERT
|
|
and
|
|
.Fn KASSERTMSG
|
|
tests are included only in kernels compiled with the
|
|
.Dv DIAGNOSTIC
|
|
configuration option.
|
|
In a kernel that does not have this configuration option,
|
|
the macros are defined to be no-ops.
|
|
.It
|
|
The
|
|
.Fn KDASSERT
|
|
and
|
|
.Fn KDASSERTMSG
|
|
tests are included only in kernels compiled with the
|
|
.Dv DEBUG
|
|
configuration option.
|
|
The
|
|
.Fn KDASSERT
|
|
and
|
|
.Fn KASSERT
|
|
macros are identical except for the controlling option
|
|
.Pf ( Dv DEBUG
|
|
vs
|
|
.Dv DIAGNOSTIC ) .
|
|
Basically,
|
|
.Fn KASSERT
|
|
should be used for light-weight checks and
|
|
.Fn KDASSERT
|
|
should be used for heavier ones.
|
|
.El
|
|
.Pp
|
|
Callers should not rely on the side effects of
|
|
.Ar expression
|
|
because, depending on the kernel compile options mentioned above,
|
|
.Ar expression
|
|
might not be evaluated at all.
|
|
.Pp
|
|
The panic message will display the style of assertion (debugging
|
|
vs. diagnostic), the expression that failed and the filename, and line
|
|
number the failure happened on.
|
|
The
|
|
.Fn KASSERTMSG
|
|
and
|
|
.Fn KDASSERTMSG
|
|
macros append
|
|
to the
|
|
.Xr panic 9
|
|
format string the message specified by
|
|
.Fa format
|
|
and its subsequent arguments, similar to
|
|
.Xr printf 9
|
|
functions.
|
|
.Sh SEE ALSO
|
|
.Xr config 1 ,
|
|
.Xr options 4 ,
|
|
.Xr CTASSERT 9 ,
|
|
.Xr panic 9 ,
|
|
.Xr printf 9
|
|
.Sh AUTHORS
|
|
These macros were written by
|
|
.An Chris G. Demetriou
|
|
.Aq cgd@netbsd.org .
|