Subject: Re: Line & file debugging info for vnode locking.
To: John Kohl <>
From: Bill Sommerfeld <>
List: tech-kern
Date: 08/14/1999 10:29:22
> We can use ANSI string pasting to use a single "const char *" argument
> to include file and function name information (and, with a little bit of
> quoting hair, the line number too):
> #define _quote(x) #x
> #define quote(x) _quote(x)
> 	printf("%s\n", __FILE__ ":" __FUNCTION__ ":" quote(__LINE__));

This reduces runtime overhead at the cost of (potentially significant)
additional text space for character constants (multiple copies of the
__FILE__ string constant would otherwise be consolidated by the
compiler, but this is prevented by string-pasting).

Kernel builds are done with the absolute pathname of the module, and
this adds up..

If we're going to be using GCC extensions like __FUNCTION__, we could
also use another extension like:

struct callsite {
	const char *file, func;
	int line;

#define wrapped_foo(x, y) ({static callsite foo = { __FILE__, __FUNCTION__, __LINE__ }; bar((x),(y), &foo); })

						- Bill