load run time and donot load pending_* or *_favoured

This commit is contained in:
vj-27
2021-02-05 19:46:24 +00:00
parent 6f163bb0c5
commit 1a8c242d28
3 changed files with 22 additions and 17 deletions

View File

@ -1067,7 +1067,7 @@ void destroy_extras(afl_state_t *);
/* Stats */ /* Stats */
void load_stats_file(afl_state_t *); u32 load_stats_file(afl_state_t *);
void write_setup_file(afl_state_t *, u32, char **); void write_setup_file(afl_state_t *, u32, char **);
void write_stats_file(afl_state_t *, double, double, double); void write_stats_file(afl_state_t *, double, double, double);
void maybe_update_plot_file(afl_state_t *, double, double); void maybe_update_plot_file(afl_state_t *, double, double);

View File

@ -90,20 +90,20 @@ void write_setup_file(afl_state_t *afl, u32 argc, char **argv) {
} }
/* load some of the existing stats file when resuming.*/ /* load some of the existing stats file when resuming.*/
void load_stats_file(afl_state_t *afl) { u32 load_stats_file(afl_state_t *afl) {
FILE *f; FILE *f;
u8 buf[MAX_LINE]; u8 buf[MAX_LINE];
u8 * lptr; u8 * lptr;
u8 fn[PATH_MAX]; u8 fn[PATH_MAX];
u32 lineno = 0; u32 lineno = 0;
u32 prev_run_time = 0;
snprintf(fn, PATH_MAX, "%s/fuzzer_stats", afl->out_dir); snprintf(fn, PATH_MAX, "%s/fuzzer_stats", afl->out_dir);
f = fopen(fn, "r"); f = fopen(fn, "r");
if (!f) { if (!f) {
WARNF("Unable to load stats file '%s'", fn); WARNF("Unable to load stats file '%s'", fn);
return; return prev_run_time;
} }
@ -134,6 +134,15 @@ void load_stats_file(afl_state_t *afl) {
char *nptr; char *nptr;
switch (lineno) { switch (lineno) {
case 3:
if (!strcmp(keystring, "run_time ")) {
prev_run_time = 1000 * strtoull(lptr, &nptr, 10);
afl->start_time -= prev_run_time;
}
break;
case 5: case 5:
if (!strcmp(keystring, "cycles_done ")) if (!strcmp(keystring, "cycles_done "))
afl->queue_cycle = afl->queue_cycle =
@ -147,10 +156,6 @@ void load_stats_file(afl_state_t *afl) {
if (!strcmp(keystring, "paths_total ")) if (!strcmp(keystring, "paths_total "))
afl->queued_paths = strtoul(lptr, &nptr, 10); afl->queued_paths = strtoul(lptr, &nptr, 10);
break; break;
case 11:
if (!strcmp(keystring, "paths_favored "))
afl->queued_favored = strtoul(lptr, &nptr, 10);
break;
case 12: case 12:
if (!strcmp(keystring, "paths_found ")) if (!strcmp(keystring, "paths_found "))
afl->queued_discovered = strtoul(lptr, &nptr, 10); afl->queued_discovered = strtoul(lptr, &nptr, 10);
@ -163,14 +168,6 @@ void load_stats_file(afl_state_t *afl) {
if (!strcmp(keystring, "max_depth ")) if (!strcmp(keystring, "max_depth "))
afl->max_depth = strtoul(lptr, &nptr, 10); afl->max_depth = strtoul(lptr, &nptr, 10);
break; break;
case 16:
if (!strcmp(keystring, "pending_favs "))
afl->pending_favored = strtoul(lptr, &nptr, 10);
break;
case 17:
if (!strcmp(keystring, "pending_total "))
afl->pending_not_fuzzed = strtoul(lptr, &nptr, 10);
break;
case 21: case 21:
if (!strcmp(keystring, "unique_crashes ")) if (!strcmp(keystring, "unique_crashes "))
afl->unique_crashes = strtoull(lptr, &nptr, 10); afl->unique_crashes = strtoull(lptr, &nptr, 10);
@ -188,6 +185,8 @@ void load_stats_file(afl_state_t *afl) {
} }
return prev_run_time;
} }
/* Update stats file for unattended monitoring. */ /* Update stats file for unattended monitoring. */

View File

@ -1682,7 +1682,11 @@ int main(int argc, char **argv_orig, char **envp) {
if (unlikely(afl->old_seed_selection)) seek_to = find_start_position(afl); if (unlikely(afl->old_seed_selection)) seek_to = find_start_position(afl);
if (afl->in_place_resume || afl->afl_env.afl_autoresume) load_stats_file(afl); u32 prev_run_time = 0; // to not call load_stats_file again after line 1705
afl->start_time = get_cur_time(); // without this, time taken for
// perform_dry_run gets added to run time.
if (afl->in_place_resume || afl->afl_env.afl_autoresume)
prev_run_time = load_stats_file(afl);
write_stats_file(afl, 0, 0, 0); write_stats_file(afl, 0, 0, 0);
maybe_update_plot_file(afl, 0, 0); maybe_update_plot_file(afl, 0, 0);
save_auto(afl); save_auto(afl);
@ -1701,6 +1705,8 @@ int main(int argc, char **argv_orig, char **envp) {
// (void)nice(-20); // does not improve the speed // (void)nice(-20); // does not improve the speed
// real start time, we reset, so this works correctly with -V // real start time, we reset, so this works correctly with -V
afl->start_time = get_cur_time(); afl->start_time = get_cur_time();
if (afl->in_place_resume || afl->afl_env.afl_autoresume)
afl->start_time -= prev_run_time;
u32 runs_in_current_cycle = (u32)-1; u32 runs_in_current_cycle = (u32)-1;
u32 prev_queued_paths = 0; u32 prev_queued_paths = 0;