Fix refill buffers overwriting verify data
[fio.git] / debug.h
1 #ifndef FIO_DEBUG_H
2 #define FIO_DEBUG_H
3
4 #include <assert.h>
5 #include "log.h"
6
7 enum {
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,
16         FD_DISKUTIL,
17         FD_JOB,
18         FD_DEBUG_MAX,
19 };
20
21 #ifdef FIO_INC_DEBUG
22 struct debug_level {
23         const char *name;
24         unsigned long shift;
25         unsigned int jobno;
26 };
27 extern struct debug_level debug_levels[];
28
29 extern unsigned long fio_debug;
30 extern unsigned int fio_debug_jobno, *fio_debug_jobp;
31
32 #define dprint(type, str, args...)                              \
33         do {                                                    \
34                 pid_t pid = getpid();                           \
35                 assert(type < FD_DEBUG_MAX);                    \
36                 if ((((1 << type)) & fio_debug) == 0)           \
37                         break;                                  \
38                 if (fio_debug_jobp && *fio_debug_jobp != -1U    \
39                     && pid != *fio_debug_jobp)                  \
40                         break;                                  \
41                 log_info("%-8s ", debug_levels[(type)].name);   \
42                 log_info("%-5u ", pid);                         \
43                 log_info(str, ##args);                          \
44         } while (0)
45
46 #else
47
48 #define dprint(type, str, args...)
49 #endif
50
51 #endif