static void cmdlineHelp(const char *pname, struct custom_option *opts) { LOG_HELP_BOLD("Usage: %s [options] -- path_to_command [args]", pname); LOG_HELP_BOLD("Options:"); for (int i = 0; opts[i].opt.name; i++) { if (isprint(opts[i].opt.val)) { LOG_HELP_BOLD(" --%s%s%c %s", opts[i].opt.name, "|-", opts[i].opt.val, opts[i].opt.has_arg == required_argument ? "[val]" : ""); } else { LOG_HELP_BOLD(" --%s %s", opts[i].opt.name, opts[i].opt.has_arg == required_argument ? "[val]" : ""); } LOG_HELP("\t%s", opts[i].descr); } LOG_HELP_BOLD("\nExamples:"); LOG_HELP(" Run the binary over a mutated file chosen from the directory"); LOG_HELP_BOLD(" " PROG_NAME " -f input_dir -- /usr/bin/tiffinfo -D " _HF_FILE_PLACEHOLDER); LOG_HELP(" As above, provide input over STDIN:"); LOG_HELP_BOLD(" " PROG_NAME " -f input_dir -s -- /usr/bin/djpeg"); #if defined(_HF_ARCH_LINUX) LOG_HELP(" Run the binary over a dynamic file, maximize total no. of instructions:"); LOG_HELP_BOLD(" " PROG_NAME " --linux_perf_instr -- /usr/bin/tiffinfo -D " _HF_FILE_PLACEHOLDER); LOG_HELP(" Run the binary over a dynamic file, maximize total no. of branches:"); LOG_HELP_BOLD(" " PROG_NAME " --linux_perf_branch -- /usr/bin/tiffinfo -D " _HF_FILE_PLACEHOLDER); LOG_HELP(" Run the binary over a dynamic file, maximize unique code blocks (coverage):"); LOG_HELP_BOLD(" " PROG_NAME " --linux_perf_ip -- /usr/bin/tiffinfo -D " _HF_FILE_PLACEHOLDER); LOG_HELP(" Run the binary over a dynamic file, maximize unique branches (edges):"); LOG_HELP_BOLD(" " PROG_NAME " --linux_perf_ip_addr -- /usr/bin/tiffinfo -D " _HF_FILE_PLACEHOLDER); LOG_HELP(" Run the binary over a dynamic file, maximize custom counters (experimental):"); LOG_HELP_BOLD(" " PROG_NAME " --linux_perf_custom -- /usr/bin/tiffinfo -D " _HF_FILE_PLACEHOLDER); #endif /* defined(_HF_ARCH_LINUX) */ }
static void cmdlineHelp(const char* pname, struct custom_option* opts) { LOG_HELP_BOLD("Usage: %s [options] -- path_to_command [args]", pname); LOG_HELP_BOLD("Options:"); for (int i = 0; opts[i].opt.name; i++) { if (isprint(opts[i].opt.val) && opts[i].opt.val < 0x80) { LOG_HELP_BOLD(" --%s%s%c %s", opts[i].opt.name, "|-", opts[i].opt.val, opts[i].opt.has_arg == required_argument ? "VALUE" : ""); } else { LOG_HELP_BOLD(" --%s %s", opts[i].opt.name, opts[i].opt.has_arg == required_argument ? "VALUE" : ""); } LOG_HELP("\t%s", opts[i].descr); } LOG_HELP_BOLD("\nExamples:"); LOG_HELP( " Run the binary over a mutated file chosen from the directory. Disable fuzzing feedback " "(static mode):"); LOG_HELP_BOLD(" " PROG_NAME " -f input_dir -x -- /usr/bin/djpeg " _HF_FILE_PLACEHOLDER); LOG_HELP(" As above, provide input over STDIN:"); LOG_HELP_BOLD(" " PROG_NAME " -f input_dir -x -s -- /usr/bin/djpeg"); LOG_HELP(" Use compile-time instrumentation (-fsanitize-coverage=trace-pc-guard,...):"); LOG_HELP_BOLD(" " PROG_NAME " -f input_dir -- /usr/bin/djpeg " _HF_FILE_PLACEHOLDER); LOG_HELP(" Use persistent mode w/o instrumentation:"); LOG_HELP_BOLD(" " PROG_NAME " -f input_dir -P -x -- /usr/bin/djpeg_persistent_mode"); LOG_HELP(" Use persistent mode and compile-time (-fsanitize-coverage=trace-pc-guard,...) " "instrumentation:"); LOG_HELP_BOLD(" " PROG_NAME " -f input_dir -P -- /usr/bin/djpeg_persistent_mode"); #if defined(_HF_ARCH_LINUX) LOG_HELP( " Run the binary with dynamically generate inputs, maximize total no. of instructions:"); LOG_HELP_BOLD(" " PROG_NAME " --linux_perf_instr -- /usr/bin/djpeg " _HF_FILE_PLACEHOLDER); LOG_HELP(" As above, maximize total no. of branches:"); LOG_HELP_BOLD(" " PROG_NAME " --linux_perf_branch -- /usr/bin/djpeg " _HF_FILE_PLACEHOLDER); LOG_HELP(" As above, maximize unique branches (edges) via Intel BTS:"); LOG_HELP_BOLD(" " PROG_NAME " --linux_perf_bts_edge -- /usr/bin/djpeg " _HF_FILE_PLACEHOLDER); LOG_HELP( " As above, maximize unique code blocks via Intel Processor Trace (requires libipt.so):"); LOG_HELP_BOLD(" " PROG_NAME " --linux_perf_ipt_block -- /usr/bin/djpeg " _HF_FILE_PLACEHOLDER); #endif /* defined(_HF_ARCH_LINUX) */ }