This example shows forwarding debug information through a chain of routines.
void ReportFunction( int sum DBG_PASS ) { printf( "%s(%d):started this whole mess\n" DBG_RELAY ); } void TrackingFunction( int a, int b DBG_PASS ) { ReportFunction( a+b, DBG_RELAY ); } void CallTrack( void ) { TrackingFunction( 1, 2 DBG_SRC ); }
In this example, the debug information is passed to the logging system. This allows logging to blame the user application for allocations, releases, locks, etc...
void MyAlloc( int size DBG_PASS ) { _lprintf( DBG_RELAY )( ": alloc %d\n", size ); } void g( void ) { lprintf( "Will Allocate %d\n", 32 ); MyAlloc( 32 DBG_SRC ); }
This example uses the void argument macros
void SimpleFunction( DBG_VOIDPASS ) { // this function usually has (void) parameters. } void f( void ) { SimpleFunction( DBG_VOIDSRC ); }