Subject: Re: kernel panic messages
To: None <mjl+usenet-2003-04@emsi.priv.at>
From: M. Warner Losh <imp@bsdimp.com>
List: tech-kern
Date: 05/04/2003 06:35:17
In message: <slrnbb9d4t.73u.mjl+usenet-2003-04@cactus.emsi.priv.at>
            "Martin J. Laubach" <mjl+usenet-2003-04@emsi.priv.at> writes:
: | > how about changing the panic signature to include __FILE__ and __LINE__ just
: | > before the const char * fmt?
: |  
: |  Doubles or tripples the number of strings. If all we need to do is add a
: |  number to the existing string, let's just do that.
: 
:   For implementing, I see four possibilities
: 
:    (a) touch each panic() call to included __FILE__ and __LINE__, 
:        change the panic() signature to take two more arguments.
: 
:    (b) werap it in a macro that does add magically __FILE__ and __LINE__. 
:        gcc can do varargs macros IIRC but I'm not sure we want to
:        use them.

There's a standard way to do this that doesn't depend on gccisms.
That's iso-99 not iso-89, however.

#define panic(...) _panic(__FILE__, __LINE__, __VA_ARGS__);

would do the trick.  However, at least with the FreeBSD kernel, this
increased the size of the kernel quite a bit, so I had to add a 'small
kernel' option to not include them:

#ifdef SMALL
#define panic(...) _panic("", 0, __VA_ARGS__)
#else
#define panic(...) _panic(__FILE__, __LINE__, __VA_ARGS__)
#endif

for whatever marker of 'SMALL' you want.  The only issue I'm aware of
with __VA_ARGS__ is that it is a 'C' only thing at the moment and any
C++ code in the kernel can't use it.  Since there's no C++ code in the
kernel, even this should be OK :-)

Warner