diff options
Diffstat (limited to 'frida_mode/src/stats')
-rw-r--r-- | frida_mode/src/stats/stats.c | 40 | ||||
-rw-r--r-- | frida_mode/src/stats/stats_arm.c | 36 | ||||
-rw-r--r-- | frida_mode/src/stats/stats_arm64.c | 2 | ||||
-rw-r--r-- | frida_mode/src/stats/stats_x64.c | 20 | ||||
-rw-r--r-- | frida_mode/src/stats/stats_x86.c | 2 |
5 files changed, 56 insertions, 44 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(); + } diff --git a/frida_mode/src/stats/stats_arm.c b/frida_mode/src/stats/stats_arm.c new file mode 100644 index 00000000..7eea7f91 --- /dev/null +++ b/frida_mode/src/stats/stats_arm.c @@ -0,0 +1,36 @@ +#include "frida-gum.h" + +#include "debug.h" + +#include "stats.h" +#include "util.h" + +#if defined(__arm__) + +gboolean stats_is_supported_arch(void) { + + return FALSE; + +} + +size_t stats_data_size_arch(void) { + + FATAL("Stats not supported on this architecture"); + +} + +void stats_write_arch(void) { + + FATAL("Stats not supported on this architecture"); + +} + +void stats_collect_arch(const cs_insn *instr) { + + UNUSED_PARAMETER(instr); + FATAL("Stats not supported on this architecture"); + +} + +#endif + diff --git a/frida_mode/src/stats/stats_arm64.c b/frida_mode/src/stats/stats_arm64.c index d9d374a4..592af87a 100644 --- a/frida_mode/src/stats/stats_arm64.c +++ b/frida_mode/src/stats/stats_arm64.c @@ -1,4 +1,4 @@ -#include "frida-gumjs.h" +#include "frida-gum.h" #include "debug.h" diff --git a/frida_mode/src/stats/stats_x64.c b/frida_mode/src/stats/stats_x64.c index 11464a2a..c3e8742a 100644 --- a/frida_mode/src/stats/stats_x64.c +++ b/frida_mode/src/stats/stats_x64.c @@ -1,4 +1,4 @@ -#include "frida-gumjs.h" +#include "frida-gum.h" #include "debug.h" @@ -31,9 +31,6 @@ typedef struct { guint64 num_rip_relative; - guint64 num_rip_relative_type[X86_INS_ENDING]; - char name_rip_relative_type[X86_INS_ENDING][CS_MNEMONIC_SIZE]; - } stats_data_arch_t; gboolean stats_is_supported_arch(void) { @@ -139,18 +136,6 @@ void stats_write_arch(void) { stats_data_arch->num_rip_relative, (stats_data_arch->num_rip_relative * 100 / num_instructions)); - for (size_t i = 0; i < X86_INS_ENDING; i++) { - - if (stats_data_arch->num_rip_relative_type[i] != 0) { - - stats_print(" %10d %s\n", - stats_data_arch->num_rip_relative_type[i], - stats_data_arch->name_rip_relative_type[i]); - - } - - } - stats_print("\n"); stats_print("\n"); @@ -271,9 +256,6 @@ static void stats_collect_rip_relative_arch(const cs_insn *instr) { if (rm != 5) { return; } stats_data_arch->num_rip_relative++; - stats_data_arch->num_rip_relative_type[instr->id]++; - memcpy(stats_data_arch->name_rip_relative_type[instr->id], instr->mnemonic, - CS_MNEMONIC_SIZE); } diff --git a/frida_mode/src/stats/stats_x86.c b/frida_mode/src/stats/stats_x86.c index d9c4f652..1906e809 100644 --- a/frida_mode/src/stats/stats_x86.c +++ b/frida_mode/src/stats/stats_x86.c @@ -1,4 +1,4 @@ -#include "frida-gumjs.h" +#include "frida-gum.h" #include "debug.h" |