PAPI
7.1.0.0
Loading...
Searching...
No Matches
papi_debug.h
Go to the documentation of this file.
1
/****************************/
2
/* THIS IS OPEN SOURCE CODE */
3
/****************************/
16
#ifndef _PAPI_DEBUG_H
17
#define _PAPI_DEBUG_H
18
19
#ifdef NO_VARARG_MACRO
20
#include <stdarg.h>
21
#endif
22
23
#include <stdio.h>
24
25
/* Debug Levels */
26
27
#define DEBUG_SUBSTRATE 0x002
28
#define DEBUG_API 0x004
29
#define DEBUG_INTERNAL 0x008
30
#define DEBUG_THREADS 0x010
31
#define DEBUG_MULTIPLEX 0x020
32
#define DEBUG_OVERFLOW 0x040
33
#define DEBUG_PROFILE 0x080
34
#define DEBUG_MEMORY 0x100
35
#define DEBUG_LEAK 0x200
36
#define DEBUG_HIGHLEVEL 0x400
37
#define DEBUG_ALL (DEBUG_SUBSTRATE|DEBUG_API|DEBUG_INTERNAL|DEBUG_THREADS|DEBUG_MULTIPLEX|DEBUG_OVERFLOW|DEBUG_PROFILE|DEBUG_MEMORY|DEBUG_LEAK|DEBUG_HIGHLEVEL)
38
39
/* Please get rid of the DBG macro from your code */
40
41
extern
int
_papi_hwi_debug
;
42
extern
unsigned
long
int
( *
_papi_hwi_thread_id_fn
) ( void );
43
44
#ifdef DEBUG
45
46
#ifdef __GNUC__
47
#define FUNC __FUNCTION__
48
#elif defined(__func__)
49
#define FUNC __func__
50
#else
51
#define FUNC "?"
52
#endif
53
54
#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())
55
#define ISLEVEL(a) (_papi_hwi_debug&a)
56
57
#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":(a&DEBUG_HIGHLEVEL)?"HIGHLEVEL":"UNKNOWN")
58
59
#ifndef NO_VARARG_MACRO
/* Has variable arg macro support */
60
#define PAPIDEBUG(level,format, args...) { if(_papi_hwi_debug&level){DEBUGLABEL(DEBUGLEVEL(level));fprintf(stderr,format, ## args);}}
61
62
/* Macros */
63
64
#define SUBDBG(format, args...) (PAPIDEBUG(DEBUG_SUBSTRATE,format, ## args))
65
#define APIDBG(format, args...) (PAPIDEBUG(DEBUG_API,format, ## args))
66
#define INTDBG(format, args...) (PAPIDEBUG(DEBUG_INTERNAL,format, ## args))
67
#define THRDBG(format, args...) (PAPIDEBUG(DEBUG_THREADS,format, ## args))
68
#define MPXDBG(format, args...) (PAPIDEBUG(DEBUG_MULTIPLEX,format, ## args))
69
#define OVFDBG(format, args...) (PAPIDEBUG(DEBUG_OVERFLOW,format, ## args))
70
#define PRFDBG(format, args...) (PAPIDEBUG(DEBUG_PROFILE,format, ## args))
71
#define MEMDBG(format, args...) (PAPIDEBUG(DEBUG_MEMORY,format, ## args))
72
#define LEAKDBG(format, args...) (PAPIDEBUG(DEBUG_LEAK,format, ## args))
73
#define HLDBG(format, args...) (PAPIDEBUG(DEBUG_HIGHLEVEL,format, ## args))
74
#endif
75
76
#else
77
#ifndef NO_VARARG_MACRO
/* Has variable arg macro support */
78
#define SUBDBG(format, args...) { ; }
79
#define APIDBG(format, args...) { ; }
80
#define INTDBG(format, args...) { ; }
81
#define THRDBG(format, args...) { ; }
82
#define MPXDBG(format, args...) { ; }
83
#define OVFDBG(format, args...) { ; }
84
#define PRFDBG(format, args...) { ; }
85
#define MEMDBG(format, args...) { ; }
86
#define LEAKDBG(format, args...) { ; }
87
#define HLDBG(format, args...) { ; }
88
#define PAPIDEBUG(level, format, args...) { ; }
89
#endif
90
#endif
91
92
/*
93
* Debug functions for platforms without vararg macro support
94
*/
95
96
#ifdef NO_VARARG_MACRO
97
98
static
void
PAPIDEBUG
(
int
level,
char
*format,
va_list
args )
99
{
100
#ifdef DEBUG
101
102
if
(
ISLEVEL
( level ) ) {
103
vfprintf(
stderr
, format, args );
104
}
else
105
#endif
106
return
;
107
}
108
109
static
void
110
_SUBDBG(
char
*format, ... )
111
{
112
#ifdef DEBUG
113
va_list
args;
114
va_start
(args, format);
115
PAPIDEBUG
(
DEBUG_SUBSTRATE
, format, args );
116
va_end
(args);
117
#endif
118
}
119
#ifdef DEBUG
120
#define SUBDBG do { \
121
if (DEBUG_SUBSTRATE & _papi_hwi_debug) {\
122
DEBUGLABEL( DEBUGLEVEL ( DEBUG_SUBSTRATE ) ); \
123
} \
124
} while(0); _SUBDBG
125
#else
126
#define SUBDBG _SUBDBG
127
#endif
128
129
static
void
130
_APIDBG(
char
*format, ... )
131
{
132
#ifdef DEBUG
133
va_list
args;
134
va_start
(args, format);
135
PAPIDEBUG
(
DEBUG_API
, format, args );
136
va_end
(args);
137
#endif
138
}
139
#ifdef DEBUG
140
#define APIDBG do { \
141
if (DEBUG_API&_papi_hwi_debug) {\
142
DEBUGLABEL( DEBUGLEVEL ( DEBUG_API ) ); \
143
} \
144
} while(0); _APIDBG
145
#else
146
#define APIDBG _APIDBG
147
#endif
148
149
static
void
150
_INTDBG(
char
*format, ... )
151
{
152
#ifdef DEBUG
153
va_list
args;
154
va_start
(args, format);
155
PAPIDEBUG
(
DEBUG_INTERNAL
, format, args );
156
va_end
(args);
157
#endif
158
}
159
#ifdef DEBUG
160
#define INTDBG do { \
161
if (DEBUG_INTERNAL&_papi_hwi_debug) {\
162
DEBUGLABEL( DEBUGLEVEL ( DEBUG_INTERNAL ) ); \
163
} \
164
} while(0); _INTDBG
165
#else
166
#define INTDBG _INTDBG
167
#endif
168
169
static
void
170
_THRDBG(
char
*format, ... )
171
{
172
#ifdef DEBUG
173
va_list
args;
174
va_start
(args, format);
175
PAPIDEBUG
(
DEBUG_THREADS
, format, args );
176
va_end
(args);
177
#endif
178
}
179
#ifdef DEBUG
180
#define THRDBG do { \
181
if (DEBUG_THREADS&_papi_hwi_debug) {\
182
DEBUGLABEL( DEBUGLEVEL ( DEBUG_THREADS ) ); \
183
} \
184
} while(0); _THRDBG
185
#else
186
#define THRDBG _THRDBG
187
#endif
188
189
static
void
190
_MPXDBG(
char
*format, ... )
191
{
192
#ifdef DEBUG
193
va_list
args;
194
va_start
(args, format);
195
PAPIDEBUG
(
DEBUG_MULTIPLEX
, format, args );
196
va_end
(args);
197
#endif
198
}
199
#ifdef DEBUG
200
#define MPXDBG do { \
201
if (DEBUG_MULTIPLEX&_papi_hwi_debug) {\
202
DEBUGLABEL( DEBUGLEVEL ( DEBUG_MULTIPLEX ) ); \
203
} \
204
} while(0); _MPXDBG
205
#else
206
#define MPXDBG _MPXDBG
207
#endif
208
209
static
void
210
_OVFDBG(
char
*format, ... )
211
{
212
#ifdef DEBUG
213
va_list
args;
214
va_start
(args, format);
215
PAPIDEBUG
(
DEBUG_OVERFLOW
, format, args );
216
va_end
(args);
217
#endif
218
}
219
#ifdef DEBUG
220
#define OVFDBG do { \
221
if (DEBUG_OVERFLOW&_papi_hwi_debug) {\
222
DEBUGLABEL( DEBUGLEVEL ( DEBUG_OVERFLOW ) ); \
223
} \
224
} while(0); _OVFDBG
225
#else
226
#define OVFDBG _OVFDBG
227
#endif
228
229
static
void
230
_PRFDBG(
char
*format, ... )
231
{
232
#ifdef DEBUG
233
va_list
args;
234
va_start
(args, format);
235
PAPIDEBUG
(
DEBUG_PROFILE
, format, args );
236
va_end
(args);
237
#endif
238
}
239
#ifdef DEBUG
240
#define PRFDBG do { \
241
if (DEBUG_PROFILE&_papi_hwi_debug) {\
242
DEBUGLABEL( DEBUGLEVEL ( DEBUG_PROFILE ) ); \
243
} \
244
} while(0); _PRFDBG
245
#else
246
#define PRFDBG _PRFDBG
247
#endif
248
249
static
void
250
_MEMDBG(
char
*format, ... )
251
{
252
#ifdef DEBUG
253
va_list
args;
254
va_start
(args, format);
255
PAPIDEBUG
(
DEBUG_MEMORY
, format , args);
256
va_end
(args);
257
#endif
258
}
259
#ifdef DEBUG
260
#define MEMDBG do { \
261
if (DEBUG_MEMORY&_papi_hwi_debug) {\
262
DEBUGLABEL( DEBUGLEVEL ( DEBUG_MEMORY ) ); \
263
} \
264
} while(0); _MEMDBG
265
#else
266
#define MEMDBG _MEMDBG
267
#endif
268
269
static
void
270
_LEAKDBG(
char
*format, ... )
271
{
272
#ifdef DEBUG
273
va_list
args;
274
va_start
(args, format);
275
PAPIDEBUG
(
DEBUG_LEAK
, format , args);
276
va_end
(args);
277
#endif
278
}
279
#ifdef DEBUG
280
#define LEAKDBG do { \
281
if (DEBUG_LEAK&_papi_hwi_debug) {\
282
DEBUGLABEL( DEBUGLEVEL ( DEBUG_LEAK ) ); \
283
} \
284
} while(0); _LEAKDBG
285
#else
286
#define LEAKDBG _LEAKDBG
287
#endif
288
289
static
void
290
_HLDBG(
char
*format, ... )
291
{
292
#ifdef DEBUG
293
va_list
args;
294
va_start
(args, format);
295
PAPIDEBUG
(
DEBUG_HIGHLEVEL
, format , args);
296
va_end
(args);
297
#endif
298
}
299
#ifdef DEBUG
300
#define HLDBG do { \
301
if (DEBUG_HIGHLEVEL&_papi_hwi_debug) {\
302
DEBUGLABEL( DEBUGLEVEL ( DEBUG_HIGHLEVEL ) ); \
303
} \
304
} while(0); _HLDBG
305
#else
306
#define HLDBG _HLDBG
307
#endif
308
309
/* ifdef NO_VARARG_MACRO */
310
#endif
311
312
#endif
/* PAPI_DEBUG_H */
DEBUG_SUBSTRATE
#define DEBUG_SUBSTRATE
Definition:
papi_debug.h:27
DEBUG_LEAK
#define DEBUG_LEAK
Definition:
papi_debug.h:35
PAPIDEBUG
#define PAPIDEBUG(level, format, args...)
Definition:
papi_debug.h:60
DEBUG_OVERFLOW
#define DEBUG_OVERFLOW
Definition:
papi_debug.h:32
_papi_hwi_thread_id_fn
unsigned long int(* _papi_hwi_thread_id_fn)(void)
Definition:
threads.c:42
DEBUG_HIGHLEVEL
#define DEBUG_HIGHLEVEL
Definition:
papi_debug.h:36
ISLEVEL
#define ISLEVEL(a)
Definition:
papi_debug.h:55
_papi_hwi_debug
int _papi_hwi_debug
Definition:
linux-pcp.c:187
DEBUG_MULTIPLEX
#define DEBUG_MULTIPLEX
Definition:
papi_debug.h:31
DEBUG_MEMORY
#define DEBUG_MEMORY
Definition:
papi_debug.h:34
DEBUG_INTERNAL
#define DEBUG_INTERNAL
Definition:
papi_debug.h:29
DEBUG_THREADS
#define DEBUG_THREADS
Definition:
papi_debug.h:30
DEBUG_API
#define DEBUG_API
Definition:
papi_debug.h:28
DEBUG_PROFILE
#define DEBUG_PROFILE
Definition:
papi_debug.h:33
va_list
__gnuc_va_list va_list
Definition:
papi_fwrappers_.c:307
stderr
FILE * stderr
va_end
va_end(arg_list)
va_start
va_start(arg_list, fmt)
int
int
Definition:
sde_internal.h:89
src
papi_debug.h
Generated on Wed Dec 20 2023 18:12:52 for PAPI by
1.9.6