blob: 1a2b79ab6d24b4a385ed1720f718dc29a345cf3b [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 Axboea3d741f2008-02-27 18:32:33 +010019 FD_DEBUG_MAX,
20};
21
Jens Axboe69b98d42008-05-30 22:25:32 +020022extern unsigned int fio_debug_jobno, *fio_debug_jobp;
23
Jens Axboea3d741f2008-02-27 18:32:33 +010024#ifdef FIO_INC_DEBUG
25struct debug_level {
26 const char *name;
27 unsigned long shift;
Jens Axboe5e1d3062008-05-23 11:55:53 +020028 unsigned int jobno;
Jens Axboea3d741f2008-02-27 18:32:33 +010029};
30extern struct debug_level debug_levels[];
31
32extern unsigned long fio_debug;
33
34#define dprint(type, str, args...) \
35 do { \
Jens Axboe5e1d3062008-05-23 11:55:53 +020036 pid_t pid = getpid(); \
Jens Axboea3d741f2008-02-27 18:32:33 +010037 assert(type < FD_DEBUG_MAX); \
38 if ((((1 << type)) & fio_debug) == 0) \
39 break; \
Jens Axboe5e1d3062008-05-23 11:55:53 +020040 if (fio_debug_jobp && *fio_debug_jobp != -1U \
41 && pid != *fio_debug_jobp) \
42 break; \
Jens Axboea3d741f2008-02-27 18:32:33 +010043 log_info("%-8s ", debug_levels[(type)].name); \
Jens Axboe5921e802008-05-30 15:02:38 +020044 log_info("%-5u ", (int) pid); \
Jens Axboea3d741f2008-02-27 18:32:33 +010045 log_info(str, ##args); \
46 } while (0)
47
48#else
49
50#define dprint(type, str, args...)
51#endif
52
53#endif