Subject: Re: DPRINTF in ?
To: None <tech-kern@netbsd.org>
From: Iain Hibbert <plunky@rya-online.net>
List: tech-kern
Date: 03/23/2007 10:52:13
  This message is in MIME format.  The first part should be readable text,
  while the remaining parts are likely unreadable without MIME-aware tools.

--0-1295668080-1174611274=:29025
Content-Type: TEXT/PLAIN; CHARSET=US-ASCII
Content-ID: <Pine.NEB.4.64.0703230929003.10985@localhost.>

On Fri, 16 Mar 2007, Iain Hibbert wrote:

>    I thought a while ago that it would be nice to standardize DPRINTF and
> DPRINTFN, and now that we have a <sys/debug.h> I've been pondering how we
> could integrate them, and make it easier to generate debug output. These
> are my thoughts so far:

Ok, I've been looking into this in more depth to see what works, and there
seem to be several possible directions:

1. add 'debug ??' statements as I originally planned
	this looks complex to implement, though it could represent a
	natural extension to the config(5) API

2. integrate with "options DEBUG"
	this is not bad, but it requires making 'options DEBUG' a
	magic option, in that config(1) takes note of it.
        I'm not sure if I like that yet, and its also complex..

and for both of these, there is some potential confusion about choosing an
attribute to debug against. Then I noticed DEBUGLIST, so:

3. integrate with "makeoptions DEBUGLIST="
	is what I was fiddling with last night, and something can be made
	very easily from a little make magic and a shell script..

I like this last because although maybe "per file" is overly fine grained,
its simple and doesn't break anything. modules can be upgraded to the new
API at their own pace, and the control mechanism can be upgraded later if
need be, without any more source changes.

I've attached a preliminary patch that seems to work ok, any comments?

iain

- if a mask is being used instead of levels, then DPRINTFN should go?
- more bit definitions?
- sysctl helper?
--0-1295668080-1174611274=:29025
Content-Type: TEXT/PLAIN; charset=US-ASCII; name=diff
Content-Transfer-Encoding: BASE64
Content-ID: <Pine.NEB.4.64.0703231052130.1692@localhost.>
Content-Description: standard DPRINTF
Content-Disposition: attachment; filename=diff

LS0tIC91c3Ivc3JjL3N5cy9jb25mL01ha2VmaWxlLmtlcm4uaW5jCTIwMDct
MDEtMjcgMjM6Mzc6NDIuMDAwMDAwMDAwICswMDAwDQorKysgc3lzL2NvbmYv
TWFrZWZpbGUua2Vybi5pbmMJMjAwN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