about summary refs log tree commit diff
path: root/frida_mode/src/stats/stats.c
diff options
context:
space:
mode:
Diffstat (limited to 'frida_mode/src/stats/stats.c')
-rw-r--r--frida_mode/src/stats/stats.c21
1 files changed, 10 insertions, 11 deletions
diff --git a/frida_mode/src/stats/stats.c b/frida_mode/src/stats/stats.c
index 7972b881..83ecf89a 100644
--- a/frida_mode/src/stats/stats.c
+++ b/frida_mode/src/stats/stats.c
@@ -8,7 +8,6 @@
 #include "frida-gumjs.h"
 
 #include "config.h"
-#include "debug.h"
 #include "util.h"
 
 #include "entry.h"
@@ -324,42 +323,42 @@ static void stats_observer_init(GumStalkerObserver *observer) {
 void stats_config(void) {
 
   stats_filename = getenv("AFL_FRIDA_STATS_FILE");
-  stats_interval = util_read_num("AFL_FRIDA_STATS_INTERVAL");
+  stats_interval = util_read_num("AFL_FRIDA_STATS_INTERVAL", 10);
 
 }
 
 void stats_init(void) {
 
-  OKF("Stats - file [%s]", stats_filename);
-  OKF("Stats - interval [%" G_GINT64_MODIFIER "u]", stats_interval);
+  FOKF("Stats - file [%s]", stats_filename);
+  FOKF("Stats - interval [%" G_GINT64_MODIFIER "u]", stats_interval);
 
-  if (stats_interval != 0 && stats_filename == NULL) {
+  if (getenv("AFL_FRIDA_STATS_INTERVAL") != NULL &&
+      getenv("AFL_FRIDA_STATS_FILE") == NULL) {
 
-    FATAL(
+    FFATAL(
         "AFL_FRIDA_STATS_FILE must be specified if "
         "AFL_FRIDA_STATS_INTERVAL is");
 
   }
 
-  if (stats_interval == 0) { stats_interval = 10; }
   stats_interval_us = stats_interval * MICRO_TO_SEC;
 
   if (stats_filename == NULL) { return; }
 
   char *path = g_canonicalize_filename(stats_filename, g_get_current_dir());
 
-  OKF("Stats - path [%s]", path);
+  FOKF("Stats - path [%s]", path);
 
   stats_fd = open(path, O_RDWR | O_CREAT | O_TRUNC,
                   S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP);
 
-  if (stats_fd < 0) { FATAL("Failed to open stats file '%s'", path); }
+  if (stats_fd < 0) { FFATAL("Failed to open stats file '%s'", path); }
 
   g_free(path);
 
   int shm_id =
       shmget(IPC_PRIVATE, sizeof(stats_data_t), IPC_CREAT | IPC_EXCL | 0600);
-  if (shm_id < 0) { FATAL("shm_id < 0 - errno: %d\n", errno); }
+  if (shm_id < 0) { FFATAL("shm_id < 0 - errno: %d\n", errno); }
 
   stats_data = shmat(shm_id, NULL, 0);
   g_assert(stats_data != MAP_FAILED);
@@ -372,7 +371,7 @@ void stats_init(void) {
    */
   if (shmctl(shm_id, IPC_RMID, NULL) < 0) {
 
-    FATAL("shmctl (IPC_RMID) < 0 - errno: %d\n", errno);
+    FFATAL("shmctl (IPC_RMID) < 0 - errno: %d\n", errno);
 
   }