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