summaryrefslogtreecommitdiff
path: root/plugins/devdbg
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/devdbg')
-rw-r--r--plugins/devdbg/Makefile.am12
-rw-r--r--plugins/devdbg/speed.c121
-rw-r--r--plugins/devdbg/speed.h63
3 files changed, 196 insertions, 0 deletions
diff --git a/plugins/devdbg/Makefile.am b/plugins/devdbg/Makefile.am
new file mode 100644
index 0000000..bd686d3
--- /dev/null
+++ b/plugins/devdbg/Makefile.am
@@ -0,0 +1,12 @@
+
+lib_LTLIBRARIES = libspeed.la
+
+libspeed_la_SOURCES = \
+ speed.h speed.c
+
+libspeed_la_CFLAGS = $(AM_CFLAGS)
+
+
+AM_CPPFLAGS = $(LIBGTK_CFLAGS) $(LIBXML_CFLAGS) -I../../src
+
+AM_CFLAGS = $(DEBUG_CFLAGS) $(WARNING_FLAGS) $(COMPLIANCE_FLAGS)
diff --git a/plugins/devdbg/speed.c b/plugins/devdbg/speed.c
new file mode 100644
index 0000000..7f9705d
--- /dev/null
+++ b/plugins/devdbg/speed.c
@@ -0,0 +1,121 @@
+
+/* Chrysalide - Outil d'analyse de fichiers binaires
+ * speed.c - mesure de temps d'exécution internes
+ *
+ * Copyright (C) 2015 Cyrille Bagard
+ *
+ * This file is part of Chrysalide.
+ *
+ * OpenIDA is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * OpenIDA is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Foobar. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+
+#include "speed.h"
+
+
+#include <malloc.h>
+#include <time.h>
+#include <sys/time.h>
+#include <sys/resource.h>
+
+
+#include <plugins/plugin-def.h>
+#include <plugins/plugin-int.h>
+
+
+
+DEFINE_CHRYSALIDE_ACTIVE_PLUGIN("Speed Measure", "Tracks to time spent for disassembling code", "0.1.0",
+ PGA_DISASSEMBLY_STARTED, PGA_DISASSEMBLY_ENDED);
+
+
+/* Mémorisation des résultats de chronométrages */
+typedef struct _speed_measure
+{
+ clock_t points[2]; /* Points de mesure successifs */
+ unsigned long usages[2]; /* Taux d'utilisation du CPU */
+
+} speed_measure;
+
+
+
+/******************************************************************************
+* *
+* Paramètres : plugin = greffon à manipuler. *
+* action = type d'action attendue. *
+* binary = binaire dont le contenu est en cours de traitement. *
+* *
+* Description : Exécute une action pendant un désassemblage de binaire. *
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+G_MODULE_EXPORT void process_binary_disassembly(const GPluginModule *plugin, PluginAction action, GLoadedBinary *binary)
+{
+ speed_measure *measure; /* Suivi des progressions */
+
+ void take_measure(clock_t *point, unsigned long *usage)
+ {
+ struct rusage rusage; /* Notification des usages */
+
+ *point = clock();
+
+ getrusage(RUSAGE_THREAD, &rusage);
+
+ *usage = rusage.ru_utime.tv_sec * 1000000 + rusage.ru_utime.tv_usec;
+ *usage += rusage.ru_stime.tv_sec * 1000000 + rusage.ru_stime.tv_usec;
+
+ }
+
+
+ switch (action)
+ {
+ case PGA_DISASSEMBLY_STARTED:
+
+ measure = (speed_measure *)calloc(1, sizeof(speed_measure));
+ g_object_set_data(G_OBJECT(binary), "speed_measure", measure);
+
+ take_measure(&measure->points[0], &measure->usages[0]);
+
+ break;
+
+
+ case PGA_DISASSEMBLY_ENDED:
+
+ measure = (speed_measure *)g_object_get_data(G_OBJECT(binary), "speed_measure");
+
+ take_measure(&measure->points[1], &measure->usages[1]);
+
+#define SHOW_SPEED(pg, sm, title, p0, p1) \
+ g_plugin_module_log_variadic_message(pg, LMT_INFO, title " : %.2g (%.2g)", \
+ (double)(sm->points[p1] - sm->points[p0]) / CLOCKS_PER_SEC, \
+ (sm->usages[p1] - sm->usages[p0]) / 1000000.0);
+
+ SHOW_SPEED(plugin, measure, "Whole elapsed time for disassembly", 0, 1);
+
+ g_object_set_data(G_OBJECT(binary), "speed_measure", NULL);
+ free(measure);
+
+ break;
+
+ default:
+ break;
+
+ }
+
+ printf("##########\n\nPassage 0x%08x !!!\n\n################\n", action);
+
+}
diff --git a/plugins/devdbg/speed.h b/plugins/devdbg/speed.h
new file mode 100644
index 0000000..bad7ba5
--- /dev/null
+++ b/plugins/devdbg/speed.h
@@ -0,0 +1,63 @@
+
+/* Chrysalide - Outil d'analyse de fichiers binaires
+ * speed.h - prototypes pour la mesure de temps d'exécution internes
+ *
+ * Copyright (C) 2015 Cyrille Bagard
+ *
+ * This file is part of Chrysalide.
+ *
+ * OpenIDA is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * OpenIDA is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Foobar. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+
+#ifndef _PLUGINS_DEVDBG_SPEED_H
+#define _PLUGINS_DEVDBG_SPEED_H
+
+
+#include <gmodule.h>
+
+#include <analysis/binary.h>
+#include <plugins/plugin.h>
+#include <plugins/plugin-def.h>
+
+
+
+
+/* Exécute une action pendant un désassemblage de binaire. */
+G_MODULE_EXPORT void process_binary_disassembly(const GPluginModule *, PluginAction , GLoadedBinary *);
+
+
+
+
+
+#if 0
+#include <glib-object.h>
+#include <gmodule.h>
+#include <stdbool.h>
+
+
+
+
+/* Initialise le greffon pour les bornes de routine. */
+G_MODULE_EXPORT bool init_plugin(GObject *);
+
+/* Fournit une indication sur le type d'opération(s) menée(s). */
+G_MODULE_EXPORT PluginAction get_plugin_action(void);
+
+/* Exécute une action définie sur un binaire chargé. */
+G_MODULE_EXPORT bool execute_action_on_binary(GLoadedBinary *, PluginAction);
+#endif
+
+
+#endif /* _PLUGINS_DEVDBG_SPEED_H */