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