Re: *(int*)0 = 0 & variations

Jeff Garzik (jgarzik@pobox.com)
Tue, 22 Jun 1999 19:33:56 -0400


"Joshua M. Thompson" wrote:
>
> On Tue, 22 Jun 1999, Jeff Garzik wrote:
>
> > > * a central dbg_printk().
> >
> > Ditto. This would be nice too. This will need to be controlled at the
> > module level IMHO, maybe something like:
> >
> > #define MODULE_DEBUG 1
> > #include <linux/debug.h>
> >
> > would enable dprintk.
>
> Except for the per-module part this sounds an awful lot like
> console_loglevel and the various KERN_xxx prefixes for printk()'s.

dprintk should evaluate to printk(KERN_DEBUG ...). Beyond that, what
are you suggesting? Take a look at DPRINTK in drivers/video/{various}.
It does nice stuff like prefix your output with the function name.

A per-module switch is necessary to have fine grained control over
whether or not you have tons and tons of debugging text and code
compiled into the module. Feel free to put the switch anywhere you
want. I think it would be cool to do it from make config:

Floppy driver? [y/n/m] yd
( defines CONFIG_FLOPPY, DBG_CONFIG_FLOPPY )

Rather than implementing this DPRINTK() and assert() in every module in
drivers/video/* and elsewhere, it makes sense to move the code into a
common location. With all the pointers de-ref'd in C code and the
kernel in particular, using assert() around that type of code has saved
me lots of debugging time more than once. asserts() are usually cheap
so it doesn't kill you to leave them on during runtime.

Jeff

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/