Blame src/papi_debug.h

Packit Service a1973e
/****************************/
Packit Service a1973e
/* THIS IS OPEN SOURCE CODE */
Packit Service a1973e
/****************************/
Packit Service a1973e
/** 
Packit Service a1973e
* @file    papi_debug.h
Packit Service a1973e
* @author  Philip Mucci
Packit Service a1973e
*          mucci@cs.utk.edu
Packit Service a1973e
* @author  Dan Terpstra
Packit Service a1973e
*          terpstra.utk.edu
Packit Service a1973e
* @author  Kevin London
Packit Service a1973e
*	       london@cs.utk.edu
Packit Service a1973e
* @author  Haihang You
Packit Service a1973e
*          you@cs.utk.edu
Packit Service a1973e
*/
Packit Service a1973e
Packit Service a1973e
#ifndef _PAPI_DEBUG_H
Packit Service a1973e
#define _PAPI_DEBUG_H
Packit Service a1973e
Packit Service a1973e
#ifdef NO_VARARG_MACRO
Packit Service a1973e
#include <stdarg.h>
Packit Service a1973e
#endif
Packit Service a1973e
Packit Service a1973e
#include <stdio.h>
Packit Service a1973e
Packit Service a1973e
/* Debug Levels */
Packit Service a1973e
Packit Service a1973e
#define DEBUG_SUBSTRATE         0x002
Packit Service a1973e
#define DEBUG_API               0x004
Packit Service a1973e
#define DEBUG_INTERNAL          0x008
Packit Service a1973e
#define DEBUG_THREADS           0x010
Packit Service a1973e
#define DEBUG_MULTIPLEX         0x020
Packit Service a1973e
#define DEBUG_OVERFLOW          0x040
Packit Service a1973e
#define DEBUG_PROFILE           0x080
Packit Service a1973e
#define DEBUG_MEMORY            0x100
Packit Service a1973e
#define DEBUG_LEAK              0x200
Packit Service a1973e
#define DEBUG_ALL               (DEBUG_SUBSTRATE|DEBUG_API|DEBUG_INTERNAL|DEBUG_THREADS|DEBUG_MULTIPLEX|DEBUG_OVERFLOW|DEBUG_PROFILE|DEBUG_MEMORY|DEBUG_LEAK)
Packit Service a1973e
Packit Service a1973e
/* Please get rid of the DBG macro from your code */
Packit Service a1973e
Packit Service a1973e
extern int _papi_hwi_debug;
Packit Service a1973e
extern unsigned long int ( *_papi_hwi_thread_id_fn ) ( void );
Packit Service a1973e
Packit Service a1973e
#ifdef DEBUG
Packit Service a1973e
Packit Service a1973e
#ifdef __GNUC__
Packit Service a1973e
#define FUNC __FUNCTION__
Packit Service a1973e
#elif defined(__func__)
Packit Service a1973e
#define FUNC __func__
Packit Service a1973e
#else
Packit Service a1973e
#define FUNC "?"
Packit Service a1973e
#endif
Packit Service a1973e
Packit Service a1973e
#define DEBUGLABEL(a) if (_papi_hwi_thread_id_fn) fprintf(stderr, "%s:%s:%s:%d:%d:%#lx ",a,__FILE__, FUNC, __LINE__,(int)getpid(),_papi_hwi_thread_id_fn()); else fprintf(stderr, "%s:%s:%s:%d:%d ",a,__FILE__, FUNC, __LINE__, (int)getpid())
Packit Service a1973e
#define ISLEVEL(a) (_papi_hwi_debug&a)
Packit Service a1973e
Packit Service a1973e
#define DEBUGLEVEL(a) ((a&DEBUG_SUBSTRATE)?"SUBSTRATE":(a&DEBUG_API)?"API":(a&DEBUG_INTERNAL)?"INTERNAL":(a&DEBUG_THREADS)?"THREADS":(a&DEBUG_MULTIPLEX)?"MULTIPLEX":(a&DEBUG_OVERFLOW)?"OVERFLOW":(a&DEBUG_PROFILE)?"PROFILE":(a&DEBUG_MEMORY)?"MEMORY":(a&DEBUG_LEAK)?"LEAK":"UNKNOWN")
Packit Service a1973e
Packit Service a1973e
#ifndef NO_VARARG_MACRO		 /* Has variable arg macro support */
Packit Service a1973e
#define PAPIDEBUG(level,format, args...) { if(_papi_hwi_debug&level){DEBUGLABEL(DEBUGLEVEL(level));fprintf(stderr,format, ## args);}}
Packit Service a1973e
Packit Service a1973e
 /* Macros */
