summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJens Axboe <jens.axboe@oracle.com>2008-02-27 18:32:33 +0100
committerJens Axboe <jens.axboe@oracle.com>2008-02-27 18:32:33 +0100
commita3d741fa3bc3120d5b62a56826a97524daa32803 (patch)
tree9f792474e4cbca062176a7a7788a9691cfdfbf7d
parentc0a5d35ec77fae5cfe382d35ab18915ed6766504 (diff)
downloadfio-a3d741fa3bc3120d5b62a56826a97524daa32803.tar.gz
Add --debug=parse for option parsing debug
Adds log.h and debug.h to split the logging and debug bits out of fio, so that the parser can use them. Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
-rw-r--r--README1
-rw-r--r--debug.h42
-rw-r--r--fio.h47
-rw-r--r--init.c1
-rw-r--r--log.h21
-rw-r--r--parse.c10
6 files changed, 77 insertions, 45 deletions
diff --git a/README b/README
index cf48c018..ef614a28 100644
--- a/README
+++ b/README
@@ -100,6 +100,7 @@ options in fio. Currently the options are:
verify Dump info related to IO verification
all Enable all debug options
random Dump info related to random offset generation
+ parse Dump info related to option matching and parsing
? or help Show available debug options.
You can specify as many as you want, eg --debug=file,mem will enable
diff --git a/debug.h b/debug.h
new file mode 100644
index 00000000..b11a9012
--- /dev/null
+++ b/debug.h
@@ -0,0 +1,42 @@
+#ifndef FIO_DEBUG_H
+#define FIO_DEBUG_H
+
+#include <assert.h>
+#include "log.h"
+
+enum {
+ FD_PROCESS = 0,
+ FD_FILE,
+ FD_IO,
+ FD_MEM,
+ FD_BLKTRACE,
+ FD_VERIFY,
+ FD_RANDOM,
+ FD_PARSE,
+ FD_DEBUG_MAX,
+};
+
+#ifdef FIO_INC_DEBUG
+struct debug_level {
+ const char *name;
+ unsigned long shift;
+};
+extern struct debug_level debug_levels[];
+
+extern unsigned long fio_debug;
+
+#define dprint(type, str, args...) \
+ do { \
+ assert(type < FD_DEBUG_MAX); \
+ if ((((1 << type)) & fio_debug) == 0) \
+ break; \
+ log_info("%-8s ", debug_levels[(type)].name); \
+ log_info(str, ##args); \
+ } while (0)
+
+#else
+
+#define dprint(type, str, args...)
+#endif
+
+#endif
diff --git a/fio.h b/fio.h
index 028ef4cb..0c5b6487 100644
--- a/fio.h
+++ b/fio.h
@@ -22,6 +22,8 @@
#include "arch/arch.h"
#include "os/os.h"
#include "mutex.h"
+#include "log.h"
+#include "debug.h"
#ifdef FIO_HAVE_GUASI
#include <guasi.h>
@@ -659,8 +661,6 @@ extern int nr_process, nr_thread;
extern int shm_id;
extern int groupid;
extern int terse_output;
-extern FILE *f_out;
-extern FILE *f_err;
extern int temp_stall_ts;
extern unsigned long long mlock_size;
extern unsigned long page_mask, page_size;
@@ -903,20 +903,6 @@ extern int is_blktrace(const char *);
extern int load_blktrace(struct thread_data *, const char *);
#endif
-/*
- * If logging output to a file, stderr should go to both stderr and f_err
- */
-#define log_err(args...) do { \
- fprintf(f_err, ##args); \
- if (f_err != stderr) \
- fprintf(stderr, ##args); \
- } while (0)
-
-#define log_info(args...) fprintf(f_out, ##args)
-
-FILE *get_f_out(void);
-FILE *get_f_err(void);
-
struct ioengine_ops {
struct list_head list;
char name[16];
@@ -972,35 +958,7 @@ static inline void clear_error(struct thread_data *td)
td->verror[0] = '\0';
}
-enum {
- FD_PROCESS = 0,
- FD_FILE,
- FD_IO,
- FD_MEM,
- FD_BLKTRACE,
- FD_VERIFY,
- FD_RANDOM,
- FD_DEBUG_MAX,
-};
-
#ifdef FIO_INC_DEBUG
-struct debug_level {
- const char *name;
- unsigned long shift;
-};
-extern struct debug_level debug_levels[];
-
-extern unsigned long fio_debug;
-
-#define dprint(type, str, args...) \
- do { \
- assert(type < FD_DEBUG_MAX); \
- if ((((1 << type)) & fio_debug) == 0) \
- break; \
- log_info("%-8s ", debug_levels[(type)].name); \
- log_info(str, ##args); \
- } while (0)
-
static inline void dprint_io_u(struct io_u *io_u, const char *p)
{
struct fio_file *f = io_u->file;
@@ -1015,7 +973,6 @@ static inline void dprint_io_u(struct io_u *io_u, const char *p)
}
}
#else
-#define dprint(type, str, args...)
#define dprint_io_u(io_u, p)
#endif
diff --git a/init.c b/init.c
index 4f57ba31..65997297 100644
--- a/init.c
+++ b/init.c
@@ -812,6 +812,7 @@ struct debug_level debug_levels[] = {
{ .name = "blktrace", .shift = FD_BLKTRACE },
{ .name = "verify", .shift = FD_VERIFY },
{ .name = "random", .shift = FD_RANDOM },
+ { .name = "parse", .shift = FD_PARSE },
{ },
};
diff --git a/log.h b/log.h
new file mode 100644
index 00000000..12c9a552
--- /dev/null
+++ b/log.h
@@ -0,0 +1,21 @@
+#ifndef FIO_LOG_H
+#define FIO_LOG_H
+
+extern FILE *f_out;
+extern FILE *f_err;
+
+/*
+ * If logging output to a file, stderr should go to both stderr and f_err
+ */
+#define log_err(args...) do { \
+ fprintf(f_err, ##args); \
+ if (f_err != stderr) \
+ fprintf(stderr, ##args); \
+ } while (0)
+
+#define log_info(args...) fprintf(f_out, ##args)
+
+FILE *get_f_out(void);
+FILE *get_f_err(void);
+
+#endif
diff --git a/parse.c b/parse.c
index 90874f16..3c203121 100644
--- a/parse.c
+++ b/parse.c
@@ -10,6 +10,7 @@
#include <limits.h>
#include "parse.h"
+#include "debug.h"
static int vp_cmp(const void *p1, const void *p2)
{
@@ -229,6 +230,9 @@ static int __handle_option(struct fio_option *o, const char *ptr, void *data,
char **cp;
int ret = 0, is_time = 0;
+ dprint(FD_PARSE, "__handle_option=%s, type=%d, ptr=%s\n", o->name,
+ o->type, ptr);
+
if (!ptr && o->type != FIO_OPT_STR_SET) {
fprintf(stderr, "Option %s requires an argument\n", o->name);
return 1;
@@ -414,6 +418,8 @@ static int handle_option(struct fio_option *o, const char *ptr, void *data)
const char *ptr2 = NULL;
int r1, r2;
+ dprint(FD_PARSE, "handle_option=%s, ptr=%s\n", o->name, ptr);
+
/*
* See if we have a second set of parameters, hidden after a comma.
* Do this before parsing the first round, to check if we should
@@ -661,6 +667,8 @@ void fill_default_options(void *data, struct fio_option *options)
{
struct fio_option *o;
+ dprint(FD_PARSE, "filling default options\n");
+
for (o = &options[0]; o->name; o++)
if (o->def)
handle_option(o, o->def, data);
@@ -674,6 +682,8 @@ void options_init(struct fio_option *options)
{
struct fio_option *o;
+ dprint(FD_PARSE, "init options\n");
+
for (o = &options[0]; o->name; o++) {
if (o->type == FIO_OPT_BOOL) {
o->minval = 0;