Debug support

Luke Kenneth Casson Leighton lkcl at switchboard.net
Mon Nov 23 13:49:14 GMT 1998


richard,

hm, thinking of debug levels, how about having a stack system which could
potentially be used for profiling, too:

void some_fn(...)
{
	DEBUG_PUSH("some_fn");

	....
	....

	DEBUG(4,("hello");

	DEBUG_POP();
}

DEBUG(4,"calling some_fn()");
some_fn();

would generate:

time date "calling some fn()"
time date "some_fn" - "hello"

then you could define some specific stuff like DEBUG_PUSH(DEBUG_MEM);
where #define DEBUG_MEM "memory allocation"

and then filter by this.

if you wanted to do profiling, you have a list/other-storage-method which
is sorted by the DEBUG_PUSH() argument, and it accumulates by a timer
until the next DEBUG_POP() call.


On Sun, 22 Nov 1998, Richard Sharpe wrote:

> Hi folks,
> 
> for the multithreaded SMB server I am writing, I have adopted a slightly
> different approach than Samba, but have copied ideas liberally from Samba.
> I trust that presents no problems.
> 
> My approach is that I will have a debug level and several modules, for
> example:
> 
>    DEBUG_MAIN
>    DEBUG_MEM
>    DEBUG_THREAD
>    DEBUG_RFC1001
>    DEBUG_NETBEUI
>    DEBUG_SMB
> 
> and each debug statement nominates which module it relates to.
> 
> After I get my command line parsing code done, I will then be able to
> specify which module I am interested in seeing the DEBUG statements from.
> 
> So, if I only want to see the debug statements from memory management, I
> simply specify on the command line:
> 
>    -dMEM:4
> 
> This has already allowed me to simply see that I have quite a lot of memory
> leaks (in one test run, 9000 allocates versus 3000 frees).
> 
> This approach allows me to concentrate on one area rather than seeing heaps
> of debugging statements from all over the code.
> 
> 
> Regards
> -------
> Richard Sharpe, sharpe at ns.aus.com, NIC-Handle:RJS96
> NS Computer Software and Services P/L, 
> Ph: +61-8-8281-0063, FAX: +61-8-8250-2080, 
> Samba, Linux, Apache, Digital UNIX, AIX, Netscape, Stronghold, C, ...
> 

<a href="mailto:lkcl at samba.anu.edu.au" > Luke Kenneth Casson Leighton  </a>
<a href="http://mailhost.cb1.com/~lkcl"> Samba and Network Development </a>
<a href="http://www.samba.co.uk"       > Samba and Network Consultancy </a>



More information about the samba-technical mailing list