mirror of
https://github.com/AFLplusplus/AFLplusplus.git
synced 2025-06-11 17:51:32 +00:00
Merge pull request #728 from vj-27/dev
load existing stats file when in AFL_AUTORESUME or -i - mode.
This commit is contained in:
@ -425,7 +425,8 @@ typedef struct afl_state {
|
||||
really makes no sense to haul them around as function parameters. */
|
||||
u64 orig_hit_cnt_puppet, last_limit_time_start, tmp_pilot_time,
|
||||
total_pacemaker_time, total_puppet_find, temp_puppet_find, most_time_key,
|
||||
most_time, most_execs_key, most_execs, old_hit_count, force_ui_update;
|
||||
most_time, most_execs_key, most_execs, old_hit_count, force_ui_update,
|
||||
prev_run_time;
|
||||
|
||||
MOpt_globals_t mopt_globals_core, mopt_globals_pilot;
|
||||
|
||||
@ -1067,6 +1068,7 @@ void destroy_extras(afl_state_t *);
|
||||
|
||||
/* Stats */
|
||||
|
||||
void load_stats_file(afl_state_t *);
|
||||
void write_setup_file(afl_state_t *, u32, char **);
|
||||
void write_stats_file(afl_state_t *, double, double, double);
|
||||
void maybe_update_plot_file(afl_state_t *, double, double);
|
||||
|
@ -89,6 +89,100 @@ void write_setup_file(afl_state_t *afl, u32 argc, char **argv) {
|
||||
|
||||
}
|
||||
|
||||
/* load some of the existing stats file when resuming.*/
|
||||
void load_stats_file(afl_state_t *afl) {
|
||||
|
||||
FILE *f;
|
||||
u8 buf[MAX_LINE];
|
||||
u8 * lptr;
|
||||
u8 fn[PATH_MAX];
|
||||
u32 lineno = 0;
|
||||
snprintf(fn, PATH_MAX, "%s/fuzzer_stats", afl->out_dir);
|
||||
f = fopen(fn, "r");
|
||||
if (!f) {
|
||||
|
||||
WARNF("Unable to load stats file '%s'", fn);
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
while ((lptr = fgets(buf, MAX_LINE, f))) {
|
||||
|
||||
lineno++;
|
||||
u8 *lstartptr = lptr;
|
||||
u8 *rptr = lptr + strlen(lptr) - 1;
|
||||
u8 keystring[MAX_LINE];
|
||||
while (*lptr != ':' && lptr < rptr) {
|
||||
|
||||
lptr++;
|
||||
|
||||
}
|
||||
|
||||
if (*lptr == '\n' || !*lptr) {
|
||||
|
||||
WARNF("Unable to read line %d of stats file", lineno);
|
||||
continue;
|
||||
|
||||
}
|
||||
|
||||
if (*lptr == ':') {
|
||||
|
||||
*lptr = 0;
|
||||
strcpy(keystring, lstartptr);
|
||||
lptr++;
|
||||
char *nptr;
|
||||
switch (lineno) {
|
||||
|
||||
case 3:
|
||||
if (!strcmp(keystring, "run_time "))
|
||||
afl->prev_run_time = 1000 * strtoull(lptr, &nptr, 10);
|
||||
break;
|
||||
case 5:
|
||||
if (!strcmp(keystring, "cycles_done "))
|
||||
afl->queue_cycle =
|
||||
strtoull(lptr, &nptr, 10) ? strtoull(lptr, &nptr, 10) + 1 : 0;
|
||||
break;
|
||||
case 7:
|
||||
if (!strcmp(keystring, "execs_done "))
|
||||
afl->fsrv.total_execs = strtoull(lptr, &nptr, 10);
|
||||
break;
|
||||
case 10:
|
||||
if (!strcmp(keystring, "paths_total "))
|
||||
afl->queued_paths = strtoul(lptr, &nptr, 10);
|
||||
break;
|
||||
case 12:
|
||||
if (!strcmp(keystring, "paths_found "))
|
||||
afl->queued_discovered = strtoul(lptr, &nptr, 10);
|
||||
break;
|
||||
case 13:
|
||||
if (!strcmp(keystring, "paths_imported "))
|
||||
afl->queued_imported = strtoul(lptr, &nptr, 10);
|
||||
break;
|
||||
case 14:
|
||||
if (!strcmp(keystring, "max_depth "))
|
||||
afl->max_depth = strtoul(lptr, &nptr, 10);
|
||||
break;
|
||||
case 21:
|
||||
if (!strcmp(keystring, "unique_crashes "))
|
||||
afl->unique_crashes = strtoull(lptr, &nptr, 10);
|
||||
break;
|
||||
case 22:
|
||||
if (!strcmp(keystring, "unique_hangs "))
|
||||
afl->unique_hangs = strtoull(lptr, &nptr, 10);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
/* Update stats file for unattended monitoring. */
|
||||
|
||||
void write_stats_file(afl_state_t *afl, double bitmap_cvg, double stability,
|
||||
@ -179,12 +273,13 @@ void write_stats_file(afl_state_t *afl, double bitmap_cvg, double stability,
|
||||
"\n"
|
||||
"target_mode : %s%s%s%s%s%s%s%s%s\n"
|
||||
"command_line : %s\n",
|
||||
afl->start_time / 1000, cur_time / 1000,
|
||||
(cur_time - afl->start_time) / 1000, (u32)getpid(),
|
||||
afl->queue_cycle ? (afl->queue_cycle - 1) : 0, afl->cycles_wo_finds,
|
||||
afl->fsrv.total_execs,
|
||||
(afl->start_time - afl->prev_run_time) / 1000, cur_time / 1000,
|
||||
(afl->prev_run_time + cur_time - afl->start_time) / 1000,
|
||||
(u32)getpid(), afl->queue_cycle ? (afl->queue_cycle - 1) : 0,
|
||||
afl->cycles_wo_finds, afl->fsrv.total_execs,
|
||||
afl->fsrv.total_execs /
|
||||
((double)(get_cur_time() - afl->start_time) / 1000),
|
||||
((double)(afl->prev_run_time + get_cur_time() - afl->start_time) /
|
||||
1000),
|
||||
afl->last_avg_execs_saved, afl->queued_paths, afl->queued_favored,
|
||||
afl->queued_discovered, afl->queued_imported, afl->max_depth,
|
||||
afl->current_entry, afl->pending_favored, afl->pending_not_fuzzed,
|
||||
@ -379,8 +474,8 @@ void show_stats(afl_state_t *afl) {
|
||||
|
||||
if (likely(cur_ms != afl->start_time)) {
|
||||
|
||||
afl->stats_avg_exec =
|
||||
((double)afl->fsrv.total_execs) * 1000 / (cur_ms - afl->start_time);
|
||||
afl->stats_avg_exec = ((double)afl->fsrv.total_execs) * 1000 /
|
||||
(afl->prev_run_time + cur_ms - afl->start_time);
|
||||
|
||||
}
|
||||
|
||||
@ -592,7 +687,7 @@ void show_stats(afl_state_t *afl) {
|
||||
|
||||
}
|
||||
|
||||
u_stringify_time_diff(time_tmp, cur_ms, afl->start_time);
|
||||
u_stringify_time_diff(time_tmp, afl->prev_run_time + cur_ms, afl->start_time);
|
||||
SAYF(bV bSTOP " run time : " cRST "%-33s " bSTG bV bSTOP
|
||||
" cycles done : %s%-5s " bSTG bV "\n",
|
||||
time_tmp, tmp, u_stringify_int(IB(0), afl->queue_cycle - 1));
|
||||
|
@ -1682,6 +1682,8 @@ int main(int argc, char **argv_orig, char **envp) {
|
||||
|
||||
if (unlikely(afl->old_seed_selection)) seek_to = find_start_position(afl);
|
||||
|
||||
afl->start_time = get_cur_time();
|
||||
if (afl->in_place_resume || afl->afl_env.afl_autoresume) load_stats_file(afl);
|
||||
write_stats_file(afl, 0, 0, 0);
|
||||
maybe_update_plot_file(afl, 0, 0);
|
||||
save_auto(afl);
|
||||
|
Reference in New Issue
Block a user