Subject: Re: kernel panic messages
To: None <email@example.com>
From: M. Warner Losh <firstname.lastname@example.org>
Date: 05/04/2003 06:35:17
In message: <email@example.com>
"Martin J. Laubach" <firstname.lastname@example.org> 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:
#define panic(...) _panic("", 0, __VA_ARGS__)
#define panic(...) _panic(__FILE__, __LINE__, __VA_ARGS__)
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 :-)