From: Jens Axboe Date: Thu, 4 Jun 2015 19:45:32 +0000 (-0600) Subject: init: automate displaying debug categories X-Git-Tag: fio-2.2.9~21 X-Git-Url: https://git.kernel.dk/?p=fio.git;a=commitdiff_plain;h=2236df3d9d6bc053039a5c2185cff43ea5015111 init: automate displaying debug categories Better than having them hardwired, so we don't have to update the code in several places when adding new categories. Signed-off-by: Jens Axboe --- diff --git a/init.c b/init.c index 9f1041c7..515f3141 100644 --- a/init.c +++ b/init.c @@ -1710,13 +1710,41 @@ static int fill_def_thread(void) return 0; } +static void show_debug_categories(void) +{ + struct debug_level *dl = &debug_levels[0]; + int curlen, first = 1; + + curlen = 0; + while (dl->name) { + int has_next = (dl + 1)->name != NULL; + + if (first || curlen + strlen(dl->name) >= 80) { + if (!first) { + printf("\n"); + curlen = 0; + } + curlen += printf("\t\t\t%s", dl->name); + curlen += 3 * (8 - 1); + if (has_next) + curlen += printf(","); + } else { + curlen += printf("%s", dl->name); + if (has_next) + curlen += printf(","); + } + dl++; + first = 0; + } + printf("\n"); +} + static void usage(const char *name) { printf("%s\n", fio_version_string); printf("%s [options] [job options] \n", name); - printf(" --debug=options\tEnable debug logging. May be one/more of:\n" - "\t\t\tprocess,file,io,mem,blktrace,verify,random,parse,\n" - "\t\t\tdiskutil,job,mutex,profile,time,net,rate,compress\n"); + printf(" --debug=options\tEnable debug logging. May be one/more of:\n"); + show_debug_categories(); printf(" --parse-only\t\tParse options only, don't start any IO\n"); printf(" --output\t\tWrite output to file\n"); printf(" --runtime\t\tRuntime in seconds\n");