diff options
Diffstat (limited to 'frida_mode/src/stats/stats.c')
-rw-r--r-- | frida_mode/src/stats/stats.c | 40 |
1 files changed, 17 insertions, 23 deletions
diff --git a/frida_mode/src/stats/stats.c b/frida_mode/src/stats/stats.c index 91a58741..662fb6d5 100644 --- a/frida_mode/src/stats/stats.c +++ b/frida_mode/src/stats/stats.c @@ -5,7 +5,7 @@ #include <sys/shm.h> #include <sys/mman.h> -#include "frida-gumjs.h" +#include "frida-gum.h" #include "config.h" #include "debug.h" @@ -17,16 +17,15 @@ stats_data_header_t *stats_data = NULL; -static int stats_parent_pid = -1; -static int stats_fd = -1; +static int stats_parent_pid = -1; +static int stats_fd = -1; +static gboolean stats_transitions = FALSE; +static guint64 stats_interval = 0; -char * stats_filename = NULL; -guint64 stats_interval = 0; -gboolean stats_transitions = FALSE; - -void stats_config(void) { +void stats_init(void) { - stats_filename = getenv("AFL_FRIDA_STATS_FILE"); + stats_parent_pid = getpid(); + char *filename = getenv("AFL_FRIDA_STATS_FILE"); stats_interval = util_read_num("AFL_FRIDA_STATS_INTERVAL"); if (getenv("AFL_FRIDA_STATS_TRANSITIONS") != NULL) { @@ -34,16 +33,10 @@ void stats_config(void) { } -} - -void stats_init(void) { - - stats_parent_pid = getpid(); - - OKF("Stats - file [%s]", stats_filename); + OKF("Stats - file [%s]", filename); OKF("Stats - interval [%" G_GINT64_MODIFIER "u]", stats_interval); - if (stats_interval != 0 && stats_filename == NULL) { + if (stats_interval != 0 && filename == NULL) { FATAL( "AFL_FRIDA_STATS_FILE must be specified if " @@ -53,7 +46,7 @@ void stats_init(void) { if (stats_interval == 0) { stats_interval = 10; } - if (stats_filename == NULL) { return; } + if (filename == NULL) { return; } if (!stats_is_supported_arch()) { @@ -63,11 +56,11 @@ void stats_init(void) { char *path = NULL; - if (stats_filename == NULL) { return; } + if (filename == NULL) { return; } if (stats_transitions) { gum_stalker_set_counters_enabled(TRUE); } - path = g_canonicalize_filename(stats_filename, g_get_current_dir()); + path = g_canonicalize_filename(filename, g_get_current_dir()); OKF("Stats - path [%s]", path); @@ -103,6 +96,7 @@ void stats_init(void) { void stats_vprint(int fd, char *format, va_list ap) { char buffer[4096] = {0}; + int ret; int len; if (vsnprintf(buffer, sizeof(buffer) - 1, format, ap) < 0) { return; } @@ -178,12 +172,10 @@ void stats_write(void) { } -void stats_on_fork(void) { +static void stats_maybe_write(void) { guint64 current_time; - if (stats_filename == NULL) { return; } - if (stats_interval == 0) { return; } current_time = g_get_monotonic_time(); @@ -210,5 +202,7 @@ void stats_collect(const cs_insn *instr, gboolean begin) { stats_collect_arch(instr); + stats_maybe_write(); + } |