display.c revision c20cdbfcc8042c3b81959ef1edd227b3ab5424e5
1fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot/* 2fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot * 3fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot * honggfuzz - display statistics 4fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot * ----------------------------------------- 5fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot * 6fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot * Author: Robert Swiecki <swiecki@google.com> 7fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot * 8fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot * Copyright 2010-2015 by Google Inc. All Rights Reserved. 9fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot * 10fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot * Licensed under the Apache License, Version 2.0 (the "License"); you may 11fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot * not use this file except in compliance with the License. You may obtain 12fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot * a copy of the License at 13fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot * 14fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot * http://www.apache.org/licenses/LICENSE-2.0 15fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot * 16fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot * Unless required by applicable law or agreed to in writing, software 17fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot * distributed under the License is distributed on an "AS IS" BASIS, 18fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 19fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot * implied. See the License for the specific language governing 20fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot * permissions and limitations under the License. 21fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot * 22fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot */ 23fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot 24fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot#define _WITH_DPRINTF 25fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot 26fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot#include "common.h" 27fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot#include "display.h" 28fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot 29fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot#include <inttypes.h> 30fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot#include <math.h> 31fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot#include <string.h> 32fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot#include <stdarg.h> 33fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot#include <stdio.h> 34fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot#include <unistd.h> 35fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot 36fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot#include "log.h" 37fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot#include "util.h" 38fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot 39fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot#define ESC_CLEAR "\033[H\033[2J" 40fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot#define ESC_NAV(x,y) "\033["#x";"#y"H" 41fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot#define ESC_BOLD "\033[1m" 42fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot#define ESC_RED "\033[31m" 43fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot#define ESC_RESET "\033[0m" 44fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot 45fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot#if defined(_HF_ARCH_LINUX) 46fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot#define _HF_MONETARY_MOD "'" 47fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot#else 48fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot#define _HF_MONETARY_MOD "" 49fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot#endif 50fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot 51fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robotstatic void display_put(const char *fmt, ...) 52fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot{ 53fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot va_list args; 54fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot va_start(args, fmt); 55fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot vfprintf(stdout, fmt, args); 56fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot va_end(args); 57fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot fflush(stdout); 58fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot} 59fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot 60fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robotstatic void display_printKMG(uint64_t val) 61fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot{ 62fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot if (val >= 1000000000UL) { 63fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot display_put(" [%.2lfG]", (double)val / 1000000.0); 64fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot } else if (val >= 1000000UL) { 65fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot display_put(" [%.2lfM]", (double)val / 1000000.0); 66fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot } else if (val >= 1000UL) { 67fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot display_put(" [%.2lfk]", (double)val / 1000.0); 68fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot } 69fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot} 70fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot 71fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robotstatic double getCpuUse(long num_cpu) 72fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot{ 73fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot static uint64_t prevIdleT = 0UL; 74fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot 75fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot FILE *f = fopen("/proc/stat", "re"); 76fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot if (f == NULL) { 77fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot return NAN; 78fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot } 79fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot defer { 80fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot fclose(f); 81fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot }; 82fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot uint64_t userT, niceT, systemT, idleT; 83fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot if (fscanf 84fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot (f, "cpu %" PRIu64 "%" PRIu64 "%" PRIu64 "%" PRIu64, &userT, &niceT, &systemT, 85fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot &idleT) != 4) { 86fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot LOG_W("fscanf('/proc/stat') != 4"); 87fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot return NAN; 88fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot } 89fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot 90fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot if (prevIdleT == 0UL) { 91fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot prevIdleT = idleT; 92fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot return NAN; 93fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot } 94fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot 95fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot uint64_t cpuUse = (num_cpu * sysconf(_SC_CLK_TCK)) - (idleT - prevIdleT); 96fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot prevIdleT = idleT; 97fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot return (double)cpuUse / sysconf(_SC_CLK_TCK) * 100; 98fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot} 99fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot 100fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robotstatic void display_displayLocked(honggfuzz_t * hfuzz) 101fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot{ 102fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot unsigned long elapsed_second = (unsigned long)(time(NULL) - hfuzz->timeStart); 103fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot unsigned int day, hour, min, second; 104fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot char time_elapsed_str[64]; 105fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot if (elapsed_second < 24 * 3600) { 106fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot hour = elapsed_second / 3600; 107fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot min = (elapsed_second - 3600 * hour) / 60; 108fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot second = elapsed_second - hour * 3600 - min * 60; 109fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot snprintf(time_elapsed_str, sizeof(time_elapsed_str), "%u hrs %u min %u sec", hour, 110fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot min, second); 111fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot } else { 112fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot day = elapsed_second / 24 / 3600; 113fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot elapsed_second = elapsed_second - day * 24 * 3600; 114fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot hour = elapsed_second / 3600; 115fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot min = (elapsed_second - 3600 * hour) / 60; 116fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot second = elapsed_second - hour * 3600 - min * 60; 117fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot snprintf(time_elapsed_str, sizeof(time_elapsed_str), 118fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot "%u days %u hrs %u min %u sec", day, hour, min, second); 119fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot } 120fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot 121fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot size_t curr_exec_cnt = ATOMIC_GET(hfuzz->mutationsCnt); 122fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot /* 123fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot * We increase the mutation counter unconditionally in threads, but if it's 124fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot * above hfuzz->mutationsMax we don't really execute the fuzzing loop. 125fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot * Therefore at the end of fuzzing, the mutation counter might be higher 126fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot * than hfuzz->mutationsMax 127fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot */ 128fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot if (hfuzz->mutationsMax > 0 && curr_exec_cnt > hfuzz->mutationsMax) { 129fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot curr_exec_cnt = hfuzz->mutationsMax; 130fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot } 131fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot float exeProgress = 0.0f; 132fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot if (hfuzz->mutationsMax > 0) { 133fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot exeProgress = ((float)curr_exec_cnt * 100 / hfuzz->mutationsMax); 134fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot } 135fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot 136fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot static size_t prev_exec_cnt = 0UL; 137fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot uintptr_t exec_per_sec = curr_exec_cnt - prev_exec_cnt; 138fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot prev_exec_cnt = curr_exec_cnt; 139fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot 140fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot /* The lock should be acquired before any output is printed on the screen */ 141fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot MX_SCOPED_LOCK(logMutexGet()); 142fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot 143fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot display_put("%s", ESC_CLEAR); 144fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot display_put("----------------------------[ %s v%s ]---------------------------\n", 145fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot PROG_NAME, PROG_VERSION); 146fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot display_put(" Iterations : " ESC_BOLD "%" _HF_MONETARY_MOD "zu" ESC_RESET, curr_exec_cnt); 147fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot display_printKMG(curr_exec_cnt); 148fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot if (hfuzz->mutationsMax) { 149fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot display_put(" (out of: " ESC_BOLD "%zu" ESC_RESET " [" ESC_BOLD "%.2f" ESC_RESET 150fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot "%%])", hfuzz->mutationsMax, exeProgress); 151fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot } 152fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot switch (ATOMIC_GET(hfuzz->state)) { 153fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot case _HF_STATE_STATIC: 154fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot display_put("\n Phase : " ESC_BOLD "Static Main" ESC_RESET); 155fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot break; 156fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot case _HF_STATE_DYNAMIC_PRE: 157fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot display_put("\n Phase : " ESC_BOLD "Dynamic Pre" ESC_RESET); 158fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot break; 159fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot case _HF_STATE_DYNAMIC_MAIN: 160fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot display_put("\n Phase : " ESC_BOLD "Dynamic Main" ESC_RESET); 161fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot break; 162fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot default: 163fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot display_put("\n Phase : " ESC_BOLD "Unknown" ESC_RESET); 164fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot break; 165fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot } 166fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot 167fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot char start_time_str[128]; 168fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot util_getLocalTime("%F %T", start_time_str, sizeof(start_time_str), hfuzz->timeStart); 169fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot display_put("\n Run Time : " ESC_BOLD "%s" ESC_RESET " (since: " ESC_BOLD "%s" ESC_RESET 170fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot ")\n", time_elapsed_str, start_time_str); 171fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot display_put(" Input Dir : '" ESC_BOLD "%s" ESC_RESET "'\n", 172fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot hfuzz->inputDir != NULL ? hfuzz->inputDir : "[NONE]"); 173fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot display_put(" Fuzzed Cmd : '" ESC_BOLD "%s" ESC_RESET "'\n", hfuzz->cmdline_txt); 174fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot if (hfuzz->linux.pid > 0) { 175fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot display_put("Remote cmd [" ESC_BOLD "%d" ESC_RESET "]: '" ESC_BOLD "%s" ESC_RESET 176fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot "'\n", hfuzz->linux.pid, hfuzz->linux.pidCmd); 177fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot } 178fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot 179fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot static long num_cpu = 0; 180fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot if (num_cpu == 0) { 181fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot num_cpu = sysconf(_SC_NPROCESSORS_ONLN); 182fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot } 183fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot double cpuUse = getCpuUse(num_cpu); 184fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot display_put(" Threads : " ESC_BOLD "%zu" ESC_RESET ", CPUs: " ESC_BOLD "%ld" ESC_RESET 185fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot ", CPU: " ESC_BOLD "%.1lf" ESC_RESET "%% (" ESC_BOLD "%.1lf" ESC_RESET "%%/CPU)\n", 186fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot hfuzz->threadsMax, num_cpu, cpuUse, cpuUse / num_cpu); 187fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot 188fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot display_put(" Speed : " ESC_BOLD "% " _HF_MONETARY_MOD "zu" ESC_RESET "/sec" 189fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot " (avg: " ESC_BOLD "%" _HF_MONETARY_MOD "zu" ESC_RESET ")\n", exec_per_sec, 190fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot elapsed_second ? (curr_exec_cnt / elapsed_second) : 0); 191fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot /* If dry run, print also the input file count */ 192fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot if (hfuzz->origFlipRate == 0.0L && hfuzz->useVerifier) { 193fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot display_put(" Input Files : '" ESC_BOLD "%" _HF_MONETARY_MOD "zu" ESC_RESET "'\n", 194fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot hfuzz->fileCnt); 195fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot } 196fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot 197fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot uint64_t crashesCnt = ATOMIC_GET(hfuzz->crashesCnt); 198fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot /* colored the crash count as red when exist crash */ 199fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot display_put(" Crashes : " ESC_BOLD "%s" "%zu" ESC_RESET " (unique: %s" ESC_BOLD "%zu" 200fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot ESC_RESET ", blacklist: " ESC_BOLD "%zu" ESC_RESET ", verified: " 201fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot ESC_BOLD "%zu" ESC_RESET ")\n", crashesCnt > 0 ? ESC_RED : "", 202fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot hfuzz->crashesCnt, crashesCnt > 0 ? ESC_RED : "", 203fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot ATOMIC_GET(hfuzz->uniqueCrashesCnt), ATOMIC_GET(hfuzz->blCrashesCnt), 204fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot ATOMIC_GET(hfuzz->verifiedCrashesCnt)); 205fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot display_put(" Timeouts : " ESC_BOLD "%" _HF_MONETARY_MOD "zu" ESC_RESET " [%" 206fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot _HF_MONETARY_MOD "zu sec.]\n", ATOMIC_GET(hfuzz->timeoutedCnt), hfuzz->tmOut); 207fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot /* Feedback data sources are enabled. Start with common headers. */ 208fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot if (hfuzz->dynFileMethod != _HF_DYNFILE_NONE || hfuzz->useSanCov) { 209fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot display_put(" Corpus Size : " ESC_BOLD "%" _HF_MONETARY_MOD "zu" ESC_RESET 210fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot ", max size (bytes): " ESC_BOLD "%" _HF_MONETARY_MOD "zu" ESC_RESET "\n", 211fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot hfuzz->dynfileqCnt, hfuzz->maxFileSz); 212fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot display_put(" Coverage :\n"); 213fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot } 214fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot 215fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot /* HW perf specific counters */ 216fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot if (hfuzz->dynFileMethod & _HF_DYNFILE_INSTR_COUNT) { 217fe17456d5e528078ce69b5f15cf7adf1fab963fandroid-build-team Robot display_put(" *** instructions: " ESC_BOLD "%" _HF_MONETARY_MOD PRIu64 ESC_RESET 218 "\n", ATOMIC_GET(hfuzz->linux.hwCnts.cpuInstrCnt)); 219 } 220 if (hfuzz->dynFileMethod & _HF_DYNFILE_BRANCH_COUNT) { 221 display_put(" *** branches: " ESC_BOLD "%" _HF_MONETARY_MOD PRIu64 ESC_RESET 222 "\n", ATOMIC_GET(hfuzz->linux.hwCnts.cpuBranchCnt)); 223 } 224 if (hfuzz->dynFileMethod & _HF_DYNFILE_BTS_BLOCK) { 225 display_put(" *** BTS blocks: " ESC_BOLD "%" _HF_MONETARY_MOD PRIu64 ESC_RESET 226 "\n", ATOMIC_GET(hfuzz->linux.hwCnts.bbCnt)); 227 } 228 if (hfuzz->dynFileMethod & _HF_DYNFILE_BTS_EDGE) { 229 display_put(" *** BTS edges: " ESC_BOLD "%" _HF_MONETARY_MOD PRIu64 ESC_RESET 230 "\n", ATOMIC_GET(hfuzz->linux.hwCnts.bbCnt)); 231 } 232 if (hfuzz->dynFileMethod & _HF_DYNFILE_IPT_BLOCK) { 233 display_put(" *** PT blocks: " ESC_BOLD "%" _HF_MONETARY_MOD PRIu64 ESC_RESET 234 "\n", ATOMIC_GET(hfuzz->linux.hwCnts.bbCnt)); 235 } 236 if (hfuzz->dynFileMethod & _HF_DYNFILE_CUSTOM) { 237 display_put(" *** custom counter: " ESC_BOLD "%" _HF_MONETARY_MOD PRIu64 ESC_RESET 238 "\n", ATOMIC_GET(hfuzz->linux.hwCnts.customCnt)); 239 } 240 241 if (hfuzz->dynFileMethod & _HF_DYNFILE_SOFT) { 242 uint64_t softCntPc = ATOMIC_GET(hfuzz->linux.hwCnts.softCntPc); 243 uint64_t softCntCmp = ATOMIC_GET(hfuzz->linux.hwCnts.softCntCmp); 244 display_put(" *** blocks seen: " ESC_BOLD "%" _HF_MONETARY_MOD PRIu64 ESC_RESET 245 ", comparison map: " ESC_BOLD "%" _HF_MONETARY_MOD PRIu64 ESC_RESET "\n", 246 softCntPc, softCntCmp); 247 } 248 249 /* Sanitizer coverage specific counters */ 250 if (hfuzz->useSanCov) { 251 uint64_t hitBB = ATOMIC_GET(hfuzz->sanCovCnts.hitBBCnt); 252 uint64_t totalBB = ATOMIC_GET(hfuzz->sanCovCnts.totalBBCnt); 253 float covPer = totalBB ? (((float)hitBB * 100) / totalBB) : 0.0; 254 display_put(" *** total hit #bb: " ESC_BOLD "%" _HF_MONETARY_MOD PRIu64 ESC_RESET 255 " (coverage " ESC_BOLD "%.2f" ESC_RESET "%%)\n", hitBB, covPer); 256 display_put(" *** total #dso: " ESC_BOLD "%" _HF_MONETARY_MOD PRIu64 ESC_RESET 257 " (instrumented only)\n", ATOMIC_GET(hfuzz->sanCovCnts.iDsoCnt)); 258 display_put(" *** discovered #bb: " ESC_BOLD "%" _HF_MONETARY_MOD PRIu64 ESC_RESET 259 " (new from input seed)\n", ATOMIC_GET(hfuzz->sanCovCnts.newBBCnt)); 260 display_put(" *** crashes: " ESC_BOLD "%" _HF_MONETARY_MOD PRIu64 ESC_RESET 261 "\n", ATOMIC_GET(hfuzz->sanCovCnts.crashesCnt)); 262 } 263 display_put("-----------------------------------[ LOGS ]-----------------------------------\n"); 264} 265 266extern void display_display(honggfuzz_t * hfuzz) 267{ 268 display_displayLocked(hfuzz); 269} 270