Packit Service a1973e
Packit Service a1973e
#define SUBDBG(format, args...) (PAPIDEBUG(DEBUG_SUBSTRATE,format, ## args))
Packit Service a1973e
#define APIDBG(format, args...) (PAPIDEBUG(DEBUG_API,format, ## args))
Packit Service a1973e
#define INTDBG(format, args...) (PAPIDEBUG(DEBUG_INTERNAL,format, ## args))
Packit Service a1973e
#define THRDBG(format, args...) (PAPIDEBUG(DEBUG_THREADS,format, ## args))
Packit Service a1973e
#define MPXDBG(format, args...) (PAPIDEBUG(DEBUG_MULTIPLEX,format, ## args))
Packit Service a1973e
#define OVFDBG(format, args...) (PAPIDEBUG(DEBUG_OVERFLOW,format, ## args))
Packit Service a1973e
#define PRFDBG(format, args...) (PAPIDEBUG(DEBUG_PROFILE,format, ## args))
Packit Service a1973e
#define MEMDBG(format, args...) (PAPIDEBUG(DEBUG_MEMORY,format, ## args))
Packit Service a1973e
#define LEAKDBG(format, args...) (PAPIDEBUG(DEBUG_LEAK,format, ## args))
Packit Service a1973e
#endif
Packit Service a1973e
Packit Service a1973e
#else
Packit Service a1973e
#ifndef NO_VARARG_MACRO		 /* Has variable arg macro support */
Packit Service a1973e
#define SUBDBG(format, args...) { ; }
Packit Service a1973e
#define APIDBG(format, args...) { ; }
Packit Service a1973e
#define INTDBG(format, args...) { ; }
Packit Service a1973e
#define THRDBG(format, args...) { ; }
Packit Service a1973e
#define MPXDBG(format, args...) { ; }
Packit Service a1973e
#define OVFDBG(format, args...) { ; }
Packit Service a1973e
#define PRFDBG(format, args...) { ; }
Packit Service a1973e
#define MEMDBG(format, args...) { ; }
Packit Service a1973e
#define LEAKDBG(format, args...) { ; }
Packit Service a1973e
#define PAPIDEBUG(level, format, args...) { ; }
Packit Service a1973e
#endif
Packit Service a1973e
#endif
Packit Service a1973e
Packit Service a1973e
/*
Packit Service a1973e
 * Debug functions for platforms without vararg macro support
Packit Service a1973e
 */
Packit Service a1973e
Packit Service a1973e
#ifdef NO_VARARG_MACRO
Packit Service a1973e
Packit Service a1973e
static void PAPIDEBUG( int level, char *format, va_list args )
Packit Service a1973e
{
Packit Service a1973e
#ifdef DEBUG
Packit Service a1973e
Packit Service a1973e
	if ( ISLEVEL( level ) ) {
Packit Service a1973e
		vfprintf( stderr, format, args );
Packit Service a1973e
	} else
Packit Service a1973e
#endif
Packit Service a1973e
		return;
Packit Service a1973e
}
Packit Service a1973e
Packit Service a1973e
static void
Packit Service a1973e
_SUBDBG( char *format, ... )
Packit Service a1973e
{
Packit Service a1973e
#ifdef DEBUG
Packit Service a1973e
	va_list args;
Packit Service a1973e
	va_start(args, format);
Packit Service a1973e
	PAPIDEBUG( DEBUG_SUBSTRATE, format, args );
Packit Service a1973e
	va_end(args);
Packit Service a1973e
#endif
Packit Service a1973e
}
Packit Service a1973e
#ifdef DEBUG
Packit Service a1973e
#define SUBDBG do { \
Packit Service a1973e
 if (DEBUG_SUBSTRATE & _papi_hwi_debug) {\
Packit Service a1973e
   DEBUGLABEL( DEBUGLEVEL ( DEBUG_SUBSTRATE ) ); \
Packit Service a1973e
 } \
