Subject: Re: where is KASSERT(9) documented?
To: Igor Sobrado <igor@string1.ciencias.uniovi.es>
From: Igor Sobrado <igor@string1.ciencias.uniovi.es>
List: tech-kern
Date: 04/17/2006 22:23:37
In message <20060417172711.B71F93D87@string1.ciencias.uniovi.es>, Igor Sobrado writes:
>
> 1. Is the DIAGNOSTIC configuration option required on a kernel?
> What is the difference in behaviour of these macros when this
> configuration option is not defined? Is the libkern.h header
> file required? To be more precise (from libkern.h):
>
> #ifndef DIAGNOSTIC
[...]
> #endif
>
> It seems that the macro is replaced by a no-op if the kernel
> does not have DIAGNOSTICS and replaced with the right behaviour
> in the other case (in other words, (void)0 if the expression "e"
> is evaluated as true, and a call to __assert if the expression
> is evaluated as false. Am I wrong?
Ok, looking more carefully at this header file (now I am at home
and I have more time to look at this issue) I see that the preprocessor
structure for DEBUG/KDASSERT is the same as the one for DIAGNOSTIC/KASSERT.
In other words, KASSERT will be replaced by (void)0 or nothing if
DIAGNOSTIC is not set (same about KDASSERT and the DEBUG configuration
option) and by the assertion-checking macro if DIAGNOSTIC (KASSERT)
or DEBUG (KDASSERT) options are set in the kernel configuration files.
I have not an easy way to check the behaviour of these macros without
changing the kernel with some K[D]ASSERT macros evaluated to false.
Even worse, I do not have a test machine that can be paniced now...
at least not until I get a Ph.D. in a month or so. Well, even in
this case I will need my laptop for the course on computer networks
at the University until june (I am using ns on that course, I feel
that alumni need to know that nice simulator!).
Now I see that the evaluation of these "?:" conditional expressions
require the [il][max|min] kernel library routines... should I add
these library routines to the same manual page or write another
manual page for them? I feel that if we will document K[D]ASSET
macros, we will need to document these library functions too!
Now the design decision is if we will need to write a second manual
page or following the OpenBSD style and add them to the same
manual page. I prefer not taking this decision as there is people
here with a better knowledge on the NetBSD style.
> 2. Is the INVARIANTS (FreeBSD) configuration option used at all?
I have not found any reference to this configuration option in the
header files and, even worse, in the kernel configuration files.
I think that it is a FreeBSD-ism and means nothing for the macros
as defined in NetBSD. Of course, if I am wrong let me know!
> 3. Are there differences between KASSERT and KDASSERT apart of the
> replacement of the use of the DIAGNOSTIC configuration option
> in the former and the DEBUG configuration option in the later?
I think that I have answered to my own question. Both configuration
options are managed in the same way by the C preprocessor.
> 4. In a private email, Greg Troxel mentioned something about the
> line numbering in the panic string... is the line number provided
> as an argument to this string? Is there something to note about
> the panic string? (e.g., is it optional? does it follow printf(9)
> strictly?)
>
> Thanks a lot to you and Greg for the kindly support on this matter.
> I will do my best to document these kernel macros and provide a high
> quality manual page.
As soon as I have something useful I will post it here for its
evaluation. Once these man pages are accepted I will submit a PR.
Again, thanks a lot for the time you are spending on this matter.
Cheers,
Igor.