Add write barriers
[fio.git] / debug.h
CommitLineData
a3d741fa
JA
1#ifndef FIO_DEBUG_H
2#define FIO_DEBUG_H
3
4#include <assert.h>
5#include "log.h"
6
7enum {
8 FD_PROCESS = 0,
9 FD_FILE,
10 FD_IO,
11 FD_MEM,
12 FD_BLKTRACE,
13 FD_VERIFY,
14 FD_RANDOM,
15 FD_PARSE,
cd991b9e 16 FD_DISKUTIL,
5e1d306e 17 FD_JOB,
a3d741fa
JA
18 FD_DEBUG_MAX,
19};
20
69b98d4c
JA
21extern unsigned int fio_debug_jobno, *fio_debug_jobp;
22
a3d741fa
JA
23#ifdef FIO_INC_DEBUG
24struct debug_level {
25 const char *name;
26 unsigned long shift;
5e1d306e 27 unsigned int jobno;
a3d741fa
JA
28};
29extern struct debug_level debug_levels[];
30
31extern unsigned long fio_debug;
32
33#define dprint(type, str, args...) \
34 do { \
5e1d306e 35 pid_t pid = getpid(); \
a3d741fa
JA
36 assert(type < FD_DEBUG_MAX); \
37 if ((((1 << type)) & fio_debug) == 0) \
38 break; \
5e1d306e
JA
39 if (fio_debug_jobp && *fio_debug_jobp != -1U \
40 && pid != *fio_debug_jobp) \
41 break; \
a3d741fa 42 log_info("%-8s ", debug_levels[(type)].name); \
5921e80c 43 log_info("%-5u ", (int) pid); \
a3d741fa
JA
44 log_info(str, ##args); \
45 } while (0)
46
47#else
48
49#define dprint(type, str, args...)
50#endif
51
52#endif