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 | a3d741f | 2008-02-27 18:32:33 +0100 | [diff] [blame] | 19 | FD_DEBUG_MAX, |
| 20 | }; |
| 21 | |
Jens Axboe | 69b98d4 | 2008-05-30 22:25:32 +0200 | [diff] [blame] | 22 | extern unsigned int fio_debug_jobno, *fio_debug_jobp; |
| 23 | |
Jens Axboe | a3d741f | 2008-02-27 18:32:33 +0100 | [diff] [blame] | 24 | #ifdef FIO_INC_DEBUG |
| 25 | struct debug_level { |
| 26 | const char *name; |
| 27 | unsigned long shift; |
Jens Axboe | 5e1d306 | 2008-05-23 11:55:53 +0200 | [diff] [blame] | 28 | unsigned int jobno; |
Jens Axboe | a3d741f | 2008-02-27 18:32:33 +0100 | [diff] [blame] | 29 | }; |
| 30 | extern struct debug_level debug_levels[]; |
| 31 | |
| 32 | extern unsigned long fio_debug; |
| 33 | |
| 34 | #define dprint(type, str, args...) \ |
| 35 | do { \ |
Jens Axboe | 5e1d306 | 2008-05-23 11:55:53 +0200 | [diff] [blame] | 36 | pid_t pid = getpid(); \ |
Jens Axboe | a3d741f | 2008-02-27 18:32:33 +0100 | [diff] [blame] | 37 | assert(type < FD_DEBUG_MAX); \ |
| 38 | if ((((1 << type)) & fio_debug) == 0) \ |
| 39 | break; \ |
Jens Axboe | 5e1d306 | 2008-05-23 11:55:53 +0200 | [diff] [blame] | 40 | if (fio_debug_jobp && *fio_debug_jobp != -1U \ |
| 41 | && pid != *fio_debug_jobp) \ |
| 42 | break; \ |
Jens Axboe | a3d741f | 2008-02-27 18:32:33 +0100 | [diff] [blame] | 43 | log_info("%-8s ", debug_levels[(type)].name); \ |
Jens Axboe | 5921e80 | 2008-05-30 15:02:38 +0200 | [diff] [blame] | 44 | log_info("%-5u ", (int) pid); \ |
Jens Axboe | a3d741f | 2008-02-27 18:32:33 +0100 | [diff] [blame] | 45 | log_info(str, ##args); \ |
| 46 | } while (0) |
| 47 | |
| 48 | #else |
| 49 | |
| 50 | #define dprint(type, str, args...) |
| 51 | #endif |
| 52 | |
| 53 | #endif |