Packit Service a1973e
} while(0); _SUBDBG
Packit Service a1973e
#else
Packit Service a1973e
#define SUBDBG _SUBDBG
Packit Service a1973e
#endif
Packit Service a1973e
Packit Service a1973e
static void
Packit Service a1973e
_APIDBG( char *format, ... )
Packit Service a1973e
{
Packit Service a1973e
#ifdef DEBUG
Packit Service a1973e
	va_list args;
Packit Service a1973e
	va_start(args, format);
Packit Service a1973e
	PAPIDEBUG( DEBUG_API, format, args );
Packit Service a1973e
	va_end(args);
Packit Service a1973e
#endif
Packit Service a1973e
}
Packit Service a1973e
#ifdef DEBUG
Packit Service a1973e
#define APIDBG do { \
Packit Service a1973e
  if (DEBUG_API&_papi_hwi_debug) {\
Packit Service a1973e
	DEBUGLABEL( DEBUGLEVEL ( DEBUG_API ) ); \
Packit Service a1973e
  } \
Packit Service a1973e
} while(0); _APIDBG
Packit Service a1973e
#else
Packit Service a1973e
#define APIDBG _APIDBG
Packit Service a1973e
#endif
Packit Service a1973e
Packit Service a1973e
static void
Packit Service a1973e
_INTDBG( char *format, ... )
Packit Service a1973e
{
Packit Service a1973e
#ifdef DEBUG
Packit Service a1973e
	va_list args;
Packit Service a1973e
	va_start(args, format);
Packit Service a1973e
	PAPIDEBUG( DEBUG_INTERNAL, format, args );
Packit Service a1973e
	va_end(args);
Packit Service a1973e
#endif
Packit Service a1973e
}
Packit Service a1973e
#ifdef DEBUG
Packit Service a1973e
#define INTDBG do { \
Packit Service a1973e
    if (DEBUG_INTERNAL&_papi_hwi_debug) {\
Packit Service a1973e
	  DEBUGLABEL( DEBUGLEVEL ( DEBUG_INTERNAL ) ); \
Packit Service a1973e
	} \
Packit Service a1973e
} while(0); _INTDBG
Packit Service a1973e
#else
Packit Service a1973e
#define INTDBG _INTDBG
Packit Service a1973e
#endif 
Packit Service a1973e
Packit Service a1973e
static void
Packit Service a1973e
_THRDBG( char *format, ... )
Packit Service a1973e
{
Packit Service a1973e
#ifdef DEBUG
Packit Service a1973e
	va_list args;
Packit Service a1973e
	va_start(args, format);
Packit Service a1973e
	PAPIDEBUG( DEBUG_THREADS, format, args );
Packit Service a1973e
	va_end(args);
Packit Service a1973e
#endif
Packit Service a1973e
}
Packit Service a1973e
#ifdef DEBUG
Packit Service a1973e
#define THRDBG do { \
Packit Service a1973e
  if (DEBUG_THREADS&_papi_hwi_debug) {\
Packit Service a1973e
	DEBUGLABEL( DEBUGLEVEL ( DEBUG_THREADS ) ); \
Packit Service a1973e
  } \
Packit Service a1973e
} while(0); _THRDBG
Packit Service a1973e
#else
Packit Service a1973e
#define THRDBG _THRDBG
Packit Service a1973e
#endif
Packit Service a1973e
Packit Service a1973e
static void
Packit Service a1973e
_MPXDBG( char *format, ... )
Packit Service a1973e
{
Packit Service a1973e
#ifdef DEBUG
Packit Service a1973e
	va_list args;
Packit Service a1973e
	va_start(args, format);
Packit Service a1973e
	PAPIDEBUG( DEBUG_MULTIPLEX, format, args );
Packit Service a1973e
	va_end(args);
Packit Service a1973e
#endif
Packit Service a1973e
}
Packit Service a1973e
#ifdef DEBUG
Packit Service a1973e
#define MPXDBG do { \
Packit Service a1973e
  if (DEBUG_MULTIPLEX&_papi_hwi_debug) {\
Packit Service a1973e
	DEBUGLABEL( DEBUGLEVEL ( DEBUG_MULTIPLEX ) ); \
Packit Service a1973e
  } \
