Subject: diagnostic routines
To: None <tech-kern@netbsd.org>
From: Allen Briggs <briggs@netbsd.org>
List: tech-kern
Date: 11/24/2004 10:11:28
Greetings folks,

I've found myself writing various kinds of diagnostic printing
routines over the years.  They generally fall into a couple of
categories, and I re-invent these small wheels over and over
again.  Each time I write one of these routines, I think that
maybe I should put them in a library or something.

So I'm asking...  Does anyone have opinions on adding some
debug print routines to libkern?

I'm thinking something like:

sys/sys/debug_print.h:

#ifdef DEBUG
void	debug_dump_mem(void *mem, int bwidth, int len, const char *fmt, ...);
void	debug_dump_mbuf(struct mbuf *m, const char *fmt, ...);
...
#else
static inline void
debug_dump_mem(void *mem, int bwidth, int len, const char *fmt, ...)
{
}

static inline void
debug_dump_mbuf(struct mbuf *m, const char *fmt, ...)
{
}
...
#endif

And then corresponding functions in libkern to actually dump the
memory or mbuf (or whatever) that would be pulled in only if
DEBUG is defined.

The intent for drivers or whatever who want to use these routines
is that they would only really call the functions in cases where
DEBUG is defined and some specific debugging is enabled.

Thoughts?

-allen

-- 
                  Use NetBSD!  http://www.netbsd.org/