blob: 6a74131aed7a95394c8cb4b384c80fd5407da5f4 [file] [log] [blame]
Jens Axboea3d741f2008-02-27 18:32:33 +01001#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,
Jens Axboecd991b92008-03-07 13:19:35 +010016 FD_DISKUTIL,
Jens Axboe5e1d3062008-05-23 11:55:53 +020017 FD_JOB,
Jens Axboe29adda32009-01-05 19:06:39 +010018 FD_MUTEX,
Jens Axboe79d16312010-03-04 12:43:20 +010019 FD_PROFILE,
Jens Axboec223da82010-03-24 13:23:53 +010020 FD_TIME,
Jens Axboeeb7976e2011-10-01 12:42:00 -060021 FD_NET,
Jens Axboea3d741f2008-02-27 18:32:33 +010022 FD_DEBUG_MAX,
23};
24
Jens Axboe69b98d42008-05-30 22:25:32 +020025extern unsigned int fio_debug_jobno, *fio_debug_jobp;
26
Jens Axboea3d741f2008-02-27 18:32:33 +010027#ifdef FIO_INC_DEBUG
28struct debug_level {
29 const char *name;
Jens Axboe0b8d11e2012-03-02 19:44:15 +010030 const char *help;
Jens Axboea3d741f2008-02-27 18:32:33 +010031 unsigned long shift;
Jens Axboe5e1d3062008-05-23 11:55:53 +020032 unsigned int jobno;
Jens Axboea3d741f2008-02-27 18:32:33 +010033};
34extern struct debug_level debug_levels[];
35
36extern unsigned long fio_debug;
37
Jens Axboe985ee302013-02-26 08:16:43 +010038void __dprint(int type, const char *str, ...) __attribute__((format (printf, 2, 3)));
Jens Axboebf84eac2010-03-19 16:41:52 +010039
40#define dprint(type, str, args...) \
41 do { \
42 if ((((1 << type)) & fio_debug) == 0) \
43 break; \
44 __dprint((type), (str), ##args); \
45 } while (0) \
Jens Axboea3d741f2008-02-27 18:32:33 +010046
47#else
48
Jens Axboebf84eac2010-03-19 16:41:52 +010049static inline void dprint(int type, const char *str, ...)
50{
51}
Jens Axboea3d741f2008-02-27 18:32:33 +010052#endif
53
54#endif