Packit Service a1973e
} while(0); _MPXDBG
Packit Service a1973e
#else
Packit Service a1973e
#define MPXDBG _MPXDBG
Packit Service a1973e
#endif
Packit Service a1973e
Packit Service a1973e
static void
Packit Service a1973e
_OVFDBG( char *format, ... )
Packit Service a1973e
{
Packit Service a1973e
#ifdef DEBUG
Packit Service a1973e
	va_list args;
Packit Service a1973e
	va_start(args, format);
Packit Service a1973e
	PAPIDEBUG( DEBUG_OVERFLOW, format, args );
Packit Service a1973e
	va_end(args);
Packit Service a1973e
#endif
Packit Service a1973e
}
Packit Service a1973e
#ifdef DEBUG
Packit Service a1973e
#define OVFDBG do { \
Packit Service a1973e
  if (DEBUG_OVERFLOW&_papi_hwi_debug) {\
Packit Service a1973e
	DEBUGLABEL( DEBUGLEVEL ( DEBUG_OVERFLOW ) ); \
Packit Service a1973e
  } \
Packit Service a1973e
} while(0); _OVFDBG
Packit Service a1973e
#else
Packit Service a1973e
#define OVFDBG _OVFDBG
Packit Service a1973e
#endif
Packit Service a1973e
Packit Service a1973e
static void
Packit Service a1973e
_PRFDBG( char *format, ... )
Packit Service a1973e
{
Packit Service a1973e
#ifdef DEBUG
Packit Service a1973e
	va_list args;
Packit Service a1973e
	va_start(args, format);
Packit Service a1973e
	PAPIDEBUG( DEBUG_PROFILE, format, args );
Packit Service a1973e
	va_end(args);
Packit Service a1973e
#endif
Packit Service a1973e
}
Packit Service a1973e
#ifdef DEBUG
Packit Service a1973e
#define PRFDBG do { \
Packit Service a1973e
  if (DEBUG_PROFILE&_papi_hwi_debug) {\
Packit Service a1973e
	DEBUGLABEL( DEBUGLEVEL ( DEBUG_PROFILE ) ); \
Packit Service a1973e
  } \
Packit Service a1973e
} while(0); _PRFDBG
Packit Service a1973e
#else
Packit Service a1973e
#define PRFDBG _PRFDBG
Packit Service a1973e
#endif
Packit Service a1973e
Packit Service a1973e
static void
Packit Service a1973e
_MEMDBG( char *format, ... )
Packit Service a1973e
{
Packit Service a1973e
#ifdef DEBUG
Packit Service a1973e
	va_list args;
Packit Service a1973e
	va_start(args, format);
Packit Service a1973e
	PAPIDEBUG( DEBUG_MEMORY, format , args);
Packit Service a1973e
	va_end(args);
Packit Service a1973e
#endif
Packit Service a1973e
}
Packit Service a1973e
#ifdef DEBUG
Packit Service a1973e
#define MEMDBG do { \
Packit Service a1973e
  if (DEBUG_MEMORY&_papi_hwi_debug) {\
Packit Service a1973e
	DEBUGLABEL( DEBUGLEVEL ( DEBUG_MEMORY ) ); \
Packit Service a1973e
  } \
Packit Service a1973e
} while(0); _MEMDBG
Packit Service a1973e
#else
Packit Service a1973e
#define MEMDBG _MEMDBG
Packit Service a1973e
#endif
Packit Service a1973e
Packit Service a1973e
static void
Packit Service a1973e
_LEAKDBG( char *format, ... )
Packit Service a1973e
{
Packit Service a1973e
#ifdef DEBUG
Packit Service a1973e
	va_list args;
Packit Service a1973e
	va_start(args, format);
Packit Service a1973e
	PAPIDEBUG( DEBUG_LEAK, format , args);
Packit Service a1973e
	va_end(args);
Packit Service a1973e
#endif
Packit Service a1973e
}
Packit Service a1973e
#ifdef DEBUG
Packit Service a1973e
#define LEAKDBG do { \
Packit Service a1973e
  if (DEBUG_LEAK&_papi_hwi_debug) {\
Packit Service a1973e
	DEBUGLABEL( DEBUGLEVEL ( DEBUG_LEAK ) ); \
Packit Service a1973e
  } \
Packit Service a1973e
} while(0); _LEAKDBG
Packit Service a1973e
#else
Packit Service a1973e
#define LEAKDBG _LEAKDBG
Packit Service a1973e
#endif
Packit Service a1973e
Packit Service a1973e
/* ifdef NO_VARARG_MACRO */
Packit Service a1973e
#endif
Packit Service a1973e
Packit Service a1973e
#endif /* PAPI_DEBUG_H */