axmap: code cleanups
[fio.git] / debug.h
1 #ifndef FIO_DEBUG_H
2 #define FIO_DEBUG_H
3
4 #include "lib/types.h"
5
6 enum {
7         FD_PROCESS      = 0,
8         FD_FILE,
9         FD_IO,
10         FD_MEM,
11         FD_BLKTRACE,
12         FD_VERIFY,
13         FD_RANDOM,
14         FD_PARSE,
15         FD_DISKUTIL,
16         FD_JOB,
17         FD_MUTEX,
18         FD_PROFILE,
19         FD_TIME,
20         FD_NET,
21         FD_RATE,
22         FD_COMPRESS,
23         FD_STEADYSTATE,
24         FD_HELPERTHREAD,
25         FD_DEBUG_MAX,
26 };
27
28 extern unsigned int fio_debug_jobno, *fio_debug_jobp, *fio_warned;
29
30 static inline bool fio_did_warn(unsigned int mask)
31 {
32         if (*fio_warned & mask)
33                 return true;
34
35         *fio_warned |= mask;
36         return false;
37 }
38
39 enum {
40         FIO_WARN_ROOT_FLUSH     = 1,
41         FIO_WARN_VERIFY_BUF     = 2,
42         FIO_WARN_ZONED_BUG      = 4,
43         FIO_WARN_IOLOG_DROP     = 8,
44         FIO_WARN_FADVISE        = 16,
45         FIO_WARN_BTRACE_ZERO    = 32,
46 };
47
48 #ifdef FIO_INC_DEBUG
49 struct debug_level {
50         const char *name;
51         const char *help;
52         unsigned long shift;
53         unsigned int jobno;
54 };
55 extern const struct debug_level debug_levels[];
56
57 extern unsigned long fio_debug;
58
59 void __dprint(int type, const char *str, ...) __attribute__((format (printf, 2, 3)));
60
61 #define dprint(type, str, args...)                      \
62         do {                                            \
63                 if (((1 << type) & fio_debug) == 0)     \
64                         break;                          \
65                 __dprint((type), (str), ##args);        \
66         } while (0)                                     \
67
68 #else
69
70 static inline void dprint(int type, const char *str, ...)
71 {
72 }
73 #endif
74
75 #endif