Jens Axboe | a3d741f | 2008-02-27 18:32:33 +0100 | [diff] [blame] | 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, |
Jens Axboe | cd991b9 | 2008-03-07 13:19:35 +0100 | [diff] [blame] | 16 | FD_DISKUTIL, |
Jens Axboe | 5e1d306 | 2008-05-23 11:55:53 +0200 | [diff] [blame] | 17 | FD_JOB, |
Jens Axboe | 29adda3 | 2009-01-05 19:06:39 +0100 | [diff] [blame] | 18 | FD_MUTEX, |
Jens Axboe | 79d1631 | 2010-03-04 12:43:20 +0100 | [diff] [blame] | 19 | FD_PROFILE, |
Jens Axboe | c223da8 | 2010-03-24 13:23:53 +0100 | [diff] [blame] | 20 | FD_TIME, |
Jens Axboe | eb7976e | 2011-10-01 12:42:00 -0600 | [diff] [blame] | 21 | FD_NET, |
Jens Axboe | a3d741f | 2008-02-27 18:32:33 +0100 | [diff] [blame] | 22 | FD_DEBUG_MAX, |
| 23 | }; |
| 24 | |
Jens Axboe | 69b98d4 | 2008-05-30 22:25:32 +0200 | [diff] [blame] | 25 | extern unsigned int fio_debug_jobno, *fio_debug_jobp; |
| 26 | |
Jens Axboe | a3d741f | 2008-02-27 18:32:33 +0100 | [diff] [blame] | 27 | #ifdef FIO_INC_DEBUG |
| 28 | struct debug_level { |
| 29 | const char *name; |
Jens Axboe | 0b8d11e | 2012-03-02 19:44:15 +0100 | [diff] [blame] | 30 | const char *help; |
Jens Axboe | a3d741f | 2008-02-27 18:32:33 +0100 | [diff] [blame] | 31 | unsigned long shift; |
Jens Axboe | 5e1d306 | 2008-05-23 11:55:53 +0200 | [diff] [blame] | 32 | unsigned int jobno; |
Jens Axboe | a3d741f | 2008-02-27 18:32:33 +0100 | [diff] [blame] | 33 | }; |
| 34 | extern struct debug_level debug_levels[]; |
| 35 | |
| 36 | extern unsigned long fio_debug; |
| 37 | |
Jens Axboe | 985ee30 | 2013-02-26 08:16:43 +0100 | [diff] [blame] | 38 | void __dprint(int type, const char *str, ...) __attribute__((format (printf, 2, 3))); |
Jens Axboe | bf84eac | 2010-03-19 16:41:52 +0100 | [diff] [blame] | 39 | |
| 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 Axboe | a3d741f | 2008-02-27 18:32:33 +0100 | [diff] [blame] | 46 | |
| 47 | #else |
| 48 | |
Jens Axboe | bf84eac | 2010-03-19 16:41:52 +0100 | [diff] [blame] | 49 | static inline void dprint(int type, const char *str, ...) |
| 50 | { |
| 51 | } |
Jens Axboe | a3d741f | 2008-02-27 18:32:33 +0100 | [diff] [blame] | 52 | #endif |
| 53 | |
| 54 | #endif |