summaryrefslogtreecommitdiff
path: root/tools/d2c/hooks/manager.c
diff options
context:
space:
mode:
Diffstat (limited to 'tools/d2c/hooks/manager.c')
-rw-r--r--tools/d2c/hooks/manager.c78
1 files changed, 30 insertions, 48 deletions
diff --git a/tools/d2c/hooks/manager.c b/tools/d2c/hooks/manager.c
index dc70c0c..35d6eba 100644
--- a/tools/d2c/hooks/manager.c
+++ b/tools/d2c/hooks/manager.c
@@ -24,6 +24,7 @@
#include "manager.h"
+#include <assert.h>
#include <malloc.h>
#include <string.h>
@@ -134,9 +135,32 @@ void register_hook_function(instr_hooks *hooks, char *type, char *name)
/******************************************************************************
* *
* Paramètres : hooks = gestionnaire d'un ensemble de fonctions associées. *
+* *
+* Description : Indique si des décrochages sont définis. *
+* *
+* Retour : Bilan de la consultation. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+bool has_hook_functions(const instr_hooks *hooks)
+{
+ bool result; /* Bilan à retourner */
+
+ result = (hooks->func_count > 0);
+
+ return result;
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : hooks = gestionnaire d'un ensemble de fonctions associées. *
* fd = descripteur d'un flux ouvert en écriture. *
* *
-* Description : Déclare des opérations complémentaires pour une instruction. *
+* Description : Imprime une liste de décrochages spécifiés. *
* *
* Retour : Bilan de l'opération. *
* *
@@ -144,7 +168,7 @@ void register_hook_function(instr_hooks *hooks, char *type, char *name)
* *
******************************************************************************/
-bool declare_hook_functions(const instr_hooks *hooks, int fd)
+bool write_hook_functions(const instr_hooks *hooks, int fd)
{
bool result; /* Bilan à retourner */
size_t i; /* Boucle de parcours #1 */
@@ -173,55 +197,13 @@ bool declare_hook_functions(const instr_hooks *hooks, int fd)
result = true;
- if (hooks->func_count > 0)
- {
- dprintf(fd, "\tstatic const instr_hook_fc hooks[IPH_COUNT] = {\n\n");
-
- for (i = 0; i < (sizeof(hook_types) / sizeof(hook_types[0])); i++)
- {
- func = find_hook_by_name(hooks, hook_types[i]);
-
- dprintf(fd, "\t\t[IPH_%s] = (instr_hook_fc)%s,\n", hook_types[i], func != NULL ? func->name : "NULL");
-
- }
-
- dprintf(fd, "\n");
-
- dprintf(fd, "\t};\n");
-
- dprintf(fd, "\n");
-
- }
-
- return result;
-
-}
-
-
-/******************************************************************************
-* *
-* Paramètres : hooks = gestionnaire d'un ensemble de fonctions associées. *
-* fd = descripteur d'un flux ouvert en écriture. *
-* *
-* Description : Associe dans le code des fonctions à une instruction. *
-* *
-* Retour : Bilan de l'opération. *
-* *
-* Remarques : - *
-* *
-******************************************************************************/
-
-bool write_hook_functions(const instr_hooks *hooks, int fd)
-{
- bool result; /* Bilan à retourner */
-
- result = true;
+ assert(has_hook_functions(hooks));
- if (hooks->func_count > 0)
+ for (i = 0; i < (sizeof(hook_types) / sizeof(hook_types[0])); i++)
{
- dprintf(fd, "\tg_arch_instruction_set_hooks(result, hooks);\n");
+ func = find_hook_by_name(hooks, hook_types[i]);
- dprintf(fd, "\n");
+ dprintf(fd, "\t\t[IPH_%s] = (instr_hook_fc)%s,\n", hook_types[i], func != NULL ? func->name : "NULL");
}