"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "display.c" between
honggfuzz-2.1.tar.gz and honggfuzz-2.2.tar.gz

About: honggfuzz is a security oriented, feedback-driven, evolutionary, easy-to-use fuzzer with powerful analysis options.

display.c  (honggfuzz-2.1):display.c  (honggfuzz-2.2)
skipping to change at line 56 skipping to change at line 56
#define ESC_BOLD "\033[1m" #define ESC_BOLD "\033[1m"
#define ESC_RED "\033[31m" #define ESC_RED "\033[31m"
#define ESC_RESET "\033[0m" #define ESC_RESET "\033[0m"
#define ESC_SCROLL_REGION(x, y) "\033[" #x ";" #y "r" #define ESC_SCROLL_REGION(x, y) "\033[" #x ";" #y "r"
#define ESC_SCROLL_DISABLE "\033[?7h" #define ESC_SCROLL_DISABLE "\033[?7h"
#define ESC_SCROLL_RESET "\033[r" #define ESC_SCROLL_RESET "\033[r"
#define ESC_NAV_DOWN(x) "\033[" #x "B" #define ESC_NAV_DOWN(x) "\033[" #x "B"
#define ESC_NAV_HORIZ(x) "\033[" #x "G" #define ESC_NAV_HORIZ(x) "\033[" #x "G"
#define ESC_RESET_SETTINGS "\033[!p" #define ESC_RESET_SETTINGS "\033[!p"
/* printf() nonmonetary separator. According to MacOSX's man it's supported ther
e as well */
#define _HF_NONMON_SEP "'"
static char displayBuf[1024 * 1024]; static char displayBuf[1024 * 1024];
static void display_start(void) { static void display_start(void) {
memset(displayBuf, '\0', sizeof(displayBuf)); memset(displayBuf, '\0', sizeof(displayBuf));
} }
static void display_stop(void) { static void display_stop(void) {
TEMP_FAILURE_RETRY(write(logFd(), displayBuf, strlen(displayBuf))); TEMP_FAILURE_RETRY(write(logFd(), displayBuf, strlen(displayBuf)));
} }
__attribute__((format(printf, 1, 2))) static void display_put(const char* fmt, . ..) { __attribute__((format(printf, 1, 2))) static void display_put(const char* fmt, . ..) {
skipping to change at line 174 skipping to change at line 171
&tmpstr[len - 27]); &tmpstr[len - 27]);
} }
void display_display(honggfuzz_t* hfuzz) { void display_display(honggfuzz_t* hfuzz) {
if (logIsTTY() == false) { if (logIsTTY() == false) {
return; return;
} }
const time_t curr_sec = time(NULL); const time_t curr_sec = time(NULL);
const time_t elapsed_sec = curr_sec - hfuzz->timing.timeStart; const time_t elapsed_sec = curr_sec - hfuzz->timing.timeStart;
const int64_t curr_time_millis = util_timeNowMillis(); const int64_t curr_time_usecs = util_timeNowUSecs();
const int64_t elapsed_millis = curr_time_millis - hfuzz->display.lastDisplay const int64_t elapsed_usecs = curr_time_usecs - hfuzz->display.lastDisplayUS
Millis; ecs;
hfuzz->display.lastDisplayMillis = curr_time_millis; hfuzz->display.lastDisplayUSecs = curr_time_usecs;
char lastCovStr[64]; char lastCovStr[64];
getDuration(curr_sec - ATOMIC_GET(hfuzz->timing.lastCovUpdate), lastCovStr, sizeof(lastCovStr)); getDuration(curr_sec - ATOMIC_GET(hfuzz->timing.lastCovUpdate), lastCovStr, sizeof(lastCovStr));
char timeStr[64]; char timeStr[64];
if (ATOMIC_GET(hfuzz->timing.runEndTime)) { if (ATOMIC_GET(hfuzz->timing.runEndTime)) {
getDuration(ATOMIC_GET(hfuzz->timing.runEndTime) - curr_sec, timeStr, si zeof(timeStr)); getDuration(ATOMIC_GET(hfuzz->timing.runEndTime) - curr_sec, timeStr, si zeof(timeStr));
} else { } else {
getDuration(elapsed_sec, timeStr, sizeof(timeStr)); getDuration(elapsed_sec, timeStr, sizeof(timeStr));
} }
skipping to change at line 203 skipping to change at line 200
*/ */
if (hfuzz->mutate.mutationsMax > 0 && curr_exec_cnt > hfuzz->mutate.mutation sMax) { if (hfuzz->mutate.mutationsMax > 0 && curr_exec_cnt > hfuzz->mutate.mutation sMax) {
curr_exec_cnt = hfuzz->mutate.mutationsMax; curr_exec_cnt = hfuzz->mutate.mutationsMax;
} }
int exeProgress = 0; int exeProgress = 0;
if (hfuzz->mutate.mutationsMax > 0) { if (hfuzz->mutate.mutationsMax > 0) {
exeProgress = (curr_exec_cnt * 100) / hfuzz->mutate.mutationsMax; exeProgress = (curr_exec_cnt * 100) / hfuzz->mutate.mutationsMax;
} }
static size_t prev_exec_cnt = 0UL; static size_t prev_exec_cnt = 0UL;
size_t exec_per_millis = size_t exec_per_usecs =
elapsed_millis ? ((curr_exec_cnt - prev_exec_cnt) * 1000) / elapsed_mill elapsed_usecs ? ((curr_exec_cnt - prev_exec_cnt) * 1000000) / elapsed_us
is : 0; ecs : 0;
prev_exec_cnt = curr_exec_cnt; prev_exec_cnt = curr_exec_cnt;
display_start(); display_start();
display_put(ESC_NAV(13, 1) ESC_CLEAR_ABOVE ESC_NAV(1, 1)); display_put(ESC_NAV(13, 1) ESC_CLEAR_ABOVE ESC_NAV(1, 1));
display_put("------------------------[" ESC_BOLD "%31s " ESC_RESET "]------- ---------------\n", display_put("------------------------[" ESC_BOLD "%31s " ESC_RESET "]------- ---------------\n",
timeStr); timeStr);
display_put(" Iterations : " ESC_BOLD "%" _HF_NONMON_SEP "zu" ESC_RESET, cu rr_exec_cnt); display_put(" Iterations : " ESC_BOLD "%" _HF_NONMON_SEP "zu" ESC_RESET, cu rr_exec_cnt);
display_printKMG(curr_exec_cnt); display_printKMG(curr_exec_cnt);
if (hfuzz->mutate.mutationsMax) { if (hfuzz->mutate.mutationsMax) {
display_put(" (out of: " ESC_BOLD "%" _HF_NONMON_SEP "zu" ESC_RESET " [% d%%])", display_put(" (out of: " ESC_BOLD "%" _HF_NONMON_SEP "zu" ESC_RESET " [% d%%])",
hfuzz->mutate.mutationsMax, exeProgress); hfuzz->mutate.mutationsMax, exeProgress);
} }
switch (ATOMIC_GET(hfuzz->feedback.state)) { switch (ATOMIC_GET(hfuzz->feedback.state)) {
case _HF_STATE_STATIC: case _HF_STATE_STATIC:
display_put("\n Mode : " ESC_BOLD "Static" ESC_RESET "\n"); display_put("\n Mode : " ESC_BOLD "Static" ESC_RESET "\n");
break; break;
case _HF_STATE_DYNAMIC_DRY_RUN: { case _HF_STATE_DYNAMIC_DRY_RUN: {
if (ATOMIC_GET(hfuzz->cfg.switchingToFDM)) { if (ATOMIC_GET(hfuzz->cfg.switchingToFDM)) {
display_put("\n Mode [2/3] : " ESC_BOLD display_put("\n Mode [2/3] : " ESC_BOLD
"Switching to the Feedback Driven Mode" ESC_RESET "\ "Switching to the Feedback Driven Mode" ESC_RESET "
n"); [%zu/%zu]\n",
hfuzz->io.testedFileCnt, hfuzz->io.fileCnt);
} else { } else {
display_put("\n Mode [1/3] : " ESC_BOLD "Feedback Driven Dry Ru display_put("\n Mode [1/3] : " ESC_BOLD "Feedback Driven Dry Ru
n" ESC_RESET "\n"); n" ESC_RESET
" [%zu/%zu]\n",
hfuzz->io.testedFileCnt, hfuzz->io.fileCnt);
} }
} break; } break;
case _HF_STATE_DYNAMIC_MAIN: case _HF_STATE_DYNAMIC_MAIN:
display_put("\n Mode [3/3] : " ESC_BOLD "Feedback Driven Mode" ESC_ RESET "\n"); display_put("\n Mode [3/3] : " ESC_BOLD "Feedback Driven Mode" ESC_ RESET "\n");
break; break;
case _HF_STATE_DYNAMIC_MINIMIZE: case _HF_STATE_DYNAMIC_MINIMIZE:
display_put("\n Mode [3/3] : " ESC_BOLD "Corpus Minimization" ESC_R ESET "\n"); display_put("\n Mode [3/3] : " ESC_BOLD "Corpus Minimization" ESC_R ESET "\n");
break; break;
default: default:
display_put("\n Mode : " ESC_BOLD "Unknown" ESC_RESET "\n"); display_put("\n Mode : " ESC_BOLD "Unknown" ESC_RESET "\n");
skipping to change at line 257 skipping to change at line 257
num_cpu = 1; num_cpu = 1;
} }
unsigned cpuUse = getCpuUse(num_cpu); unsigned cpuUse = getCpuUse(num_cpu);
display_put(" Threads : " ESC_BOLD "%zu" ESC_RESET ", CPUs: " ESC_BOLD " %ld" ESC_RESET display_put(" Threads : " ESC_BOLD "%zu" ESC_RESET ", CPUs: " ESC_BOLD " %ld" ESC_RESET
", CPU%%: " ESC_BOLD "%u" ESC_RESET "%% [" ESC_BOLD "%lu" ESC_RE SET "%%/CPU]\n", ", CPU%%: " ESC_BOLD "%u" ESC_RESET "%% [" ESC_BOLD "%lu" ESC_RE SET "%%/CPU]\n",
hfuzz->threads.threadsMax, num_cpu, cpuUse, cpuUse / num_cpu); hfuzz->threads.threadsMax, num_cpu, cpuUse, cpuUse / num_cpu);
size_t tot_exec_per_sec = elapsed_sec ? (curr_exec_cnt / elapsed_sec) : 0; size_t tot_exec_per_sec = elapsed_sec ? (curr_exec_cnt / elapsed_sec) : 0;
display_put(" Speed : " ESC_BOLD "%" _HF_NONMON_SEP "zu" ESC_RESET "/s ec [avg: " ESC_BOLD display_put(" Speed : " ESC_BOLD "%" _HF_NONMON_SEP "zu" ESC_RESET "/s ec [avg: " ESC_BOLD
"%" _HF_NONMON_SEP "zu" ESC_RESET "]\n", "%" _HF_NONMON_SEP "zu" ESC_RESET "]\n",
exec_per_millis, tot_exec_per_sec); exec_per_usecs, tot_exec_per_sec);
uint64_t crashesCnt = ATOMIC_GET(hfuzz->cnts.crashesCnt); uint64_t crashesCnt = ATOMIC_GET(hfuzz->cnts.crashesCnt);
/* colored the crash count as red when exist crash */ /* colored the crash count as red when exist crash */
display_put(" Crashes : " ESC_BOLD "%s" display_put(" Crashes : " ESC_BOLD "%s"
"%zu" ESC_RESET " [unique: %s" ESC_BOLD "%zu" ESC_RESET ", black list: " ESC_BOLD "%zu" ESC_RESET " [unique: %s" ESC_BOLD "%zu" ESC_RESET ", black list: " ESC_BOLD
"%zu" ESC_RESET ", verified: " ESC_BOLD "%zu" ESC_RESET "]\n", "%zu" ESC_RESET ", verified: " ESC_BOLD "%zu" ESC_RESET "]\n",
crashesCnt > 0 ? ESC_RED : "", hfuzz->cnts.crashesCnt, crashesCnt > 0 ? ESC_RED : "", crashesCnt > 0 ? ESC_RED : "", hfuzz->cnts.crashesCnt, crashesCnt > 0 ? ESC_RED : "",
ATOMIC_GET(hfuzz->cnts.uniqueCrashesCnt), ATOMIC_GET(hfuzz->cnts.blCrash esCnt), ATOMIC_GET(hfuzz->cnts.uniqueCrashesCnt), ATOMIC_GET(hfuzz->cnts.blCrash esCnt),
ATOMIC_GET(hfuzz->cnts.verifiedCrashesCnt)); ATOMIC_GET(hfuzz->cnts.verifiedCrashesCnt));
display_put(" Timeouts : " ESC_BOLD "%" _HF_NONMON_SEP "zu" ESC_RESET " [ %lu sec]\n", display_put(" Timeouts : " ESC_BOLD "%" _HF_NONMON_SEP "zu" ESC_RESET " [ %lu sec]\n",
ATOMIC_GET(hfuzz->cnts.timeoutedCnt), (unsigned long)hfuzz->timing.tmOut ); ATOMIC_GET(hfuzz->cnts.timeoutedCnt), (unsigned long)hfuzz->timing.tmOut );
/* Feedback data sources. Common headers. */ /* Feedback data sources. Common headers. */
display_put(" Corpus Size : " ESC_BOLD "%" _HF_NONMON_SEP "zu" ESC_RESET ", max: " ESC_BOLD display_put(" Corpus Size : " ESC_BOLD "%" _HF_NONMON_SEP "zu" ESC_RESET ", max: " ESC_BOLD
"%" _HF_NONMON_SEP "zu" ESC_RESET " bytes, init: " ESC_BOLD "%" _HF_NONMON_SEP "%" _HF_NONMON_SEP "zu" ESC_RESET " bytes, init: " ESC_BOLD "%" _HF_NONMON_SEP
"zu" ESC_RESET " files\n", "zu" ESC_RESET " files\n",
hfuzz->io.dynfileqCnt, hfuzz->mutate.maxFileSz, ATOMIC_GET(hfuzz->io.fil eCnt)); hfuzz->io.dynfileqCnt, hfuzz->mutate.maxInputSz, ATOMIC_GET(hfuzz->io.fi leCnt));
display_put(" Cov Update : " ESC_BOLD "%s" ESC_RESET " ago\n" ESC_RESET, la stCovStr); display_put(" Cov Update : " ESC_BOLD "%s" ESC_RESET " ago\n" ESC_RESET, la stCovStr);
display_put(" Coverage :"); display_put(" Coverage :");
/* HW perf specific counters */ /* HW perf specific counters */
if (hfuzz->feedback.dynFileMethod == 0) { if (hfuzz->feedback.dynFileMethod == 0) {
display_put(" [none]"); display_put(" [none]");
} }
if (hfuzz->feedback.dynFileMethod & _HF_DYNFILE_INSTR_COUNT) { if (hfuzz->feedback.dynFileMethod & _HF_DYNFILE_INSTR_COUNT) {
display_put(" hwi: " ESC_BOLD "%" _HF_NONMON_SEP PRIu64 ESC_RESET, display_put(" hwi: " ESC_BOLD "%" _HF_NONMON_SEP PRIu64 ESC_RESET,
ATOMIC_GET(hfuzz->linux.hwCnts.cpuInstrCnt)); ATOMIC_GET(hfuzz->feedback.hwCnts.cpuInstrCnt));
} }
if (hfuzz->feedback.dynFileMethod & _HF_DYNFILE_BRANCH_COUNT) { if (hfuzz->feedback.dynFileMethod & _HF_DYNFILE_BRANCH_COUNT) {
display_put(" hwb: " ESC_BOLD "%" _HF_NONMON_SEP PRIu64 ESC_RESET, display_put(" hwb: " ESC_BOLD "%" _HF_NONMON_SEP PRIu64 ESC_RESET,
ATOMIC_GET(hfuzz->linux.hwCnts.cpuBranchCnt)); ATOMIC_GET(hfuzz->feedback.hwCnts.cpuBranchCnt));
} }
if (hfuzz->feedback.dynFileMethod & _HF_DYNFILE_BTS_EDGE) { if (hfuzz->feedback.dynFileMethod & _HF_DYNFILE_BTS_EDGE) {
display_put(" bts: " ESC_BOLD "%" _HF_NONMON_SEP PRIu64 ESC_RESET, display_put(" bts: " ESC_BOLD "%" _HF_NONMON_SEP PRIu64 ESC_RESET,
ATOMIC_GET(hfuzz->linux.hwCnts.bbCnt)); ATOMIC_GET(hfuzz->feedback.hwCnts.bbCnt));
} }
if (hfuzz->feedback.dynFileMethod & _HF_DYNFILE_IPT_BLOCK) { if (hfuzz->feedback.dynFileMethod & _HF_DYNFILE_IPT_BLOCK) {
display_put(" ipt: " ESC_BOLD "%" _HF_NONMON_SEP PRIu64 ESC_RESET, display_put(" ipt: " ESC_BOLD "%" _HF_NONMON_SEP PRIu64 ESC_RESET,
ATOMIC_GET(hfuzz->linux.hwCnts.bbCnt)); ATOMIC_GET(hfuzz->feedback.hwCnts.bbCnt));
} }
if (hfuzz->feedback.dynFileMethod & _HF_DYNFILE_SOFT) { if (hfuzz->feedback.dynFileMethod & _HF_DYNFILE_SOFT) {
uint64_t softCntPc = ATOMIC_GET(hfuzz->linux.hwCnts.softCntPc); uint64_t softCntPc = ATOMIC_GET(hfuzz->feedback.hwCnts.softCntPc);
uint64_t softCntEdge = ATOMIC_GET(hfuzz->linux.hwCnts.softCntEdge); uint64_t softCntEdge = ATOMIC_GET(hfuzz->feedback.hwCnts.softCntEdge);
uint64_t softCntCmp = ATOMIC_GET(hfuzz->linux.hwCnts.softCntCmp); uint64_t softCntCmp = ATOMIC_GET(hfuzz->feedback.hwCnts.softCntCmp);
uint64_t guardNb = ATOMIC_GET(hfuzz->feedback.covFeedbackMap->guardNb); uint64_t guardNb = ATOMIC_GET(hfuzz->feedback.covFeedbackMap->guardNb);
display_put(" edge: " ESC_BOLD "%" _HF_NONMON_SEP PRIu64 ESC_RESET "/" display_put(" edge: " ESC_BOLD "%" _HF_NONMON_SEP PRIu64 ESC_RESET "/"
"%" _HF_NONMON_SEP PRIu64 " [%" PRId64 "%%]", "%" _HF_NONMON_SEP PRIu64 " [%" PRId64 "%%]",
softCntEdge, guardNb, guardNb ? ((softCntEdge * 100) / guardNb) : 0) ; softCntEdge, guardNb, guardNb ? ((softCntEdge * 100) / guardNb) : 0) ;
display_put(" pc: " ESC_BOLD "%" _HF_NONMON_SEP PRIu64 ESC_RESET, softCn tPc); display_put(" pc: " ESC_BOLD "%" _HF_NONMON_SEP PRIu64 ESC_RESET, softCn tPc);
display_put(" cmp: " ESC_BOLD "%" _HF_NONMON_SEP PRIu64 ESC_RESET, softC ntCmp); display_put(" cmp: " ESC_BOLD "%" _HF_NONMON_SEP PRIu64 ESC_RESET, softC ntCmp);
} }
display_put("\n---------------------------------- [ " ESC_BOLD "LOGS" ESC_RE SET display_put("\n---------------------------------- [ " ESC_BOLD "LOGS" ESC_RE SET
" ] ------------------/ " ESC_BOLD "%s %s " ESC_RESET "/-", " ] ------------------/ " ESC_BOLD "%s %s " ESC_RESET "/-",
 End of changes. 12 change blocks. 
24 lines changed or deleted 23 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)