diff options
Diffstat (limited to 'src/arch')
54 files changed, 161 insertions, 4907 deletions
diff --git a/src/arch/Makefile.am b/src/arch/Makefile.am index 58474d7..0c0a901 100644 --- a/src/arch/Makefile.am +++ b/src/arch/Makefile.am @@ -31,8 +31,7 @@ libarch_la_SOURCES =					\  libarch_la_LIBADD =						\  	arm/libarcharm.la					\ -	dalvik/libarchdalvik.la				\ -	sharing/libarchsharing.la +	dalvik/libarchdalvik.la  libarch_la_LDFLAGS =  @@ -43,4 +42,4 @@ AM_CFLAGS = $(DEBUG_CFLAGS) $(WARNING_FLAGS) $(COMPLIANCE_FLAGS)  #SUBDIRS = arm dalvik jvm mips x86 -SUBDIRS = arm dalvik sharing +SUBDIRS = arm dalvik diff --git a/src/arch/arm/v7/core.c b/src/arch/arm/v7/core.c index ee43366..a2d0e45 100644 --- a/src/arch/arm/v7/core.c +++ b/src/arch/arm/v7/core.c @@ -24,17 +24,6 @@  #include "core.h" -#include "register.h" -#include "operands/coproc.h" -#include "operands/estate.h" -#include "operands/limitation.h" -#include "operands/maccess.h" -#include "operands/offset.h" -#include "operands/reglist.h" -#include "operands/rotation.h" -#include "operands/shift.h" - -  /******************************************************************************  *                                                                             * @@ -52,31 +41,7 @@ bool init_armv7_core(void)  {      bool result;                            /* Bilan à renvoyer            */ -    result = init_armv7_register_sharing(); - -    if (result) -        result = init_armv7_coproc_operand_sharing(); - -    if (result) -        result = init_armv7_endian_operand_sharing(); - -    if (result) -        result = init_armv7_limitation_operand_sharing(); - -    if (result) -        result = init_armv7_maccess_operand_sharing(); - -    if (result) -        result = init_armv7_offset_operand_sharing(); - -    if (result) -        result = init_armv7_reglist_operand_sharing(); - -    if (result) -        result = init_armv7_rotation_operand_sharing(); - -    if (result) -        result = init_armv7_shift_operand_sharing(); +    result = true;      return result; @@ -87,35 +52,6 @@ bool init_armv7_core(void)  *                                                                             *  *  Paramètres  : -                                                            *  *                                                                             * -*  Description : Imprime des statistiques quant aux partages dans l'archi.    * -*                                                                             * -*  Retour      : -                                                            * -*                                                                             * -*  Remarques   : -                                                            * -*                                                                             * -******************************************************************************/ -#ifdef DEBUG_DUMP_STATS -void dump_armv7_share_stats(void) -{ -    dump_armv7_register_share_stats(); - -    dump_armv7_coproc_operand_share_stats(); -    dump_armv7_endian_operand_share_stats(); -    dump_armv7_limitation_operand_share_stats(); -    dump_armv7_maccess_operand_share_stats(); -    dump_armv7_offset_operand_share_stats(); -    dump_armv7_reglist_operand_share_stats(); -    dump_armv7_rotation_operand_share_stats(); -    dump_armv7_shift_operand_share_stats(); - -} -#endif - - -/****************************************************************************** -*                                                                             * -*  Paramètres  : -                                                            * -*                                                                             *  *  Description : Supprime les mécanismes internes de l'architecture ARMv7.    *  *                                                                             *  *  Retour      : -                                                            * @@ -126,15 +62,5 @@ void dump_armv7_share_stats(void)  void exit_armv7_core(void)  { -    exit_armv7_register_sharing(); - -    exit_armv7_coproc_operand_sharing(); -    exit_armv7_endian_operand_sharing(); -    exit_armv7_limitation_operand_sharing(); -    exit_armv7_maccess_operand_sharing(); -    exit_armv7_offset_operand_sharing(); -    exit_armv7_reglist_operand_sharing(); -    exit_armv7_rotation_operand_sharing(); -    exit_armv7_shift_operand_sharing();  } diff --git a/src/arch/arm/v7/core.h b/src/arch/arm/v7/core.h index e33ae03..b4c254f 100644 --- a/src/arch/arm/v7/core.h +++ b/src/arch/arm/v7/core.h @@ -32,11 +32,6 @@  /* Met en place les mécanismes internes de l'architecture ARMv7. */  bool init_armv7_core(void); -/* Imprime des statistiques quant aux partages dans l'archi. */ -#ifdef DEBUG_DUMP_STATS -void dump_armv7_share_stats(void); -#endif -  /* Supprime les mécanismes internes de l'architecture ARMv7. */  void exit_armv7_core(void); diff --git a/src/arch/arm/v7/fetch.c b/src/arch/arm/v7/fetch.c index 788d7ab..929c877 100644 --- a/src/arch/arm/v7/fetch.c +++ b/src/arch/arm/v7/fetch.c @@ -34,7 +34,6 @@  #include "operands/offset.h"  #include "../register.h"  #include "../../raw.h" -#include "../../sharing/container.h"  #include "../../../format/format.h"  #include "../../../format/preload.h" @@ -91,7 +90,7 @@ void help_fetching_with_instruction_b_with_orig(GArchInstruction *instr, GArchPr      op = G_IMM_OPERAND(g_arch_instruction_get_operand(instr, 0));      if (g_imm_operand_get_value(op, MDS_32_BITS_SIGNED, &offset)) -        g_imm_operand_set_value(&op, MDS_32_BITS_UNSIGNED, pc + offset, G_SHARE_CONTAINER(instr)); +        g_imm_operand_set_value(op, MDS_32_BITS_UNSIGNED, pc + offset);      else assert(0); @@ -154,7 +153,7 @@ void help_fetching_with_instruction_bl_with_orig(GArchInstruction *instr, GArchP      op = G_IMM_OPERAND(g_arch_instruction_get_operand(instr, 0));      if (g_imm_operand_get_value(op, MDS_32_BITS_SIGNED, &offset)) -        g_imm_operand_set_value(&op, MDS_32_BITS_UNSIGNED, pc + offset, G_SHARE_CONTAINER(instr)); +        g_imm_operand_set_value(op, MDS_32_BITS_UNSIGNED, pc + offset);      else assert(0); @@ -207,7 +206,7 @@ void help_fetching_with_instruction_blx_with_dest(GArchInstruction *instr, GArch      op = G_IMM_OPERAND(g_arch_instruction_get_operand(instr, 0));      if (g_imm_operand_get_value(op, MDS_32_BITS_SIGNED, &offset)) -        g_imm_operand_set_value(&op, MDS_32_BITS_UNSIGNED, pc + offset, G_SHARE_CONTAINER(instr)); +        g_imm_operand_set_value(op, MDS_32_BITS_UNSIGNED, pc + offset);      else assert(0); @@ -326,7 +325,7 @@ void help_fetching_with_instruction_cb_n_z(GArchInstruction *instr, GArchProcess      op = G_IMM_OPERAND(g_arch_instruction_get_operand(instr, 1));      if (g_imm_operand_get_value(op, MDS_32_BITS_UNSIGNED, &offset)) -        g_imm_operand_set_value(&op, MDS_32_BITS_UNSIGNED, pc + offset, G_SHARE_CONTAINER(instr)); +        g_imm_operand_set_value(op, MDS_32_BITS_UNSIGNED, pc + offset);      else assert(0); diff --git a/src/arch/arm/v7/operands/coproc.c b/src/arch/arm/v7/operands/coproc.c index ff34943..a0c0254 100644 --- a/src/arch/arm/v7/operands/coproc.c +++ b/src/arch/arm/v7/operands/coproc.c @@ -25,14 +25,10 @@  #include "../../../operand-int.h" -#include "../../../sharing/manager.h"  #include "../../../../common/sort.h" -/* --------------------- MANIPULATION D'OPERANDES INDIVIDUELLES --------------------- */ - -  /* Définition d'un opérande représentant un co-processeur (instance) */  struct _GArmV7CoprocOperand  { @@ -63,9 +59,6 @@ static void g_armv7_coproc_operand_dispose(GArmV7CoprocOperand *);  /* Procède à la libération totale de la mémoire. */  static void g_armv7_coproc_operand_finalize(GArmV7CoprocOperand *); -/* Réalise une copie minimale d'un contenu partagé. */ -static void g_armv7_coproc_operand_define_template(const GArmV7CoprocOperand *, GArmV7CoprocOperand *); -  /* Compare un opérande avec un autre. */  static int g_armv7_coproc_operand_compare(const GArmV7CoprocOperand *, const GArmV7CoprocOperand *); @@ -74,23 +67,6 @@ static void g_armv7_coproc_operand_print(const GArmV7CoprocOperand *, GBufferLin -/* -------------------------- PARTAGES DE CONTENUS UNIQUES -------------------------- */ - - -/* Gestionnaire des partages d'instances */ -static GShareManager *_armv7_coproc_operand_manager = NULL; - - -/* Fournit le gestionnaire de partages attribué à un type. */ -static GShareManager *get_armv7_coproc_operand_share_manager(void); - - - -/* ---------------------------------------------------------------------------------- */ -/*                       MANIPULATION D'OPERANDES INDIVIDUELLES                       */ -/* ---------------------------------------------------------------------------------- */ - -  /* Indique le type défini par la GLib pour un co-processeur ARM. */  G_DEFINE_TYPE(GArmV7CoprocOperand, g_armv7_coproc_operand, G_TYPE_ARCH_OPERAND); @@ -118,12 +94,6 @@ static void g_armv7_coproc_operand_class_init(GArmV7CoprocOperandClass *klass)      object->dispose = (GObjectFinalizeFunc/* ! */)g_armv7_coproc_operand_dispose;      object->finalize = (GObjectFinalizeFunc)g_armv7_coproc_operand_finalize; -    operand->get_manager = (get_operand_manager_fc)get_armv7_coproc_operand_share_manager; - -    operand->apply_template = (apply_operand_template_fc)NULL; -    operand->define_template = (define_operand_template_fc)g_armv7_coproc_operand_define_template; -    operand->free_template = (free_operand_template_fc)NULL; -      operand->compare = (operand_compare_fc)g_armv7_coproc_operand_compare;      operand->print = (operand_print_fc)g_armv7_coproc_operand_print; @@ -188,26 +158,6 @@ static void g_armv7_coproc_operand_finalize(GArmV7CoprocOperand *operand)  /******************************************************************************  *                                                                             * -*  Paramètres  : operand  = objet partagé à consulter.                        * -*                template = informations à retrouver intégralement.           * -*                                                                             * -*  Description : Réalise une copie minimale d'un contenu partagé.             * -*                                                                             * -*  Retour      : -                                                            * -*                                                                             * -*  Remarques   : -                                                            * -*                                                                             * -******************************************************************************/ - -static void g_armv7_coproc_operand_define_template(const GArmV7CoprocOperand *operand, GArmV7CoprocOperand *template) -{ -    template->index = operand->index; - -} - - -/****************************************************************************** -*                                                                             *  *  Paramètres  : a = premier opérande à consulter.                            *  *                b = second opérande à consulter.                             *  *                                                                             * @@ -270,12 +220,11 @@ static void g_armv7_coproc_operand_print(const GArmV7CoprocOperand *operand, GBu  GArchOperand *g_armv7_coproc_operand_new(uint8_t raw)  { -    GSharedInstance *result;                /* Structure à retourner       */ -    GArmV7CoprocOperand template;           /* Transport d'informations    */ +    GArmV7CoprocOperand *result;            /* Structure à retourner       */ -    template.index = raw; +    result = g_object_new(G_TYPE_ARMV7_COPROC_OPERAND, NULL); -    result = g_share_manager_build(_armv7_coproc_operand_manager, (GSharedInstance *)&template); +    result->index = raw;      return G_ARCH_OPERAND(result); @@ -299,88 +248,3 @@ uint8_t g_armv7_coproc_operand_get_index(const GArmV7CoprocOperand *operand)      return operand->index;  } - - - -/* ---------------------------------------------------------------------------------- */ -/*                            PARTAGES DE CONTENUS UNIQUES                            */ -/* ---------------------------------------------------------------------------------- */ - - -/****************************************************************************** -*                                                                             * -*  Paramètres  : -                                                            * -*                                                                             * -*  Description : Fournit le gestionnaire de partages attribué à un type.      * -*                                                                             * -*  Retour      : Gestionnaire de partages en place.                           * -*                                                                             * -*  Remarques   : -                                                            * -*                                                                             * -******************************************************************************/ - -static GShareManager *get_armv7_coproc_operand_share_manager(void) -{ -    return _armv7_coproc_operand_manager; - -} - - -/****************************************************************************** -*                                                                             * -*  Paramètres  : -                                                            * -*                                                                             * -*  Description : Met en place les mécanismes de partage des co-processeurs.   * -*                                                                             * -*  Retour      : Bilan de l'opération.                                        * -*                                                                             * -*  Remarques   : -                                                            * -*                                                                             * -******************************************************************************/ - -bool init_armv7_coproc_operand_sharing(void) -{ -    _armv7_coproc_operand_manager = g_share_manager_new(G_TYPE_ARMV7_COPROC_OPERAND); - -    return true; - -} - - -/****************************************************************************** -*                                                                             * -*  Paramètres  : -                                                            * -*                                                                             * -*  Description : Imprime des statistiques quant aux partages dans l'archi.    * -*                                                                             * -*  Retour      : -                                                            * -*                                                                             * -*  Remarques   : -                                                            * -*                                                                             * -******************************************************************************/ -#ifdef DEBUG_DUMP_STATS -void dump_armv7_coproc_operand_share_stats(void) -{ -    g_share_manager_dump_stats(_armv7_coproc_operand_manager); - -} -#endif - - -/****************************************************************************** -*                                                                             * -*  Paramètres  : -                                                            * -*                                                                             * -*  Description : Supprime les mécanismes de partage des co-processeurs.       * -*                                                                             * -*  Retour      : -                                                            * -*                                                                             * -*  Remarques   : -                                                            * -*                                                                             * -******************************************************************************/ - -void exit_armv7_coproc_operand_sharing(void) -{ -    g_object_unref(G_OBJECT(_armv7_coproc_operand_manager)); - -} diff --git a/src/arch/arm/v7/operands/coproc.h b/src/arch/arm/v7/operands/coproc.h index 241db19..07224d3 100644 --- a/src/arch/arm/v7/operands/coproc.h +++ b/src/arch/arm/v7/operands/coproc.h @@ -32,9 +32,6 @@ -/* --------------------- MANIPULATION D'OPERANDES INDIVIDUELLES --------------------- */ - -  #define G_TYPE_ARMV7_COPROC_OPERAND                  g_armv7_coproc_operand_get_type()  #define G_ARMV7_COPROC_OPERAND(obj)                  (G_TYPE_CHECK_INSTANCE_CAST((obj), g_armv7_coproc_operand_get_type(), GArmV7CoprocOperand))  #define G_IS_ARMV7_COPROC_OPERAND(obj)               (G_TYPE_CHECK_INSTANCE_TYPE((obj), g_armv7_coproc_operand_get_type())) @@ -61,20 +58,4 @@ uint8_t g_armv7_coproc_operand_get_index(const GArmV7CoprocOperand *); -/* -------------------------- PARTAGES DE CONTENUS UNIQUES -------------------------- */ - - -/* Met en place les mécanismes de partage des co-processeurs. */ -bool init_armv7_coproc_operand_sharing(void); - -/* Imprime des statistiques quant aux partages dans l'archi. */ -#ifdef DEBUG_DUMP_STATS -void dump_armv7_coproc_operand_share_stats(void); -#endif - -/* Supprime les mécanismes de partage des co-processeurs. */ -void exit_armv7_coproc_operand_sharing(void); - - -  #endif  /* _ARCH_ARM_V7_OPERANDS_COPROC_H */ diff --git a/src/arch/arm/v7/operands/estate.c b/src/arch/arm/v7/operands/estate.c index 25c60ab..0756110 100644 --- a/src/arch/arm/v7/operands/estate.c +++ b/src/arch/arm/v7/operands/estate.c @@ -25,14 +25,10 @@  #include "../../../operand-int.h" -#include "../../../sharing/manager.h"  #include "../../../../common/sort.h" -/* --------------------- MANIPULATION D'OPERANDES INDIVIDUELLES --------------------- */ - -  /* Définition d'un opérande affichant le choix d'un boutisme (instance) */  struct _GArmV7EndianOperand  { @@ -63,9 +59,6 @@ static void g_armv7_endian_operand_dispose(GArmV7EndianOperand *);  /* Procède à la libération totale de la mémoire. */  static void g_armv7_endian_operand_finalize(GArmV7EndianOperand *); -/* Réalise une copie minimale d'un contenu partagé. */ -static void g_armv7_endian_operand_define_template(const GArmV7EndianOperand *, GArmV7EndianOperand *); -  /* Compare un opérande avec un autre. */  static int g_armv7_endian_operand_compare(const GArmV7EndianOperand *, const GArmV7EndianOperand *); @@ -74,23 +67,6 @@ static void g_armv7_endian_operand_print(const GArmV7EndianOperand *, GBufferLin -/* -------------------------- PARTAGES DE CONTENUS UNIQUES -------------------------- */ - - -/* Gestionnaire des partages d'instances */ -static GShareManager *_armv7_endian_operand_manager = NULL; - - -/* Fournit le gestionnaire de partages attribué à un type. */ -static GShareManager *get_armv7_endian_operand_share_manager(void); - - - -/* ---------------------------------------------------------------------------------- */ -/*                       MANIPULATION D'OPERANDES INDIVIDUELLES                       */ -/* ---------------------------------------------------------------------------------- */ - -  /* Indique le type défini par la GLib pour une endian de domaine et d'accès. */  G_DEFINE_TYPE(GArmV7EndianOperand, g_armv7_endian_operand, G_TYPE_ARCH_OPERAND); @@ -118,12 +94,6 @@ static void g_armv7_endian_operand_class_init(GArmV7EndianOperandClass *klass)      object->dispose = (GObjectFinalizeFunc/* ! */)g_armv7_endian_operand_dispose;      object->finalize = (GObjectFinalizeFunc)g_armv7_endian_operand_finalize; -    operand->get_manager = (get_operand_manager_fc)get_armv7_endian_operand_share_manager; - -    operand->apply_template = (apply_operand_template_fc)NULL; -    operand->define_template = (define_operand_template_fc)g_armv7_endian_operand_define_template; -    operand->free_template = (free_operand_template_fc)NULL; -      operand->compare = (operand_compare_fc)g_armv7_endian_operand_compare;      operand->print = (operand_print_fc)g_armv7_endian_operand_print; @@ -188,26 +158,6 @@ static void g_armv7_endian_operand_finalize(GArmV7EndianOperand *operand)  /******************************************************************************  *                                                                             * -*  Paramètres  : operand  = objet partagé à consulter.                        * -*                template = informations à retrouver intégralement.           * -*                                                                             * -*  Description : Réalise une copie minimale d'un contenu partagé.             * -*                                                                             * -*  Retour      : -                                                            * -*                                                                             * -*  Remarques   : -                                                            * -*                                                                             * -******************************************************************************/ - -static void g_armv7_endian_operand_define_template(const GArmV7EndianOperand *operand, GArmV7EndianOperand *template) -{ -    template->big = operand->big; - -} - - -/****************************************************************************** -*                                                                             *  *  Paramètres  : a = premier opérande à consulter.                            *  *                b = second opérande à consulter.                             *  *                                                                             * @@ -268,12 +218,11 @@ static void g_armv7_endian_operand_print(const GArmV7EndianOperand *operand, GBu  GArchOperand *g_armv7_endian_operand_new(bool big)  { -    GSharedInstance *result;                /* Structure à retourner       */ -    GArmV7EndianOperand template;           /* Transport d'informations    */ +    GArmV7EndianOperand *result;            /* Structure à retourner       */ -    template.big = big; +    result = g_object_new(G_TYPE_ARMV7_ENDIAN_OPERAND, NULL); -    result = g_share_manager_build(_armv7_endian_operand_manager, (GSharedInstance *)&template); +    result->big = big;      return G_ARCH_OPERAND(result); @@ -297,88 +246,3 @@ bool g_armv7_endian_operand_is_big_endian(const GArmV7EndianOperand *operand)      return operand->big;  } - - - -/* ---------------------------------------------------------------------------------- */ -/*                            PARTAGES DE CONTENUS UNIQUES                            */ -/* ---------------------------------------------------------------------------------- */ - - -/****************************************************************************** -*                                                                             * -*  Paramètres  : -                                                            * -*                                                                             * -*  Description : Fournit le gestionnaire de partages attribué à un type.      * -*                                                                             * -*  Retour      : Gestionnaire de partages en place.                           * -*                                                                             * -*  Remarques   : -                                                            * -*                                                                             * -******************************************************************************/ - -static GShareManager *get_armv7_endian_operand_share_manager(void) -{ -    return _armv7_endian_operand_manager; - -} - - -/****************************************************************************** -*                                                                             * -*  Paramètres  : -                                                            * -*                                                                             * -*  Description : Met en place les mécanismes de partage des états de boutisme.* -*                                                                             * -*  Retour      : Bilan de l'opération.                                        * -*                                                                             * -*  Remarques   : -                                                            * -*                                                                             * -******************************************************************************/ - -bool init_armv7_endian_operand_sharing(void) -{ -    _armv7_endian_operand_manager = g_share_manager_new(G_TYPE_ARMV7_ENDIAN_OPERAND); - -    return true; - -} - - -/****************************************************************************** -*                                                                             * -*  Paramètres  : -                                                            * -*                                                                             * -*  Description : Imprime des statistiques quant aux partages dans l'archi.    * -*                                                                             * -*  Retour      : -                                                            * -*                                                                             * -*  Remarques   : -                                                            * -*                                                                             * -******************************************************************************/ -#ifdef DEBUG_DUMP_STATS -void dump_armv7_endian_operand_share_stats(void) -{ -    g_share_manager_dump_stats(_armv7_endian_operand_manager); - -} -#endif - - -/****************************************************************************** -*                                                                             * -*  Paramètres  : -                                                            * -*                                                                             * -*  Description : Supprime les mécanismes de partage des états de boutisme.    * -*                                                                             * -*  Retour      : -                                                            * -*                                                                             * -*  Remarques   : -                                                            * -*                                                                             * -******************************************************************************/ - -void exit_armv7_endian_operand_sharing(void) -{ -    g_object_unref(G_OBJECT(_armv7_endian_operand_manager)); - -} diff --git a/src/arch/arm/v7/operands/estate.h b/src/arch/arm/v7/operands/estate.h index 506bcb4..a1726cf 100644 --- a/src/arch/arm/v7/operands/estate.h +++ b/src/arch/arm/v7/operands/estate.h @@ -32,9 +32,6 @@ -/* --------------------- MANIPULATION D'OPERANDES INDIVIDUELLES --------------------- */ - -  #define G_TYPE_ARMV7_ENDIAN_OPERAND             g_armv7_endian_operand_get_type()  #define G_ARMV7_ENDIAN_OPERAND(obj)             (G_TYPE_CHECK_INSTANCE_CAST((obj), g_armv7_endian_operand_get_type(), GArmV7EndianOperand))  #define G_IS_ARMV7_ENDIAN_OPERAND(obj)          (G_TYPE_CHECK_INSTANCE_TYPE((obj), g_armv7_endian_operand_get_type())) @@ -61,20 +58,4 @@ bool g_armv7_endian_operand_is_big_endian(const GArmV7EndianOperand *); -/* -------------------------- PARTAGES DE CONTENUS UNIQUES -------------------------- */ - - -/* Met en place les mécanismes de partage des états de boutisme. */ -bool init_armv7_endian_operand_sharing(void); - -/* Imprime des statistiques quant aux partages dans l'archi. */ -#ifdef DEBUG_DUMP_STATS -void dump_armv7_endian_operand_share_stats(void); -#endif - -/* Supprime les mécanismes de partage des états de boutisme. */ -void exit_armv7_endian_operand_sharing(void); - - -  #endif  /* _ARCH_ARM_V7_OPERANDS_ESTATE_H */ diff --git a/src/arch/arm/v7/operands/limitation.c b/src/arch/arm/v7/operands/limitation.c index a86502c..75e958f 100644 --- a/src/arch/arm/v7/operands/limitation.c +++ b/src/arch/arm/v7/operands/limitation.c @@ -25,14 +25,10 @@  #include "../../../operand-int.h" -#include "../../../sharing/manager.h"  #include "../../../../common/sort.h" -/* --------------------- MANIPULATION D'OPERANDES INDIVIDUELLES --------------------- */ - -  /* Définition d'un opérande déterminant une limitation de domaine et d'accès (instance) */  struct _GArmV7LimitationOperand  { @@ -63,9 +59,6 @@ static void g_armv7_limitation_operand_dispose(GArmV7LimitationOperand *);  /* Procède à la libération totale de la mémoire. */  static void g_armv7_limitation_operand_finalize(GArmV7LimitationOperand *); -/* Réalise une copie minimale d'un contenu partagé. */ -static void g_armv7_limitation_operand_define_template(const GArmV7LimitationOperand *, GArmV7LimitationOperand *); -  /* Compare un opérande avec un autre. */  static int g_armv7_limitation_operand_compare(const GArmV7LimitationOperand *, const GArmV7LimitationOperand *); @@ -74,23 +67,6 @@ static void g_armv7_limitation_operand_print(const GArmV7LimitationOperand *, GB -/* -------------------------- PARTAGES DE CONTENUS UNIQUES -------------------------- */ - - -/* Gestionnaire des partages d'instances */ -static GShareManager *_armv7_limitation_operand_manager = NULL; - - -/* Fournit le gestionnaire de partages attribué à un type. */ -static GShareManager *get_armv7_limitation_operand_share_manager(void); - - - -/* ---------------------------------------------------------------------------------- */ -/*                       MANIPULATION D'OPERANDES INDIVIDUELLES                       */ -/* ---------------------------------------------------------------------------------- */ - -  /* Indique le type défini par la GLib pour une limitation de domaine et d'accès. */  G_DEFINE_TYPE(GArmV7LimitationOperand, g_armv7_limitation_operand, G_TYPE_ARCH_OPERAND); @@ -118,12 +94,6 @@ static void g_armv7_limitation_operand_class_init(GArmV7LimitationOperandClass *      object->dispose = (GObjectFinalizeFunc/* ! */)g_armv7_limitation_operand_dispose;      object->finalize = (GObjectFinalizeFunc)g_armv7_limitation_operand_finalize; -    operand->get_manager = (get_operand_manager_fc)get_armv7_limitation_operand_share_manager; - -    operand->apply_template = (apply_operand_template_fc)NULL; -    operand->define_template = (define_operand_template_fc)g_armv7_limitation_operand_define_template; -    operand->free_template = (free_operand_template_fc)NULL; -      operand->compare = (operand_compare_fc)g_armv7_limitation_operand_compare;      operand->print = (operand_print_fc)g_armv7_limitation_operand_print; @@ -188,26 +158,6 @@ static void g_armv7_limitation_operand_finalize(GArmV7LimitationOperand *operand  /******************************************************************************  *                                                                             * -*  Paramètres  : operand  = objet partagé à consulter.                        * -*                template = informations à retrouver intégralement.           * -*                                                                             * -*  Description : Réalise une copie minimale d'un contenu partagé.             * -*                                                                             * -*  Retour      : -                                                            * -*                                                                             * -*  Remarques   : -                                                            * -*                                                                             * -******************************************************************************/ - -static void g_armv7_limitation_operand_define_template(const GArmV7LimitationOperand *operand, GArmV7LimitationOperand *template) -{ -    template->type = operand->type; - -} - - -/****************************************************************************** -*                                                                             *  *  Paramètres  : a = premier opérande à consulter.                            *  *                b = second opérande à consulter.                             *  *                                                                             * @@ -303,16 +253,15 @@ static void g_armv7_limitation_operand_print(const GArmV7LimitationOperand *oper  GArchOperand *g_armv7_limitation_operand_new(uint8_t raw)  { -    GSharedInstance *result;                /* Structure à retourner       */ -    GArmV7LimitationOperand template;       /* Transport d'informations    */ +    GArmV7LimitationOperand *result;        /* Structure à retourner       */ + +    result = g_object_new(G_TYPE_ARMV7_LIMITATION_OPERAND, NULL);      if (raw < 0b0010 || raw > 0b1111) -        template.type = BLT_RESERVED; +        result->type = BLT_RESERVED;      else -        template.type = raw; - -    result = g_share_manager_build(_armv7_limitation_operand_manager, (GSharedInstance *)&template); +        result->type = raw;      return G_ARCH_OPERAND(result); @@ -336,88 +285,3 @@ BarrierLimitationType g_armv7_limitation_operand_get_value(const GArmV7Limitatio      return operand->type;  } - - - -/* ---------------------------------------------------------------------------------- */ -/*                            PARTAGES DE CONTENUS UNIQUES                            */ -/* ---------------------------------------------------------------------------------- */ - - -/****************************************************************************** -*                                                                             * -*  Paramètres  : -                                                            * -*                                                                             * -*  Description : Fournit le gestionnaire de partages attribué à un type.      * -*                                                                             * -*  Retour      : Gestionnaire de partages en place.                           * -*                                                                             * -*  Remarques   : -                                                            * -*                                                                             * -******************************************************************************/ - -static GShareManager *get_armv7_limitation_operand_share_manager(void) -{ -    return _armv7_limitation_operand_manager; - -} - - -/****************************************************************************** -*                                                                             * -*  Paramètres  : -                                                            * -*                                                                             * -*  Description : Met en place les mécanismes de partage de limites de domaine.* -*                                                                             * -*  Retour      : Bilan de l'opération.                                        * -*                                                                             * -*  Remarques   : -                                                            * -*                                                                             * -******************************************************************************/ - -bool init_armv7_limitation_operand_sharing(void) -{ -    _armv7_limitation_operand_manager = g_share_manager_new(G_TYPE_ARMV7_LIMITATION_OPERAND); - -    return true; - -} - - -/****************************************************************************** -*                                                                             * -*  Paramètres  : -                                                            * -*                                                                             * -*  Description : Imprime des statistiques quant aux partages dans l'archi.    * -*                                                                             * -*  Retour      : -                                                            * -*                                                                             * -*  Remarques   : -                                                            * -*                                                                             * -******************************************************************************/ -#ifdef DEBUG_DUMP_STATS -void dump_armv7_limitation_operand_share_stats(void) -{ -    g_share_manager_dump_stats(_armv7_limitation_operand_manager); - -} -#endif - - -/****************************************************************************** -*                                                                             * -*  Paramètres  : -                                                            * -*                                                                             * -*  Description : Supprime les mécanismes de partage des limites de domaine.   * -*                                                                             * -*  Retour      : -                                                            * -*                                                                             * -*  Remarques   : -                                                            * -*                                                                             * -******************************************************************************/ - -void exit_armv7_limitation_operand_sharing(void) -{ -    g_object_unref(G_OBJECT(_armv7_limitation_operand_manager)); - -} diff --git a/src/arch/arm/v7/operands/limitation.h b/src/arch/arm/v7/operands/limitation.h index 6fc61d2..4f7db88 100644 --- a/src/arch/arm/v7/operands/limitation.h +++ b/src/arch/arm/v7/operands/limitation.h @@ -32,9 +32,6 @@ -/* --------------------- MANIPULATION D'OPERANDES INDIVIDUELLES --------------------- */ - -  #define G_TYPE_ARMV7_LIMITATION_OPERAND                  g_armv7_limitation_operand_get_type()  #define G_ARMV7_LIMITATION_OPERAND(obj)                  (G_TYPE_CHECK_INSTANCE_CAST((obj), g_armv7_limitation_operand_get_type(), GArmV7LimitationOperand))  #define G_IS_ARMV7_LIMITATION_OPERAND(obj)               (G_TYPE_CHECK_INSTANCE_TYPE((obj), g_armv7_limitation_operand_get_type())) @@ -77,20 +74,4 @@ BarrierLimitationType g_armv7_limitation_operand_get_value(const GArmV7Limitatio -/* -------------------------- PARTAGES DE CONTENUS UNIQUES -------------------------- */ - - -/* Met en place les mécanismes de partage de limites de domaine. */ -bool init_armv7_limitation_operand_sharing(void); - -/* Imprime des statistiques quant aux partages dans l'archi. */ -#ifdef DEBUG_DUMP_STATS -void dump_armv7_limitation_operand_share_stats(void); -#endif - -/* Supprime les mécanismes de partage des limites de domaine. */ -void exit_armv7_limitation_operand_sharing(void); - - -  #endif  /* _ARCH_ARM_V7_OPERANDS_LIMITATION_H */ diff --git a/src/arch/arm/v7/operands/maccess.c b/src/arch/arm/v7/operands/maccess.c index 71d55e0..6daf821 100644 --- a/src/arch/arm/v7/operands/maccess.c +++ b/src/arch/arm/v7/operands/maccess.c @@ -25,14 +25,10 @@  #include "../../../operand-int.h" -#include "../../../sharing/manager.h"  #include "../../../../common/sort.h" -/* --------------------- MANIPULATION D'OPERANDES INDIVIDUELLES --------------------- */ - -  /* Définition d'un opérande offrant un accès à la mémoire depuis une base (instance) */  struct _GArmV7MAccessOperand  { @@ -67,12 +63,6 @@ static void g_armv7_maccess_operand_dispose(GArmV7MAccessOperand *);  /* Procède à la libération totale de la mémoire. */  static void g_armv7_maccess_operand_finalize(GArmV7MAccessOperand *); -/* Initialise un nouvel objet partagé avec des informations. */ -static bool g_armv7_maccess_operand_apply_template(GArmV7MAccessOperand *, const GArmV7MAccessOperand *); - -/* Réalise une copie minimale d'un contenu partagé. */ -static void g_armv7_maccess_operand_define_template(const GArmV7MAccessOperand *, GArmV7MAccessOperand *); -  /* Compare un opérande avec un autre. */  static int g_armv7_maccess_operand_compare(const GArmV7MAccessOperand *, const GArmV7MAccessOperand *); @@ -81,23 +71,6 @@ static void g_armv7_maccess_operand_print(const GArmV7MAccessOperand *, GBufferL -/* -------------------------- PARTAGES DE CONTENUS UNIQUES -------------------------- */ - - -/* Gestionnaire des partages d'instances */ -static GShareManager *_armv7_maccess_operand_manager = NULL; - - -/* Fournit le gestionnaire de partages attribué à un type. */ -static GShareManager *get_armv7_maccess_operand_share_manager(void); - - - -/* ---------------------------------------------------------------------------------- */ -/*                       MANIPULATION D'OPERANDES INDIVIDUELLES                       */ -/* ---------------------------------------------------------------------------------- */ - -  /* Indique le type défini par la GLib pour un accès à la mémoire depuis une base. */  G_DEFINE_TYPE(GArmV7MAccessOperand, g_armv7_maccess_operand, G_TYPE_ARCH_OPERAND); @@ -125,12 +98,6 @@ static void g_armv7_maccess_operand_class_init(GArmV7MAccessOperandClass *klass)      object->dispose = (GObjectFinalizeFunc/* ! */)g_armv7_maccess_operand_dispose;      object->finalize = (GObjectFinalizeFunc)g_armv7_maccess_operand_finalize; -    operand->get_manager = (get_operand_manager_fc)get_armv7_maccess_operand_share_manager; - -    operand->apply_template = (apply_operand_template_fc)g_armv7_maccess_operand_apply_template; -    operand->define_template = (define_operand_template_fc)g_armv7_maccess_operand_define_template; -    operand->free_template = (free_operand_template_fc)NULL; -      operand->compare = (operand_compare_fc)g_armv7_maccess_operand_compare;      operand->print = (operand_print_fc)g_armv7_maccess_operand_print; @@ -203,61 +170,6 @@ static void g_armv7_maccess_operand_finalize(GArmV7MAccessOperand *operand)  /******************************************************************************  *                                                                             * -*  Paramètres  : operand  = objet partagé à initialiser.                      * -*                template = information à utiliser pour la mise en place.     * -*                                                                             * -*  Description : Initialise un nouvel objet partagé avec des informations.    * -*                                                                             * -*  Retour      : Bilan de l'opération.                                        * -*                                                                             * -*  Remarques   : -                                                            * -*                                                                             * -******************************************************************************/ - -static bool g_armv7_maccess_operand_apply_template(GArmV7MAccessOperand *operand, const GArmV7MAccessOperand *template) -{ -    g_armv7_maccess_operand_define_template(template, operand); - -    g_object_ref(G_OBJECT(operand->base)); - -    if (operand->offset != NULL) -        g_object_ref(G_OBJECT(operand->offset)); - -    if (operand->shift != NULL) -        g_object_ref(G_OBJECT(operand->shift)); - -    return true; - -} - - -/****************************************************************************** -*                                                                             * -*  Paramètres  : operand  = objet partagé à consulter.                        * -*                template = informations à retrouver intégralement.           * -*                                                                             * -*  Description : Réalise une copie minimale d'un contenu partagé.             * -*                                                                             * -*  Retour      : -                                                            * -*                                                                             * -*  Remarques   : -                                                            * -*                                                                             * -******************************************************************************/ - -static void g_armv7_maccess_operand_define_template(const GArmV7MAccessOperand *operand, GArmV7MAccessOperand *template) -{ -    template->base = operand->base; -    template->offset = operand->offset; -    template->shift = operand->shift; - -    template->not_post_indexed = operand->not_post_indexed; -    template->write_back = operand->write_back; - -} - - -/****************************************************************************** -*                                                                             *  *  Paramètres  : a = premier opérande à consulter.                            *  *                b = second opérande à consulter.                             *  *                                                                             * @@ -362,17 +274,16 @@ static void g_armv7_maccess_operand_print(const GArmV7MAccessOperand *operand, G  GArchOperand *g_armv7_maccess_operand_new(GArchOperand *base, GArchOperand *offset, GArchOperand *shift, bool indexed, bool wback)  { -    GSharedInstance *result;                /* Structure à retourner       */ -    GArmV7MAccessOperand template;          /* Transport d'informations    */ +    GArmV7MAccessOperand *result;           /* Structure à retourner       */ -    template.base = base; -    template.offset = offset; -    template.shift = shift; +    result = g_object_new(G_TYPE_ARMV7_MACCESS_OPERAND, NULL); -    template.not_post_indexed = indexed; -    template.write_back = wback; +    result->base = base; +    result->offset = offset; +    result->shift = shift; -    result = g_share_manager_build(_armv7_maccess_operand_manager, (GSharedInstance *)&template); +    result->not_post_indexed = indexed; +    result->write_back = wback;      return G_ARCH_OPERAND(result); @@ -472,88 +383,3 @@ bool g_armv7_maccess_operand_has_to_write_back(const GArmV7MAccessOperand *opera      return operand->write_back;  } - - - -/* ---------------------------------------------------------------------------------- */ -/*                            PARTAGES DE CONTENUS UNIQUES                            */ -/* ---------------------------------------------------------------------------------- */ - - -/****************************************************************************** -*                                                                             * -*  Paramètres  : -                                                            * -*                                                                             * -*  Description : Fournit le gestionnaire de partages attribué à un type.      * -*                                                                             * -*  Retour      : Gestionnaire de partages en place.                           * -*                                                                             * -*  Remarques   : -                                                            * -*                                                                             * -******************************************************************************/ - -static GShareManager *get_armv7_maccess_operand_share_manager(void) -{ -    return _armv7_maccess_operand_manager; - -} - - -/****************************************************************************** -*                                                                             * -*  Paramètres  : -                                                            * -*                                                                             * -*  Description : Met en place les mécanismes de partage des accès mémmoire.   * -*                                                                             * -*  Retour      : Bilan de l'opération.                                        * -*                                                                             * -*  Remarques   : -                                                            * -*                                                                             * -******************************************************************************/ - -bool init_armv7_maccess_operand_sharing(void) -{ -    _armv7_maccess_operand_manager = g_share_manager_new(G_TYPE_ARMV7_MACCESS_OPERAND); - -    return true; - -} - - -/****************************************************************************** -*                                                                             * -*  Paramètres  : -                                                            * -*                                                                             * -*  Description : Imprime des statistiques quant aux partages dans l'archi.    * -*                                                                             * -*  Retour      : -                                                            * -*                                                                             * -*  Remarques   : -                                                            * -*                                                                             * -******************************************************************************/ -#ifdef DEBUG_DUMP_STATS -void dump_armv7_maccess_operand_share_stats(void) -{ -    g_share_manager_dump_stats(_armv7_maccess_operand_manager); - -} -#endif - - -/****************************************************************************** -*                                                                             * -*  Paramètres  : -                                                            * -*                                                                             * -*  Description : Supprime les mécanismes de partage des accès mémoire.        * -*                                                                             * -*  Retour      : -                                                            * -*                                                                             * -*  Remarques   : -                                                            * -*                                                                             * -******************************************************************************/ - -void exit_armv7_maccess_operand_sharing(void) -{ -    g_object_unref(G_OBJECT(_armv7_maccess_operand_manager)); - -} diff --git a/src/arch/arm/v7/operands/maccess.h b/src/arch/arm/v7/operands/maccess.h index 52f297d..6e99e0b 100644 --- a/src/arch/arm/v7/operands/maccess.h +++ b/src/arch/arm/v7/operands/maccess.h @@ -34,9 +34,6 @@ -/* --------------------- MANIPULATION D'OPERANDES INDIVIDUELLES --------------------- */ - -  #define G_TYPE_ARMV7_MACCESS_OPERAND                  g_armv7_maccess_operand_get_type()  #define G_ARMV7_MACCESS_OPERAND(obj)                  (G_TYPE_CHECK_INSTANCE_CAST((obj), g_armv7_maccess_operand_get_type(), GArmV7MAccessOperand))  #define G_IS_ARMV7_MACCESS_OPERAND(obj)               (G_TYPE_CHECK_INSTANCE_TYPE((obj), g_armv7_maccess_operand_get_type())) @@ -75,20 +72,4 @@ bool g_armv7_maccess_operand_has_to_write_back(const GArmV7MAccessOperand *); -/* -------------------------- PARTAGES DE CONTENUS UNIQUES -------------------------- */ - - -/* Met en place les mécanismes de partage des accès mémmoire. */ -bool init_armv7_maccess_operand_sharing(void); - -/* Imprime des statistiques quant aux partages dans l'archi. */ -#ifdef DEBUG_DUMP_STATS -void dump_armv7_maccess_operand_share_stats(void); -#endif - -/* Supprime les mécanismes de partage des accès mémoire. */ -void exit_armv7_maccess_operand_sharing(void); - - -  #endif  /* _ARCH_ARM_V7_OPERANDS_MACCESS_H */ diff --git a/src/arch/arm/v7/operands/offset.c b/src/arch/arm/v7/operands/offset.c index ebd73c8..b8df640 100644 --- a/src/arch/arm/v7/operands/offset.c +++ b/src/arch/arm/v7/operands/offset.c @@ -25,14 +25,10 @@  #include "../../../operand-int.h" -#include "../../../sharing/manager.h"  #include "../../../../common/sort.h" -/* --------------------- MANIPULATION D'OPERANDES INDIVIDUELLES --------------------- */ - -  /* Définition d'un opérande visant à constituer un décallage relatif ARMv7 (instance) */  struct _GArmV7OffsetOperand  { @@ -64,12 +60,6 @@ static void g_armv7_offset_operand_dispose(GArmV7OffsetOperand *);  /* Procède à la libération totale de la mémoire. */  static void g_armv7_offset_operand_finalize(GArmV7OffsetOperand *); -/* Initialise un nouvel objet partagé avec des informations. */ -static bool g_armv7_offset_operand_apply_template(GArmV7OffsetOperand *, const GArmV7OffsetOperand *); - -/* Réalise une copie minimale d'un contenu partagé. */ -static void g_armv7_offset_operand_define_template(const GArmV7OffsetOperand *, GArmV7OffsetOperand *); -  /* Compare un opérande avec un autre. */  static int g_armv7_offset_operand_compare(const GArmV7OffsetOperand *, const GArmV7OffsetOperand *); @@ -78,23 +68,6 @@ static void g_armv7_offset_operand_print(const GArmV7OffsetOperand *, GBufferLin -/* -------------------------- PARTAGES DE CONTENUS UNIQUES -------------------------- */ - - -/* Gestionnaire des partages d'instances */ -static GShareManager *_armv7_offset_operand_manager = NULL; - - -/* Fournit le gestionnaire de partages attribué à un type. */ -static GShareManager *get_armv7_offset_operand_share_manager(void); - - - -/* ---------------------------------------------------------------------------------- */ -/*                       MANIPULATION D'OPERANDES INDIVIDUELLES                       */ -/* ---------------------------------------------------------------------------------- */ - -  /* Indique le type défini par la GLib pour un décallage relatif ARMv7. */  G_DEFINE_TYPE(GArmV7OffsetOperand, g_armv7_offset_operand, G_TYPE_ARCH_OPERAND); @@ -122,12 +95,6 @@ static void g_armv7_offset_operand_class_init(GArmV7OffsetOperandClass *klass)      object->dispose = (GObjectFinalizeFunc/* ! */)g_armv7_offset_operand_dispose;      object->finalize = (GObjectFinalizeFunc)g_armv7_offset_operand_finalize; -    operand->get_manager = (get_operand_manager_fc)get_armv7_offset_operand_share_manager; - -    operand->apply_template = (apply_operand_template_fc)g_armv7_offset_operand_apply_template; -    operand->define_template = (define_operand_template_fc)g_armv7_offset_operand_define_template; -    operand->free_template = (free_operand_template_fc)NULL; -      operand->compare = (operand_compare_fc)g_armv7_offset_operand_compare;      operand->print = (operand_print_fc)g_armv7_offset_operand_print; @@ -194,52 +161,6 @@ static void g_armv7_offset_operand_finalize(GArmV7OffsetOperand *operand)  /******************************************************************************  *                                                                             * -*  Paramètres  : operand  = objet partagé à initialiser.                      * -*                template = information à utiliser pour la mise en place.     * -*                                                                             * -*  Description : Initialise un nouvel objet partagé avec des informations.    * -*                                                                             * -*  Retour      : Bilan de l'opération.                                        * -*                                                                             * -*  Remarques   : -                                                            * -*                                                                             * -******************************************************************************/ - -static bool g_armv7_offset_operand_apply_template(GArmV7OffsetOperand *operand, const GArmV7OffsetOperand *template) -{ -    g_armv7_offset_operand_define_template(template, operand); - -    g_object_ref(G_OBJECT(operand->value)); - -    return true; - -} - - -/****************************************************************************** -*                                                                             * -*  Paramètres  : operand  = objet partagé à consulter.                        * -*                template = informations à retrouver intégralement.           * -*                                                                             * -*  Description : Réalise une copie minimale d'un contenu partagé.             * -*                                                                             * -*  Retour      : -                                                            * -*                                                                             * -*  Remarques   : -                                                            * -*                                                                             * -******************************************************************************/ - -static void g_armv7_offset_operand_define_template(const GArmV7OffsetOperand *operand, GArmV7OffsetOperand *template) -{ -    template->positive = operand->positive; - -    template->value = operand->value; - -} - - -/****************************************************************************** -*                                                                             *  *  Paramètres  : a = premier opérande à consulter.                            *  *                b = second opérande à consulter.                             *  *                                                                             * @@ -306,13 +227,12 @@ static void g_armv7_offset_operand_print(const GArmV7OffsetOperand *operand, GBu  GArchOperand *g_armv7_offset_operand_new(bool positive, GArchOperand *value)  { -    GSharedInstance *result;                /* Structure à retourner       */ -    GArmV7OffsetOperand template;           /* Transport d'informations    */ +    GArmV7OffsetOperand *result;            /* Structure à retourner       */ -    template.positive = positive; -    template.value = value; +    result = g_object_new(G_TYPE_ARMV7_OFFSET_OPERAND, NULL); -    result = g_share_manager_build(_armv7_offset_operand_manager, (GSharedInstance *)&template); +    result->positive = positive; +    result->value = value;      return G_ARCH_OPERAND(result); @@ -361,88 +281,3 @@ GArchOperand *g_armv7_offset_operand_get_value(const GArmV7OffsetOperand *operan      return result;  } - - - -/* ---------------------------------------------------------------------------------- */ -/*                            PARTAGES DE CONTENUS UNIQUES                            */ -/* ---------------------------------------------------------------------------------- */ - - -/****************************************************************************** -*                                                                             * -*  Paramètres  : -                                                            * -*                                                                             * -*  Description : Fournit le gestionnaire de partages attribué à un type.      * -*                                                                             * -*  Retour      : Gestionnaire de partages en place.                           * -*                                                                             * -*  Remarques   : -                                                            * -*                                                                             * -******************************************************************************/ - -static GShareManager *get_armv7_offset_operand_share_manager(void) -{ -    return _armv7_offset_operand_manager; - -} - - -/****************************************************************************** -*                                                                             * -*  Paramètres  : -                                                            * -*                                                                             * -*  Description : Met en place les mécanismes de partage des décallages ARMv7. * -*                                                                             * -*  Retour      : Bilan de l'opération.                                        * -*                                                                             * -*  Remarques   : -                                                            * -*                                                                             * -******************************************************************************/ - -bool init_armv7_offset_operand_sharing(void) -{ -    _armv7_offset_operand_manager = g_share_manager_new(G_TYPE_ARMV7_OFFSET_OPERAND); - -    return true; - -} - - -/****************************************************************************** -*                                                                             * -*  Paramètres  : -                                                            * -*                                                                             * -*  Description : Imprime des statistiques quant aux partages dans l'archi.    * -*                                                                             * -*  Retour      : -                                                            * -*                                                                             * -*  Remarques   : -                                                            * -*                                                                             * -******************************************************************************/ -#ifdef DEBUG_DUMP_STATS -void dump_armv7_offset_operand_share_stats(void) -{ -    g_share_manager_dump_stats(_armv7_offset_operand_manager); - -} -#endif - - -/****************************************************************************** -*                                                                             * -*  Paramètres  : -                                                            * -*                                                                             * -*  Description : Supprime les mécanismes de partage des décallages ARMv7.     * -*                                                                             * -*  Retour      : -                                                            * -*                                                                             * -*  Remarques   : -                                                            * -*                                                                             * -******************************************************************************/ - -void exit_armv7_offset_operand_sharing(void) -{ -    g_object_unref(G_OBJECT(_armv7_offset_operand_manager)); - -} diff --git a/src/arch/arm/v7/operands/offset.h b/src/arch/arm/v7/operands/offset.h index b1e1ddc..64744df 100644 --- a/src/arch/arm/v7/operands/offset.h +++ b/src/arch/arm/v7/operands/offset.h @@ -34,9 +34,6 @@ -/* --------------------- MANIPULATION D'OPERANDES INDIVIDUELLES --------------------- */ - -  #define G_TYPE_ARMV7_OFFSET_OPERAND                  g_armv7_offset_operand_get_type()  #define G_ARMV7_OFFSET_OPERAND(obj)                  (G_TYPE_CHECK_INSTANCE_CAST((obj), g_armv7_offset_operand_get_type(), GArmV7OffsetOperand))  #define G_IS_ARMV7_OFFSET_OPERAND(obj)               (G_TYPE_CHECK_INSTANCE_TYPE((obj), g_armv7_offset_operand_get_type())) @@ -66,20 +63,4 @@ GArchOperand *g_armv7_offset_operand_get_value(const GArmV7OffsetOperand *); -/* -------------------------- PARTAGES DE CONTENUS UNIQUES -------------------------- */ - - -/* Met en place les mécanismes de partage des décallages ARMv7. */ -bool init_armv7_offset_operand_sharing(void); - -/* Imprime des statistiques quant aux partages dans l'archi. */ -#ifdef DEBUG_DUMP_STATS -void dump_armv7_offset_operand_share_stats(void); -#endif - -/* Supprime les mécanismes de partage des décallages ARMv7. */ -void exit_armv7_offset_operand_sharing(void); - - -  #endif  /* _ARCH_ARM_V7_OPERANDS_OFFSET_H */ diff --git a/src/arch/arm/v7/operands/reglist.c b/src/arch/arm/v7/operands/reglist.c index 968a423..9f641b8 100644 --- a/src/arch/arm/v7/operands/reglist.c +++ b/src/arch/arm/v7/operands/reglist.c @@ -30,14 +30,10 @@  #include "../../../operand-int.h"  #include "../../../register.h" -#include "../../../sharing/manager.h"  #include "../../../../common/sort.h" -/* --------------------- MANIPULATION D'OPERANDES INDIVIDUELLES --------------------- */ - -  /* Définition d'un opérande listant une série de registres ARM (instance) */  struct _GArmV7RegListOperand  { @@ -69,15 +65,6 @@ static void g_armv7_reglist_operand_dispose(GArmV7RegListOperand *);  /* Procède à la libération totale de la mémoire. */  static void g_armv7_reglist_operand_finalize(GArmV7RegListOperand *); -/* Initialise un nouvel objet partagé avec des informations. */ -static bool g_armv7_reglist_operand_apply_template(GArmV7RegListOperand *, const GArmV7RegListOperand *); - -/* Réalise une copie minimale d'un contenu partagé. */ -static void g_armv7_reglist_operand_define_template(const GArmV7RegListOperand *, GArmV7RegListOperand *); - -/* Libère la mémoire utilisée par un patron d'instance. */ -static void g_armv7_reglist_operand_free_template(const GArmV7RegListOperand *, GArmV7RegListOperand *); -  /* Compare un opérande avec un autre. */  static int g_armv7_reglist_operand_compare(const GArmV7RegListOperand *, const GArmV7RegListOperand *); @@ -86,23 +73,6 @@ static void g_armv7_reglist_operand_print(const GArmV7RegListOperand *, GBufferL -/* -------------------------- PARTAGES DE CONTENUS UNIQUES -------------------------- */ - - -/* Gestionnaire des partages d'instances */ -static GShareManager *_armv7_reglist_operand_manager = NULL; - - -/* Fournit le gestionnaire de partages attribué à un type. */ -static GShareManager *get_armv7_reglist_operand_share_manager(void); - - - -/* ---------------------------------------------------------------------------------- */ -/*                       MANIPULATION D'OPERANDES INDIVIDUELLES                       */ -/* ---------------------------------------------------------------------------------- */ - -  /* Indique le type défini par la GLib pour une liste de registres ARM. */  G_DEFINE_TYPE(GArmV7RegListOperand, g_armv7_reglist_operand, G_TYPE_ARCH_OPERAND); @@ -130,12 +100,6 @@ static void g_armv7_reglist_operand_class_init(GArmV7RegListOperandClass *klass)      object->dispose = (GObjectFinalizeFunc/* ! */)g_armv7_reglist_operand_dispose;      object->finalize = (GObjectFinalizeFunc)g_armv7_reglist_operand_finalize; -    operand->get_manager = (get_operand_manager_fc)get_armv7_reglist_operand_share_manager; - -    operand->apply_template = (apply_operand_template_fc)g_armv7_reglist_operand_apply_template; -    operand->define_template = (define_operand_template_fc)g_armv7_reglist_operand_define_template; -    operand->free_template = (free_operand_template_fc)g_armv7_reglist_operand_free_template;; -      operand->compare = (operand_compare_fc)g_armv7_reglist_operand_compare;      operand->print = (operand_print_fc)g_armv7_reglist_operand_print; @@ -208,91 +172,6 @@ static void g_armv7_reglist_operand_finalize(GArmV7RegListOperand *operand)  /******************************************************************************  *                                                                             * -*  Paramètres  : operand  = objet partagé à initialiser.                      * -*                template = information à utiliser pour la mise en place.     * -*                                                                             * -*  Description : Initialise un nouvel objet partagé avec des informations.    * -*                                                                             * -*  Retour      : Bilan de l'opération.                                        * -*                                                                             * -*  Remarques   : -                                                            * -*                                                                             * -******************************************************************************/ - -static bool g_armv7_reglist_operand_apply_template(GArmV7RegListOperand *operand, const GArmV7RegListOperand *template) -{ -    size_t i;                               /* Boucle de parcours          */ - -    g_armv7_reglist_operand_define_template(template, operand); - -    for (i = 0; i < operand->count; i++) -        g_object_ref(G_OBJECT(operand->registers[i])); - -    return true; - -} - - -/****************************************************************************** -*                                                                             * -*  Paramètres  : operand  = objet partagé à consulter.                        * -*                template = informations à retrouver intégralement.           * -*                                                                             * -*  Description : Réalise une copie minimale d'un contenu partagé.             * -*                                                                             * -*  Retour      : -                                                            * -*                                                                             * -*  Remarques   : -                                                            * -*                                                                             * -******************************************************************************/ - -static void g_armv7_reglist_operand_define_template(const GArmV7RegListOperand *operand, GArmV7RegListOperand *template) -{ -    size_t i;                               /* Boucle de parcours          */ - -    if (operand != NULL) -        template->count = operand->count; -    else -        template->count = 0; - -    if (template->count == 0) -        template->registers = NULL; - -    else -    { -        template->registers = (GArmV7Register **)malloc(template->count * sizeof(GArmV7Register *)); - -        for (i = 0; i < template->count; i++) -            template->registers[i] = operand->registers[i]; - -    } - -} - - -/****************************************************************************** -*                                                                             * -*  Paramètres  : operand  = objet partagé à consulter.                        * -*                template = informations dont le contenu est à libérer.       * -*                                                                             * -*  Description : Libère la mémoire utilisée par un patron d'instance.         * -*                                                                             * -*  Retour      : -                                                            * -*                                                                             * -*  Remarques   : -                                                            * -*                                                                             * -******************************************************************************/ - -static void g_armv7_reglist_operand_free_template(const GArmV7RegListOperand *operand, GArmV7RegListOperand *template) -{ -    if (template->registers != NULL) -        free(template->registers); - -} - - -/****************************************************************************** -*                                                                             *  *  Paramètres  : a = premier opérande à consulter.                            *  *                b = second opérande à consulter.                             *  *                                                                             * @@ -388,9 +267,9 @@ static void g_armv7_reglist_operand_print(const GArmV7RegListOperand *operand, G  GArchOperand *g_armv7_reglist_operand_new(void)  { -    GSharedInstance *result;                /* Structure à retourner       */ +    GArchOperand *result;                   /* Structure à retourner       */ -    result = g_share_manager_build(_armv7_reglist_operand_manager, NULL); +    result = g_object_new(G_TYPE_ARMV7_REGLIST_OPERAND, NULL);      return G_ARCH_OPERAND(result); @@ -495,88 +374,3 @@ GArmV7Register *g_armv7_reglist_operand_get_register(const GArmV7RegListOperand      return operand->registers[index];  } - - - -/* ---------------------------------------------------------------------------------- */ -/*                            PARTAGES DE CONTENUS UNIQUES                            */ -/* ---------------------------------------------------------------------------------- */ - - -/****************************************************************************** -*                                                                             * -*  Paramètres  : -                                                            * -*                                                                             * -*  Description : Fournit le gestionnaire de partages attribué à un type.      * -*                                                                             * -*  Retour      : Gestionnaire de partages en place.                           * -*                                                                             * -*  Remarques   : -                                                            * -*                                                                             * -******************************************************************************/ - -static GShareManager *get_armv7_reglist_operand_share_manager(void) -{ -    return _armv7_reglist_operand_manager; - -} - - -/****************************************************************************** -*                                                                             * -*  Paramètres  : -                                                            * -*                                                                             * -*  Description : Met en place les mécanismes de partage de listes de reg.     * -*                                                                             * -*  Retour      : Bilan de l'opération.                                        * -*                                                                             * -*  Remarques   : -                                                            * -*                                                                             * -******************************************************************************/ - -bool init_armv7_reglist_operand_sharing(void) -{ -    _armv7_reglist_operand_manager = g_share_manager_new(G_TYPE_ARMV7_REGLIST_OPERAND); - -    return true; - -} - - -/****************************************************************************** -*                                                                             * -*  Paramètres  : -                                                            * -*                                                                             * -*  Description : Imprime des statistiques quant aux partages dans l'archi.    * -*                                                                             * -*  Retour      : -                                                            * -*                                                                             * -*  Remarques   : -                                                            * -*                                                                             * -******************************************************************************/ -#ifdef DEBUG_DUMP_STATS -void dump_armv7_reglist_operand_share_stats(void) -{ -    g_share_manager_dump_stats(_armv7_reglist_operand_manager); - -} -#endif - - -/****************************************************************************** -*                                                                             * -*  Paramètres  : -                                                            * -*                                                                             * -*  Description : Supprime les mécanismes de partage des listes de registres.  * -*                                                                             * -*  Retour      : -                                                            * -*                                                                             * -*  Remarques   : -                                                            * -*                                                                             * -******************************************************************************/ - -void exit_armv7_reglist_operand_sharing(void) -{ -    g_object_unref(G_OBJECT(_armv7_reglist_operand_manager)); - -} diff --git a/src/arch/arm/v7/operands/reglist.h b/src/arch/arm/v7/operands/reglist.h index 497c852..7c60805 100644 --- a/src/arch/arm/v7/operands/reglist.h +++ b/src/arch/arm/v7/operands/reglist.h @@ -34,9 +34,6 @@ -/* --------------------- MANIPULATION D'OPERANDES INDIVIDUELLES --------------------- */ - -  #define G_TYPE_ARMV7_REGLIST_OPERAND                  g_armv7_reglist_operand_get_type()  #define G_ARMV7_REGLIST_OPERAND(obj)                  (G_TYPE_CHECK_INSTANCE_CAST((obj), g_armv7_reglist_operand_get_type(), GArmV7RegListOperand))  #define G_IS_ARMV7_REGLIST_OPERAND(obj)               (G_TYPE_CHECK_INSTANCE_TYPE((obj), g_armv7_reglist_operand_get_type())) @@ -72,20 +69,4 @@ GArmV7Register *g_armv7_reglist_operand_get_register(const GArmV7RegListOperand -/* -------------------------- PARTAGES DE CONTENUS UNIQUES -------------------------- */ - - -/* Met en place les mécanismes de partage de listes de registres. */ -bool init_armv7_reglist_operand_sharing(void); - -/* Imprime des statistiques quant aux partages dans l'archi. */ -#ifdef DEBUG_DUMP_STATS -void dump_armv7_reglist_operand_share_stats(void); -#endif - -/* Supprime les mécanismes de partage des listes de registres. */ -void exit_armv7_reglist_operand_sharing(void); - - -  #endif  /* _ARCH_ARM_V7_OPERANDS_REGLIST_H */ diff --git a/src/arch/arm/v7/operands/rotation.c b/src/arch/arm/v7/operands/rotation.c index be89cd5..ba31441 100644 --- a/src/arch/arm/v7/operands/rotation.c +++ b/src/arch/arm/v7/operands/rotation.c @@ -25,13 +25,9 @@  #include "../../../operand-int.h" -#include "../../../sharing/manager.h" -/* --------------------- MANIPULATION D'OPERANDES INDIVIDUELLES --------------------- */ - -  /* Définition d'un opérande visant une opérande de rotation ARMv7 (instance) */  struct _GArmV7RotationOperand  { @@ -62,12 +58,6 @@ static void g_armv7_rotation_operand_dispose(GArmV7RotationOperand *);  /* Procède à la libération totale de la mémoire. */  static void g_armv7_rotation_operand_finalize(GArmV7RotationOperand *); -/* Initialise un nouvel objet partagé avec des informations. */ -static bool g_armv7_rotation_operand_apply_template(GArmV7RotationOperand *, const GArmV7RotationOperand *); - -/* Réalise une copie minimale d'un contenu partagé. */ -static void g_armv7_rotation_operand_define_template(const GArmV7RotationOperand *, GArmV7RotationOperand *); -  /* Compare un opérande avec un autre. */  static int g_armv7_rotation_operand_compare(const GArmV7RotationOperand *, const GArmV7RotationOperand *); @@ -76,23 +66,6 @@ static void g_armv7_rotation_operand_print(const GArmV7RotationOperand *, GBuffe -/* -------------------------- PARTAGES DE CONTENUS UNIQUES -------------------------- */ - - -/* Gestionnaire des partages d'instances */ -static GShareManager *_armv7_rotation_operand_manager = NULL; - - -/* Fournit le gestionnaire de partages attribué à un type. */ -static GShareManager *get_armv7_rotation_operand_share_manager(void); - - - -/* ---------------------------------------------------------------------------------- */ -/*                       MANIPULATION D'OPERANDES INDIVIDUELLES                       */ -/* ---------------------------------------------------------------------------------- */ - -  /* Indique le type défini par la GLib pour une opérande de rotation ARMv7. */  G_DEFINE_TYPE(GArmV7RotationOperand, g_armv7_rotation_operand, G_TYPE_ARCH_OPERAND); @@ -120,12 +93,6 @@ static void g_armv7_rotation_operand_class_init(GArmV7RotationOperandClass *klas      object->dispose = (GObjectFinalizeFunc/* ! */)g_armv7_rotation_operand_dispose;      object->finalize = (GObjectFinalizeFunc)g_armv7_rotation_operand_finalize; -    operand->get_manager = (get_operand_manager_fc)get_armv7_rotation_operand_share_manager; - -    operand->apply_template = (apply_operand_template_fc)g_armv7_rotation_operand_apply_template; -    operand->define_template = (define_operand_template_fc)g_armv7_rotation_operand_define_template; -    operand->free_template = (free_operand_template_fc)NULL; -      operand->compare = (operand_compare_fc)g_armv7_rotation_operand_compare;      operand->print = (operand_print_fc)g_armv7_rotation_operand_print; @@ -192,50 +159,6 @@ static void g_armv7_rotation_operand_finalize(GArmV7RotationOperand *operand)  /******************************************************************************  *                                                                             * -*  Paramètres  : operand  = objet partagé à initialiser.                      * -*                template = information à utiliser pour la mise en place.     * -*                                                                             * -*  Description : Initialise un nouvel objet partagé avec des informations.    * -*                                                                             * -*  Retour      : Bilan de l'opération.                                        * -*                                                                             * -*  Remarques   : -                                                            * -*                                                                             * -******************************************************************************/ - -static bool g_armv7_rotation_operand_apply_template(GArmV7RotationOperand *operand, const GArmV7RotationOperand *template) -{ -    g_armv7_rotation_operand_define_template(template, operand); - -    g_object_ref(G_OBJECT(operand->value)); - -    return true; - -} - - -/****************************************************************************** -*                                                                             * -*  Paramètres  : operand  = objet partagé à consulter.                        * -*                template = informations à retrouver intégralement.           * -*                                                                             * -*  Description : Réalise une copie minimale d'un contenu partagé.             * -*                                                                             * -*  Retour      : -                                                            * -*                                                                             * -*  Remarques   : -                                                            * -*                                                                             * -******************************************************************************/ - -static void g_armv7_rotation_operand_define_template(const GArmV7RotationOperand *operand, GArmV7RotationOperand *template) -{ -    template->value = operand->value; - -} - - -/****************************************************************************** -*                                                                             *  *  Paramètres  : a = premier opérande à consulter.                            *  *                b = second opérande à consulter.                             *  *                                                                             * @@ -297,12 +220,11 @@ static void g_armv7_rotation_operand_print(const GArmV7RotationOperand *operand,  GArchOperand *g_armv7_rotation_operand_new(GArchOperand *value)  { -    GSharedInstance *result;                /* Structure à retourner       */ -    GArmV7RotationOperand template;         /* Transport d'informations    */ +    GArmV7RotationOperand *result;          /* Structure à retourner       */ -    template.value = value; +    result = g_object_new(G_TYPE_ARMV7_ROTATION_OPERAND, NULL); -    result = g_share_manager_build(_armv7_rotation_operand_manager, (GSharedInstance *)&template); +    result->value = value;      return G_ARCH_OPERAND(result); @@ -332,88 +254,3 @@ GArchOperand *g_armv7_rotation_operand_get_value(const GArmV7RotationOperand *op      return result;  } - - - -/* ---------------------------------------------------------------------------------- */ -/*                            PARTAGES DE CONTENUS UNIQUES                            */ -/* ---------------------------------------------------------------------------------- */ - - -/****************************************************************************** -*                                                                             * -*  Paramètres  : -                                                            * -*                                                                             * -*  Description : Fournit le gestionnaire de partages attribué à un type.      * -*                                                                             * -*  Retour      : Gestionnaire de partages en place.                           * -*                                                                             * -*  Remarques   : -                                                            * -*                                                                             * -******************************************************************************/ - -static GShareManager *get_armv7_rotation_operand_share_manager(void) -{ -    return _armv7_rotation_operand_manager; - -} - - -/****************************************************************************** -*                                                                             * -*  Paramètres  : -                                                            * -*                                                                             * -*  Description : Met en place les mécanismes de partage des rotation ARMv7.   * -*                                                                             * -*  Retour      : Bilan de l'opération.                                        * -*                                                                             * -*  Remarques   : -                                                            * -*                                                                             * -******************************************************************************/ - -bool init_armv7_rotation_operand_sharing(void) -{ -    _armv7_rotation_operand_manager = g_share_manager_new(G_TYPE_ARMV7_ROTATION_OPERAND); - -    return true; - -} - - -/****************************************************************************** -*                                                                             * -*  Paramètres  : -                                                            * -*                                                                             * -*  Description : Imprime des statistiques quant aux partages dans l'archi.    * -*                                                                             * -*  Retour      : -                                                            * -*                                                                             * -*  Remarques   : -                                                            * -*                                                                             * -******************************************************************************/ -#ifdef DEBUG_DUMP_STATS -void dump_armv7_rotation_operand_share_stats(void) -{ -    g_share_manager_dump_stats(_armv7_rotation_operand_manager); - -} -#endif - - -/****************************************************************************** -*                                                                             * -*  Paramètres  : -                                                            * -*                                                                             * -*  Description : Supprime les mécanismes de partage des opérandes de rotation.* -*                                                                             * -*  Retour      : -                                                            * -*                                                                             * -*  Remarques   : -                                                            * -*                                                                             * -******************************************************************************/ - -void exit_armv7_rotation_operand_sharing(void) -{ -    g_object_unref(G_OBJECT(_armv7_rotation_operand_manager)); - -} diff --git a/src/arch/arm/v7/operands/rotation.h b/src/arch/arm/v7/operands/rotation.h index 399baf4..7fb6c09 100644 --- a/src/arch/arm/v7/operands/rotation.h +++ b/src/arch/arm/v7/operands/rotation.h @@ -58,20 +58,4 @@ GArchOperand *g_armv7_rotation_operand_get_value(const GArmV7RotationOperand *); -/* -------------------------- PARTAGES DE CONTENUS UNIQUES -------------------------- */ - - -/* Met en place les mécanismes de partage des rotation ARMv7. */ -bool init_armv7_rotation_operand_sharing(void); - -/* Imprime des statistiques quant aux partages dans l'archi. */ -#ifdef DEBUG_DUMP_STATS -void dump_armv7_rotation_operand_share_stats(void); -#endif - -/* Supprime les mécanismes de partage des opérandes de rotation. */ -void exit_armv7_rotation_operand_sharing(void); - - -  #endif  /* _ARCH_ARM_V7_OPERANDS_ROTATION_H */ diff --git a/src/arch/arm/v7/operands/shift.c b/src/arch/arm/v7/operands/shift.c index 3a37e81..6fbdbcb 100644 --- a/src/arch/arm/v7/operands/shift.c +++ b/src/arch/arm/v7/operands/shift.c @@ -25,14 +25,10 @@  #include "../../../operand-int.h" -#include "../../../sharing/manager.h"  #include "../../../../common/sort.h" -/* --------------------- MANIPULATION D'OPERANDES INDIVIDUELLES --------------------- */ - -  /* Définition d'un opérande visant une opérande de décallage ARMv7 (instance) */  struct _GArmV7ShiftOperand  { @@ -64,12 +60,6 @@ static void g_armv7_shift_operand_dispose(GArmV7ShiftOperand *);  /* Procède à la libération totale de la mémoire. */  static void g_armv7_shift_operand_finalize(GArmV7ShiftOperand *); -/* Initialise un nouvel objet partagé avec des informations. */ -static bool g_armv7_shift_operand_apply_template(GArmV7ShiftOperand *, const GArmV7ShiftOperand *); - -/* Réalise une copie minimale d'un contenu partagé. */ -static void g_armv7_shift_operand_define_template(const GArmV7ShiftOperand *, GArmV7ShiftOperand *); -  /* Compare un opérande avec un autre. */  static int g_armv7_shift_operand_compare(const GArmV7ShiftOperand *, const GArmV7ShiftOperand *); @@ -78,23 +68,6 @@ static void g_armv7_shift_operand_print(const GArmV7ShiftOperand *, GBufferLine -/* -------------------------- PARTAGES DE CONTENUS UNIQUES -------------------------- */ - - -/* Gestionnaire des partages d'instances */ -static GShareManager *_armv7_shift_operand_manager = NULL; - - -/* Fournit le gestionnaire de partages attribué à un type. */ -static GShareManager *get_armv7_shift_operand_share_manager(void); - - - -/* ---------------------------------------------------------------------------------- */ -/*                       MANIPULATION D'OPERANDES INDIVIDUELLES                       */ -/* ---------------------------------------------------------------------------------- */ - -  /* Indique le type défini par la GLib pour une opérande de décallage ARMv7. */  G_DEFINE_TYPE(GArmV7ShiftOperand, g_armv7_shift_operand, G_TYPE_ARCH_OPERAND); @@ -122,12 +95,6 @@ static void g_armv7_shift_operand_class_init(GArmV7ShiftOperandClass *klass)      object->dispose = (GObjectFinalizeFunc/* ! */)g_armv7_shift_operand_dispose;      object->finalize = (GObjectFinalizeFunc)g_armv7_shift_operand_finalize; -    operand->get_manager = (get_operand_manager_fc)get_armv7_shift_operand_share_manager; - -    operand->apply_template = (apply_operand_template_fc)g_armv7_shift_operand_apply_template; -    operand->define_template = (define_operand_template_fc)g_armv7_shift_operand_define_template; -    operand->free_template = (free_operand_template_fc)NULL; -      operand->compare = (operand_compare_fc)g_armv7_shift_operand_compare;      operand->print = (operand_print_fc)g_armv7_shift_operand_print; @@ -194,52 +161,6 @@ static void g_armv7_shift_operand_finalize(GArmV7ShiftOperand *operand)  /******************************************************************************  *                                                                             * -*  Paramètres  : operand  = objet partagé à initialiser.                      * -*                template = information à utiliser pour la mise en place.     * -*                                                                             * -*  Description : Initialise un nouvel objet partagé avec des informations.    * -*                                                                             * -*  Retour      : Bilan de l'opération.                                        * -*                                                                             * -*  Remarques   : -                                                            * -*                                                                             * -******************************************************************************/ - -static bool g_armv7_shift_operand_apply_template(GArmV7ShiftOperand *operand, const GArmV7ShiftOperand *template) -{ -    g_armv7_shift_operand_define_template(template, operand); - -    g_object_ref(G_OBJECT(operand->shift_value)); - -    return true; - -} - - -/****************************************************************************** -*                                                                             * -*  Paramètres  : operand  = objet partagé à consulter.                        * -*                template = informations à retrouver intégralement.           * -*                                                                             * -*  Description : Réalise une copie minimale d'un contenu partagé.             * -*                                                                             * -*  Retour      : -                                                            * -*                                                                             * -*  Remarques   : -                                                            * -*                                                                             * -******************************************************************************/ - -static void g_armv7_shift_operand_define_template(const GArmV7ShiftOperand *operand, GArmV7ShiftOperand *template) -{ -    template->shift_type = operand->shift_type; - -    template->shift_value = operand->shift_value; - -} - - -/****************************************************************************** -*                                                                             *  *  Paramètres  : a = premier opérande à consulter.                            *  *                b = second opérande à consulter.                             *  *                                                                             * @@ -323,13 +244,12 @@ static void g_armv7_shift_operand_print(const GArmV7ShiftOperand *operand, GBuff  GArchOperand *g_armv7_shift_operand_new(SRType type, GArchOperand *value)  { -    GSharedInstance *result;                /* Structure à retourner       */ -    GArmV7ShiftOperand template;            /* Transport d'informations    */ +    GArmV7ShiftOperand *result;             /* Structure à retourner       */ -    template.shift_type = type; -    template.shift_value = value; +    result = g_object_new(G_TYPE_ARMV7_SHIFT_OPERAND, NULL); -    result = g_share_manager_build(_armv7_shift_operand_manager, (GSharedInstance *)&template); +    result->shift_type = type; +    result->shift_value = value;      return G_ARCH_OPERAND(result); @@ -378,88 +298,3 @@ GArchOperand *g_armv7_shift_operand_get_shift_value(const GArmV7ShiftOperand *op      return result;  } - - - -/* ---------------------------------------------------------------------------------- */ -/*                            PARTAGES DE CONTENUS UNIQUES                            */ -/* ---------------------------------------------------------------------------------- */ - - -/****************************************************************************** -*                                                                             * -*  Paramètres  : -                                                            * -*                                                                             * -*  Description : Fournit le gestionnaire de partages attribué à un type.      * -*                                                                             * -*  Retour      : Gestionnaire de partages en place.                           * -*                                                                             * -*  Remarques   : -                                                            * -*                                                                             * -******************************************************************************/ - -static GShareManager *get_armv7_shift_operand_share_manager(void) -{ -    return _armv7_shift_operand_manager; - -} - - -/****************************************************************************** -*                                                                             * -*  Paramètres  : -                                                            * -*                                                                             * -*  Description : Met en place les mécanismes de partage des décallages ARMv7. * -*                                                                             * -*  Retour      : Bilan de l'opération.                                        * -*                                                                             * -*  Remarques   : -                                                            * -*                                                                             * -******************************************************************************/ - -bool init_armv7_shift_operand_sharing(void) -{ -    _armv7_shift_operand_manager = g_share_manager_new(G_TYPE_ARMV7_SHIFT_OPERAND); - -    return true; - -} - - -/****************************************************************************** -*                                                                             * -*  Paramètres  : -                                                            * -*                                                                             * -*  Description : Imprime des statistiques quant aux partages dans l'archi.    * -*                                                                             * -*  Retour      : -                                                            * -*                                                                             * -*  Remarques   : -                                                            * -*                                                                             * -******************************************************************************/ -#ifdef DEBUG_DUMP_STATS -void dump_armv7_shift_operand_share_stats(void) -{ -    g_share_manager_dump_stats(_armv7_shift_operand_manager); - -} -#endif - - -/****************************************************************************** -*                                                                             * -*  Paramètres  : -                                                            * -*                                                                             * -*  Description : Supprime les mécanismes de partage des décallages ARMv7.     * -*                                                                             * -*  Retour      : -                                                            * -*                                                                             * -*  Remarques   : -                                                            * -*                                                                             * -******************************************************************************/ - -void exit_armv7_shift_operand_sharing(void) -{ -    g_object_unref(G_OBJECT(_armv7_shift_operand_manager)); - -} diff --git a/src/arch/arm/v7/operands/shift.h b/src/arch/arm/v7/operands/shift.h index 1169946..2eac092 100644 --- a/src/arch/arm/v7/operands/shift.h +++ b/src/arch/arm/v7/operands/shift.h @@ -33,9 +33,6 @@ -/* --------------------- MANIPULATION D'OPERANDES INDIVIDUELLES --------------------- */ - -  #define G_TYPE_ARMV7_SHIFT_OPERAND                  g_armv7_shift_operand_get_type()  #define G_ARMV7_SHIFT_OPERAND(obj)                  (G_TYPE_CHECK_INSTANCE_CAST((obj), g_armv7_shift_operand_get_type(), GArmV7ShiftOperand))  #define G_IS_ARMV7_SHIFT_OPERAND(obj)               (G_TYPE_CHECK_INSTANCE_TYPE((obj), g_armv7_shift_operand_get_type())) @@ -65,20 +62,4 @@ GArchOperand *g_armv7_shift_operand_get_shift_value(const GArmV7ShiftOperand *); -/* -------------------------- PARTAGES DE CONTENUS UNIQUES -------------------------- */ - - -/* Met en place les mécanismes de partage des décallages ARMv7. */ -bool init_armv7_shift_operand_sharing(void); - -/* Imprime des statistiques quant aux partages dans l'archi. */ -#ifdef DEBUG_DUMP_STATS -void dump_armv7_shift_operand_share_stats(void); -#endif - -/* Supprime les mécanismes de partage des décallages ARMv7. */ -void exit_armv7_shift_operand_sharing(void); - - -  #endif  /* _ARCH_ARM_V7_OPERANDS_SHIFT_H */ diff --git a/src/arch/arm/v7/post.c b/src/arch/arm/v7/post.c index 415b278..7d8ecb3 100644 --- a/src/arch/arm/v7/post.c +++ b/src/arch/arm/v7/post.c @@ -69,7 +69,7 @@ void post_process_ldr_instructions(GArchInstruction *instr, GArchProcessor *proc          new = G_TARGET_OPERAND(g_target_operand_new(MDS_32_BITS_UNSIGNED, &target)); -        if (!g_target_operand_resolve(&new, bfmt, true, NULL)) +        if (!g_target_operand_resolve(new, bfmt, true))          {              addr &= ~0x1; @@ -82,7 +82,7 @@ void post_process_ldr_instructions(GArchInstruction *instr, GArchProcessor *proc              g_binary_symbol_set_alt_label(symbol, name);              g_binary_format_add_symbol(bfmt, symbol); -            g_target_operand_resolve(&new, bfmt, true, NULL); +            g_target_operand_resolve(new, bfmt, true);          } diff --git a/src/arch/arm/v7/register.c b/src/arch/arm/v7/register.c index 7a873b5..3cd9e0f 100644 --- a/src/arch/arm/v7/register.c +++ b/src/arch/arm/v7/register.c @@ -31,9 +31,6 @@ -/* ------------------------- ENCADREMENT DE REGISTRES BRUTS ------------------------- */ - -  /* Représentation d'un registre ARMv7 (instance) */  struct _GArmV7Register  { @@ -65,31 +62,11 @@ static void g_armv7_register_dispose(GArmV7Register *);  /* Procède à la libération totale de la mémoire. */  static void g_armv7_register_finalize(GArmV7Register *); -/* Réalise une copie minimale d'un contenu partagé. */ -static void g_armv7_register_define_template(const GArmV7Register *, GArmV7Register *); -  /* Traduit un registre en version humainement lisible. */  static void g_armv7_register_print(const GArmV7Register *, GBufferLine *, AsmSyntax); -/* -------------------------- PARTAGES DE CONTENUS UNIQUES -------------------------- */ - - -/* Gestionnaire des partages d'instances */ -static GShareManager *_armv7_register_manager = NULL; - - -/* Fournit le gestionnaire de partages attribué à un type. */ -static GShareManager *get_armv7_register_share_manager(void); - - - -/* ---------------------------------------------------------------------------------- */ -/*                           ENCADREMENT DE REGISTRES BRUTS                           */ -/* ---------------------------------------------------------------------------------- */ - -  /* Indique le type défini pour une représentation d'un registre ARMv7. */  G_DEFINE_TYPE(GArmV7Register, g_armv7_register, G_TYPE_ARM_REGISTER); @@ -117,10 +94,6 @@ static void g_armv7_register_class_init(GArmV7RegisterClass *klass)      object_class->dispose = (GObjectFinalizeFunc/* ! */)g_armv7_register_dispose;      object_class->finalize = (GObjectFinalizeFunc)g_armv7_register_finalize; -    reg_class->get_manager = (get_register_manager_fc)get_armv7_register_share_manager; - -    reg_class->define_template = (define_register_template_fc)g_armv7_register_define_template; -      reg_class->print = (reg_print_fc)g_armv7_register_print;  } @@ -184,32 +157,6 @@ static void g_armv7_register_finalize(GArmV7Register *reg)  /******************************************************************************  *                                                                             * -*  Paramètres  : reg      = objet partagé à consulter.                        * -*                template = informations à retrouver intégralement.           * -*                                                                             * -*  Description : Réalise une copie minimale d'un contenu partagé.             * -*                                                                             * -*  Retour      : -                                                            * -*                                                                             * -*  Remarques   : -                                                            * -*                                                                             * -******************************************************************************/ - -static void g_armv7_register_define_template(const GArmV7Register *reg, GArmV7Register *template) -{ -    GArmRegister *areg;                     /* Version parente #1          */ -    GArmRegister *treg;                     /* Version parente #2          */ - -    areg = (GArmRegister *)reg; -    treg = (GArmRegister *)template; - -    treg->index = areg->index; - -} - - -/****************************************************************************** -*                                                                             *  *  Paramètres  : reg    = registre à transcrire.                              *  *                line   = ligne tampon où imprimer l'opérande donné.          *  *                syntax = type de représentation demandée.                    * @@ -272,97 +219,11 @@ static void g_armv7_register_print(const GArmV7Register *reg, GBufferLine *line,  GArmV7Register *g_armv7_register_new(uint8_t index)  {      GArmV7Register *result;                 /* Structure à retourner       */ -    GArmRegister template;                  /* Transport d'informations    */ -    template.index = index; +    result = g_object_new(G_TYPE_ARMV7_REGISTER, NULL); -    result = G_ARMV7_REGISTER(g_share_manager_build(_armv7_register_manager, (GSharedInstance *)&template)); +    G_ARM_REGISTER(result)->index = index;      return result;  } - - - -/* ---------------------------------------------------------------------------------- */ -/*                            PARTAGES DE CONTENUS UNIQUES                            */ -/* ---------------------------------------------------------------------------------- */ - - -/****************************************************************************** -*                                                                             * -*  Paramètres  : -                                                            * -*                                                                             * -*  Description : Fournit le gestionnaire de partages attribué à un type.      * -*                                                                             * -*  Retour      : Gestionnaire de partages en place.                           * -*                                                                             * -*  Remarques   : -                                                            * -*                                                                             * -******************************************************************************/ - -static GShareManager *get_armv7_register_share_manager(void) -{ -    return _armv7_register_manager; - -} - - -/****************************************************************************** -*                                                                             * -*  Paramètres  : -                                                            * -*                                                                             * -*  Description : Met en place les mécanismes de partage des registres ARMv7.  * -*                                                                             * -*  Retour      : Bilan de l'opération.                                        * -*                                                                             * -*  Remarques   : -                                                            * -*                                                                             * -******************************************************************************/ - -bool init_armv7_register_sharing(void) -{ -    _armv7_register_manager = g_share_manager_new(G_TYPE_ARMV7_REGISTER); - -    return true; - -} - - -/****************************************************************************** -*                                                                             * -*  Paramètres  : -                                                            * -*                                                                             * -*  Description : Imprime des statistiques quant aux partages dans l'archi.    * -*                                                                             * -*  Retour      : -                                                            * -*                                                                             * -*  Remarques   : -                                                            * -*                                                                             * -******************************************************************************/ -#ifdef DEBUG_DUMP_STATS -void dump_armv7_register_share_stats(void) -{ -    g_share_manager_dump_stats(_armv7_register_manager); - -} -#endif - - -/****************************************************************************** -*                                                                             * -*  Paramètres  : -                                                            * -*                                                                             * -*  Description : Supprime les mécanismes de partage des registres ARMv7.      * -*                                                                             * -*  Retour      : -                                                            * -*                                                                             * -*  Remarques   : -                                                            * -*                                                                             * -******************************************************************************/ - -void exit_armv7_register_sharing(void) -{ -    g_object_unref(G_OBJECT(_armv7_register_manager)); - -} diff --git a/src/arch/arm/v7/register.h b/src/arch/arm/v7/register.h index 0408859..d0a89f2 100644 --- a/src/arch/arm/v7/register.h +++ b/src/arch/arm/v7/register.h @@ -31,9 +31,6 @@ -/* ------------------------- ENCADREMENT DE REGISTRES BRUTS ------------------------- */ - -  #define G_TYPE_ARMV7_REGISTER               g_armv7_register_get_type()  #define G_ARMV7_REGISTER(obj)               (G_TYPE_CHECK_INSTANCE_CAST((obj), g_armv7_register_get_type(), GArmV7Register))  #define G_IS_ARMV7_REGISTER(obj)            (G_TYPE_CHECK_INSTANCE_TYPE((obj), g_armv7_register_get_type())) @@ -57,20 +54,4 @@ GArmV7Register *g_armv7_register_new(uint8_t); -/* -------------------------- PARTAGES DE CONTENUS UNIQUES -------------------------- */ - - -/* Met en place les mécanismes de partage des registres ARMv7. */ -bool init_armv7_register_sharing(void); - -/* Imprime des statistiques quant aux partages dans l'archi. */ -#ifdef DEBUG_DUMP_STATS -void dump_armv7_register_share_stats(void); -#endif - -/* Supprime les mécanismes de partage des registres ARMv7. */ -void exit_armv7_register_sharing(void); - - -  #endif  /* _ARCH_ARM_V7_REGISTER_H */ diff --git a/src/arch/dalvik/core.c b/src/arch/dalvik/core.c index 15095a6..acf6ff5 100644 --- a/src/arch/dalvik/core.c +++ b/src/arch/dalvik/core.c @@ -24,12 +24,6 @@  #include "core.h" -#include "register.h" -#include "operands/args.h" -#include "operands/pool.h" -#include "operands/register.h" - -  /******************************************************************************  *                                                                             * @@ -49,12 +43,6 @@ bool init_dalvik_core(void)      result = true; -    result &= init_dalvik_register_sharing(); - -    result &= init_dalvik_args_operand_sharing(); -    result &= init_dalvik_pool_operand_sharing(); -    result &= init_dalvik_register_operand_sharing(); -      return result;  } @@ -64,30 +52,6 @@ bool init_dalvik_core(void)  *                                                                             *  *  Paramètres  : -                                                            *  *                                                                             * -*  Description : Imprime des statistiques quant aux partages dans l'archi.    * -*                                                                             * -*  Retour      : -                                                            * -*                                                                             * -*  Remarques   : -                                                            * -*                                                                             * -******************************************************************************/ -#ifdef DEBUG_DUMP_STATS -void dump_dalvik_share_stats(void) -{ -    dump_dalvik_register_share_stats(); - -    dump_dalvik_args_operand_share_stats(); -    dump_dalvik_pool_operand_share_stats(); -    dump_dalvik_register_operand_share_stats(); - -} -#endif - - -/****************************************************************************** -*                                                                             * -*  Paramètres  : -                                                            * -*                                                                             *  *  Description : Supprime les mécanismes internes de l'architecture Dalvik.   *  *                                                                             *  *  Retour      : -                                                            * @@ -98,10 +62,5 @@ void dump_dalvik_share_stats(void)  void exit_dalvik_core(void)  { -    exit_dalvik_register_sharing(); - -    exit_dalvik_args_operand_sharing(); -    exit_dalvik_pool_operand_sharing(); -    exit_dalvik_register_operand_sharing();  } diff --git a/src/arch/dalvik/core.h b/src/arch/dalvik/core.h index 8dd21dc..f22d0ea 100644 --- a/src/arch/dalvik/core.h +++ b/src/arch/dalvik/core.h @@ -32,11 +32,6 @@  /* Met en place les mécanismes internes de l'architecture. */  bool init_dalvik_core(void); -/* Imprime des statistiques quant aux partages dans l'archi. */ -#ifdef DEBUG_DUMP_STATS -void dump_dalvik_share_stats(void); -#endif -  /* Supprime les mécanismes internes de l'architecture Dalvik. */  void exit_dalvik_core(void); diff --git a/src/arch/dalvik/operand.c b/src/arch/dalvik/operand.c index 88dbc6e..e37a0bb 100644 --- a/src/arch/dalvik/operand.c +++ b/src/arch/dalvik/operand.c @@ -480,7 +480,7 @@ static bool dalvik_read_fixed_operands(GArchInstruction *instr, GDexFormat *form          op = g_dalvik_register_operand_new(content, pos, low, MDS_4_BITS, endian);          if (op == NULL) goto err_registers; -        args = G_ARCH_OPERAND(g_dalvik_args_operand_add(G_DALVIK_ARGS_OPERAND(args), op, NULL)); +        g_dalvik_args_operand_add(G_DALVIK_ARGS_OPERAND(args), op);      } @@ -493,7 +493,7 @@ static bool dalvik_read_fixed_operands(GArchInstruction *instr, GDexFormat *form      /* Rajout des éléments finaux déjà chargés */      if (a == 5) -        args = G_ARCH_OPERAND(g_dalvik_args_operand_add(G_DALVIK_ARGS_OPERAND(args), opg, NULL)); +        g_dalvik_args_operand_add(G_DALVIK_ARGS_OPERAND(args), opg);      else      { @@ -573,7 +573,7 @@ static bool dalvik_read_variatic_operands(GArchInstruction *instr, GDexFormat *f          op = g_dalvik_register_operand_new_from_existing(g_dalvik_register_new(c + i));          if (op == NULL) goto drvo_registers; -        args = G_ARCH_OPERAND(g_dalvik_args_operand_add(G_DALVIK_ARGS_OPERAND(args), op, NULL)); +        g_dalvik_args_operand_add(G_DALVIK_ARGS_OPERAND(args), op);      } diff --git a/src/arch/dalvik/operands/args.c b/src/arch/dalvik/operands/args.c index 2092e6b..f33f887 100644 --- a/src/arch/dalvik/operands/args.c +++ b/src/arch/dalvik/operands/args.c @@ -29,14 +29,10 @@  #include "../../operand-int.h" -#include "../../sharing/manager.h"  #include "../../../common/sort.h" -/* --------------------- MANIPULATION D'OPERANDES INDIVIDUELLES --------------------- */ - -  /* Définition d'un opérande visant une liste d'opérandes Dalvik (instance) */  struct _GDalvikArgsOperand  { @@ -68,15 +64,6 @@ static void g_dalvik_args_operand_dispose(GDalvikArgsOperand *);  /* Procède à la libération totale de la mémoire. */  static void g_dalvik_args_operand_finalize(GDalvikArgsOperand *); -/* Initialise un nouvel objet partagé avec des informations. */ -static bool g_dalvik_args_operand_apply_template(GDalvikArgsOperand *, const GDalvikArgsOperand *); - -/* Réalise une copie minimale d'un contenu partagé. */ -static void g_dalvik_args_operand_define_template(const GDalvikArgsOperand *, GDalvikArgsOperand *); - -/* Libère la mémoire utilisée par un patron d'instance. */ -static void g_dalvik_args_operand_free_template(const GDalvikArgsOperand *, GDalvikArgsOperand *); -  /* Compare un opérande avec un autre. */  static int g_dalvik_args_operand_compare(const GDalvikArgsOperand *, const GDalvikArgsOperand *); @@ -85,23 +72,6 @@ static void g_dalvik_args_operand_print(const GDalvikArgsOperand *, GBufferLine -/* -------------------------- PARTAGES DE CONTENUS UNIQUES -------------------------- */ - - -/* Gestionnaire des partages d'instances */ -static GShareManager *_dalvik_args_operand_manager = NULL; - - -/* Fournit le gestionnaire de partages attribué à un type. */ -static GShareManager *get_dalvik_args_operand_share_manager(void); - - - -/* ---------------------------------------------------------------------------------- */ -/*                       MANIPULATION D'OPERANDES INDIVIDUELLES                       */ -/* ---------------------------------------------------------------------------------- */ - -  /* Indique le type défini par la GLib pour une liste d'arguments Dalvik. */  G_DEFINE_TYPE(GDalvikArgsOperand, g_dalvik_args_operand, G_TYPE_ARCH_OPERAND); @@ -129,12 +99,6 @@ static void g_dalvik_args_operand_class_init(GDalvikArgsOperandClass *klass)      object->dispose = (GObjectFinalizeFunc/* ! */)g_dalvik_args_operand_dispose;      object->finalize = (GObjectFinalizeFunc)g_dalvik_args_operand_finalize; -    operand->get_manager = (get_operand_manager_fc)get_dalvik_args_operand_share_manager; - -    operand->apply_template = (apply_operand_template_fc)g_dalvik_args_operand_apply_template; -    operand->define_template = (define_operand_template_fc)g_dalvik_args_operand_define_template; -    operand->free_template = (free_operand_template_fc)g_dalvik_args_operand_free_template; -      operand->compare = (operand_compare_fc)g_dalvik_args_operand_compare;      operand->print = (operand_print_fc)g_dalvik_args_operand_print; @@ -204,101 +168,6 @@ static void g_dalvik_args_operand_finalize(GDalvikArgsOperand *operand)  /******************************************************************************  *                                                                             * -*  Paramètres  : operand  = objet partagé à initialiser.                      * -*                template = information à utiliser pour la mise en place.     * -*                                                                             * -*  Description : Initialise un nouvel objet partagé avec des informations.    * -*                                                                             * -*  Retour      : Bilan de l'opération.                                        * -*                                                                             * -*  Remarques   : -                                                            * -*                                                                             * -******************************************************************************/ - -static bool g_dalvik_args_operand_apply_template(GDalvikArgsOperand *operand, const GDalvikArgsOperand *template) -{ -    size_t i;                               /* Boucle de parcours          */ - -    if (template == NULL) -    { -        operand->args = NULL; -        operand->count = 0; -    } - -    else -    { -        g_dalvik_args_operand_define_template(template, operand); - -        for (i = 0; i < operand->count; i++) -            g_object_ref(G_OBJECT(operand->args[i])); - -    } - -    return true; - -} - - -/****************************************************************************** -*                                                                             * -*  Paramètres  : operand  = objet partagé à consulter.                        * -*                template = informations à retrouver intégralement.           * -*                                                                             * -*  Description : Réalise une copie minimale d'un contenu partagé.             * -*                                                                             * -*  Retour      : -                                                            * -*                                                                             * -*  Remarques   : -                                                            * -*                                                                             * -******************************************************************************/ - -static void g_dalvik_args_operand_define_template(const GDalvikArgsOperand *operand, GDalvikArgsOperand *template) -{ -    size_t i;                               /* Boucle de parcours          */ - -    if (operand->count == 0) -    { -        template->args = NULL; -        template->count = 0; -    } - -    else -    { -        template->args = (GArchOperand **)calloc(operand->count, sizeof(GArchOperand *)); - -        for (i = 0; i < operand->count; i++) -            template->args[i] = operand->args[i]; - -        template->count = operand->count; - -    } - -} - - -/****************************************************************************** -*                                                                             * -*  Paramètres  : operand  = objet partagé à consulter.                        * -*                template = informations dont le contenu est à libérer.       * -*                                                                             * -*  Description : Libère la mémoire utilisée par un patron d'instance.         * -*                                                                             * -*  Retour      : -                                                            * -*                                                                             * -*  Remarques   : -                                                            * -*                                                                             * -******************************************************************************/ - -static void g_dalvik_args_operand_free_template(const GDalvikArgsOperand *operand, GDalvikArgsOperand *template) -{ -    if (template != NULL && template->args != NULL) -        free(template->args); - -} - - -/****************************************************************************** -*                                                                             *  *  Paramètres  : a = premier opérande à consulter.                            *  *                b = second opérande à consulter.                             *  *                                                                             * @@ -389,7 +258,7 @@ GArchOperand *g_dalvik_args_operand_new(void)  {      GArchOperand *result;                   /* Structure à retourner       */ -    result = G_ARCH_OPERAND(g_share_manager_build(_dalvik_args_operand_manager, NULL)); +    result = g_object_new(G_TYPE_DALVIK_ARGS_OPERAND, NULL);      return result; @@ -409,26 +278,13 @@ GArchOperand *g_dalvik_args_operand_new(void)  *                                                                             *  ******************************************************************************/ -GDalvikArgsOperand *g_dalvik_args_operand_add(GDalvikArgsOperand *operand, GArchOperand *arg, GShareContainer *container) +void g_dalvik_args_operand_add(GDalvikArgsOperand *operand, GArchOperand *arg)  { -    GSharedInstance *result;                /* Nouvelle version à renvoyer */ -    GDalvikArgsOperand fake;                /* Transport d'informations    */ -    size_t i;                               /* Boucle de parcours          */ - -    fake.count = operand->count + 1; -    fake.args = (GArchOperand **)calloc(fake.count, sizeof(GArchOperand *)); - -    for (i = 0; i < operand->count; i++) -        fake.args[i] = operand->args[i]; - -    fake.args[i] = arg; -    result = g_share_manager_update(_dalvik_args_operand_manager, G_SHARED_INSTANCE(operand), -                                    (GSharedInstance *)&fake, container); +    operand->count++; +    operand->args = (GArchOperand **)realloc(operand->args, operand->count * sizeof(GArchOperand *)); -    free(fake.args); - -    return G_DALVIK_ARGS_OPERAND(result); +    operand->args[operand->count - 1] = arg;  } @@ -472,88 +328,3 @@ GArchOperand *g_dalvik_args_operand_get(const GDalvikArgsOperand *operand, size_      return operand->args[index];  } - - - -/* ---------------------------------------------------------------------------------- */ -/*                            PARTAGES DE CONTENUS UNIQUES                            */ -/* ---------------------------------------------------------------------------------- */ - - -/****************************************************************************** -*                                                                             * -*  Paramètres  : -                                                            * -*                                                                             * -*  Description : Fournit le gestionnaire de partages attribué à un type.      * -*                                                                             * -*  Retour      : Gestionnaire de partages en place.                           * -*                                                                             * -*  Remarques   : -                                                            * -*                                                                             * -******************************************************************************/ - -static GShareManager *get_dalvik_args_operand_share_manager(void) -{ -    return _dalvik_args_operand_manager; - -} - - -/****************************************************************************** -*                                                                             * -*  Paramètres  : -                                                            * -*                                                                             * -*  Description : Met en place les mécanismes de partage des opérandes Dalvik. * -*                                                                             * -*  Retour      : Bilan de l'opération.                                        * -*                                                                             * -*  Remarques   : -                                                            * -*                                                                             * -******************************************************************************/ - -bool init_dalvik_args_operand_sharing(void) -{ -    _dalvik_args_operand_manager = g_share_manager_new(G_TYPE_DALVIK_ARGS_OPERAND); - -    return true; - -} - - -/****************************************************************************** -*                                                                             * -*  Paramètres  : -                                                            * -*                                                                             * -*  Description : Imprime des statistiques quant aux partages dans l'archi.    * -*                                                                             * -*  Retour      : -                                                            * -*                                                                             * -*  Remarques   : -                                                            * -*                                                                             * -******************************************************************************/ -#ifdef DEBUG_DUMP_STATS -void dump_dalvik_args_operand_share_stats(void) -{ -    g_share_manager_dump_stats(_dalvik_args_operand_manager); - -} -#endif - - -/****************************************************************************** -*                                                                             * -*  Paramètres  : -                                                            * -*                                                                             * -*  Description : Supprime les mécanismes de partage des opérandes Dalvik.     * -*                                                                             * -*  Retour      : -                                                            * -*                                                                             * -*  Remarques   : -                                                            * -*                                                                             * -******************************************************************************/ - -void exit_dalvik_args_operand_sharing(void) -{ -    g_object_unref(G_OBJECT(_dalvik_args_operand_manager)); - -} diff --git a/src/arch/dalvik/operands/args.h b/src/arch/dalvik/operands/args.h index b4f5e69..993e551 100644 --- a/src/arch/dalvik/operands/args.h +++ b/src/arch/dalvik/operands/args.h @@ -29,13 +29,9 @@  #include "../../operand.h" -#include "../../sharing/container.h" -/* --------------------- MANIPULATION D'OPERANDES INDIVIDUELLES --------------------- */ - -  #define G_TYPE_DALVIK_ARGS_OPERAND                  g_dalvik_args_operand_get_type()  #define G_DALVIK_ARGS_OPERAND(obj)                  (G_TYPE_CHECK_INSTANCE_CAST((obj), g_dalvik_args_operand_get_type(), GDalvikArgsOperand))  #define G_IS_DALVIK_ARGS_OPERAND(obj)               (G_TYPE_CHECK_INSTANCE_TYPE((obj), g_dalvik_args_operand_get_type())) @@ -58,7 +54,7 @@ GType g_dalvik_args_operand_get_type(void);  GArchOperand *g_dalvik_args_operand_new(void);  /* Ajoute un élément à la liste d'arguments Dalvik. */ -GDalvikArgsOperand *g_dalvik_args_operand_add(GDalvikArgsOperand *, GArchOperand *, GShareContainer *); +void g_dalvik_args_operand_add(GDalvikArgsOperand *, GArchOperand *);  /* Fournit le nombre d'arguments pris en charge. */  size_t g_dalvik_args_count(const GDalvikArgsOperand *); @@ -68,20 +64,4 @@ GArchOperand *g_dalvik_args_operand_get(const GDalvikArgsOperand *, size_t); -/* -------------------------- PARTAGES DE CONTENUS UNIQUES -------------------------- */ - - -/* Met en place les mécanismes de partage des opérandes Dalvik. */ -bool init_dalvik_args_operand_sharing(void); - -/* Imprime des statistiques quant aux partages dans l'archi. */ -#ifdef DEBUG_DUMP_STATS -void dump_dalvik_args_operand_share_stats(void); -#endif - -/* Supprime les mécanismes de partage des opérandes Dalvik. */ -void exit_dalvik_args_operand_sharing(void); - - -  #endif  /* _ARCH_DALVIK_OPERANDS_ARGS_H */ diff --git a/src/arch/dalvik/operands/pool.c b/src/arch/dalvik/operands/pool.c index d97c93b..055f58e 100644 --- a/src/arch/dalvik/operands/pool.c +++ b/src/arch/dalvik/operands/pool.c @@ -32,15 +32,11 @@  #include "../../operand-int.h" -#include "../../sharing/manager.h"  #include "../../../common/sort.h"  #include "../../../format/dex/pool.h" -/* --------------------- MANIPULATION D'OPERANDES INDIVIDUELLES --------------------- */ - -  /* Définition d'un opérande visant un élément de table de constantes Dalvik (instance) */  struct _GDalvikPoolOperand  { @@ -73,12 +69,6 @@ static void g_dalvik_pool_operand_dispose(GDalvikPoolOperand *);  /* Procède à la libération totale de la mémoire. */  static void g_dalvik_pool_operand_finalize(GDalvikPoolOperand *); -/* Initialise un nouvel objet partagé avec des informations. */ -static bool g_dalvik_pool_operand_apply_template(GDalvikPoolOperand *, const GDalvikPoolOperand *); - -/* Réalise une copie minimale d'un contenu partagé. */ -static void g_dalvik_pool_operand_define_template(const GDalvikPoolOperand *, GDalvikPoolOperand *); -  /* Compare un opérande avec un autre. */  static int g_dalvik_pool_operand_compare(const GDalvikPoolOperand *, const GDalvikPoolOperand *); @@ -87,23 +77,6 @@ static void g_dalvik_pool_operand_print(const GDalvikPoolOperand *, GBufferLine -/* -------------------------- PARTAGES DE CONTENUS UNIQUES -------------------------- */ - - -/* Gestionnaire des partages d'instances */ -static GShareManager *_dalvik_pool_operand_manager = NULL; - - -/* Fournit le gestionnaire de partages attribué à un type. */ -static GShareManager *get_dalvik_pool_operand_share_manager(void); - - - -/* ---------------------------------------------------------------------------------- */ -/*                       MANIPULATION D'OPERANDES INDIVIDUELLES                       */ -/* ---------------------------------------------------------------------------------- */ - -  /* Indique le type défini par la GLib pour un un élément de table de constantes Dalvik. */  G_DEFINE_TYPE(GDalvikPoolOperand, g_dalvik_pool_operand, G_TYPE_ARCH_OPERAND); @@ -132,12 +105,6 @@ static void g_dalvik_pool_operand_class_init(GDalvikPoolOperandClass *klass)      operand = G_ARCH_OPERAND_CLASS(klass); -    operand->get_manager = (get_operand_manager_fc)get_dalvik_pool_operand_share_manager; - -    operand->apply_template = (apply_operand_template_fc)g_dalvik_pool_operand_apply_template; -    operand->define_template = (define_operand_template_fc)g_dalvik_pool_operand_define_template; -    operand->free_template = (free_operand_template_fc)NULL; -      operand->compare = (operand_compare_fc)g_dalvik_pool_operand_compare;      operand->print = (operand_print_fc)g_dalvik_pool_operand_print; @@ -204,53 +171,6 @@ static void g_dalvik_pool_operand_finalize(GDalvikPoolOperand *operand)  /******************************************************************************  *                                                                             * -*  Paramètres  : operand  = objet partagé à initialiser.                      * -*                template = information à utiliser pour la mise en place.     * -*                                                                             * -*  Description : Initialise un nouvel objet partagé avec des informations.    * -*                                                                             * -*  Retour      : Bilan de l'opération.                                        * -*                                                                             * -*  Remarques   : -                                                            * -*                                                                             * -******************************************************************************/ - -static bool g_dalvik_pool_operand_apply_template(GDalvikPoolOperand *operand, const GDalvikPoolOperand *template) -{ -    g_dalvik_pool_operand_define_template(template, operand); - -    g_object_ref(G_OBJECT(operand->format)); - -    return true; - -} - - -/****************************************************************************** -*                                                                             * -*  Paramètres  : operand  = objet partagé à consulter.                        * -*                template = informations à retrouver intégralement.           * -*                                                                             * -*  Description : Réalise une copie minimale d'un contenu partagé.             * -*                                                                             * -*  Retour      : -                                                            * -*                                                                             * -*  Remarques   : -                                                            * -*                                                                             * -******************************************************************************/ - -static void g_dalvik_pool_operand_define_template(const GDalvikPoolOperand *operand, GDalvikPoolOperand *template) -{ -    template->format = operand->format; - -    template->type = operand->type; -    template->index = operand->index; - -} - - -/****************************************************************************** -*                                                                             *  *  Paramètres  : a = premier opérande à consulter.                            *  *                b = second opérande à consulter.                             *  *                                                                             * @@ -459,13 +379,10 @@ static void g_dalvik_pool_operand_print(const GDalvikPoolOperand *operand, GBuff  GArchOperand *g_dalvik_pool_operand_new(GDexFormat *format, DalvikPoolType type, const GBinContent *content, vmpa2t *pos, MemoryDataSize size, SourceEndian endian)  { -    GArchOperand *result;                   /* Structure à retourner       */ +    GDalvikPoolOperand *result;             /* Structure à retourner       */      uint8_t index8;                         /* Indice sur 8 bits           */      uint16_t index16;                       /* Indice sur 16 bits          */      bool test;                              /* Bilan de lecture            */ -    GDalvikPoolOperand fake;                /* Transport d'informations    */ - -    result = NULL;      switch (size)      { @@ -483,15 +400,17 @@ GArchOperand *g_dalvik_pool_operand_new(GDexFormat *format, DalvikPoolType type,      if (!test)          goto gdpon_exit; -    fake.format = format; -    fake.type = type; -    fake.index = (size == MDS_8_BITS ? index8 : index16); +    result = g_object_new(G_TYPE_DALVIK_POOL_OPERAND, NULL); + +    result->format = format; +    result->type = type; +    result->index = (size == MDS_8_BITS ? index8 : index16); -    result = G_ARCH_OPERAND(g_share_manager_build(_dalvik_pool_operand_manager, (GSharedInstance *)&fake)); +    return G_ARCH_OPERAND(result);   gdpon_exit: -    return result; +    return NULL;  } @@ -532,88 +451,3 @@ uint32_t g_dalvik_pool_operand_get_index(const GDalvikPoolOperand *operand)      return operand->index;  } - - - -/* ---------------------------------------------------------------------------------- */ -/*                            PARTAGES DE CONTENUS UNIQUES                            */ -/* ---------------------------------------------------------------------------------- */ - - -/****************************************************************************** -*                                                                             * -*  Paramètres  : -                                                            * -*                                                                             * -*  Description : Fournit le gestionnaire de partages attribué à un type.      * -*                                                                             * -*  Retour      : Gestionnaire de partages en place.                           * -*                                                                             * -*  Remarques   : -                                                            * -*                                                                             * -******************************************************************************/ - -static GShareManager *get_dalvik_pool_operand_share_manager(void) -{ -    return _dalvik_pool_operand_manager; - -} - - -/****************************************************************************** -*                                                                             * -*  Paramètres  : -                                                            * -*                                                                             * -*  Description : Met en place les mécanismes de partage des opérandes Dalvik. * -*                                                                             * -*  Retour      : Bilan de l'opération.                                        * -*                                                                             * -*  Remarques   : -                                                            * -*                                                                             * -******************************************************************************/ - -bool init_dalvik_pool_operand_sharing(void) -{ -    _dalvik_pool_operand_manager = g_share_manager_new(G_TYPE_DALVIK_POOL_OPERAND); - -    return true; - -} - - -/****************************************************************************** -*                                                                             * -*  Paramètres  : -                                                            * -*                                                                             * -*  Description : Imprime des statistiques quant aux partages dans l'archi.    * -*                                                                             * -*  Retour      : -                                                            * -*                                                                             * -*  Remarques   : -                                                            * -*                                                                             * -******************************************************************************/ -#ifdef DEBUG_DUMP_STATS -void dump_dalvik_pool_operand_share_stats(void) -{ -    g_share_manager_dump_stats(_dalvik_pool_operand_manager); - -} -#endif - - -/****************************************************************************** -*                                                                             * -*  Paramètres  : -                                                            * -*                                                                             * -*  Description : Supprime les mécanismes de partage des opérandes Dalvik.     * -*                                                                             * -*  Retour      : -                                                            * -*                                                                             * -*  Remarques   : -                                                            * -*                                                                             * -******************************************************************************/ - -void exit_dalvik_pool_operand_sharing(void) -{ -    g_object_unref(G_OBJECT(_dalvik_pool_operand_manager)); - -} diff --git a/src/arch/dalvik/operands/pool.h b/src/arch/dalvik/operands/pool.h index f382128..3319f66 100644 --- a/src/arch/dalvik/operands/pool.h +++ b/src/arch/dalvik/operands/pool.h @@ -35,9 +35,6 @@ -/* --------------------- MANIPULATION D'OPERANDES INDIVIDUELLES --------------------- */ - -  #define G_TYPE_DALVIK_POOL_OPERAND            g_dalvik_pool_operand_get_type()  #define G_DALVIK_POOL_OPERAND(obj)            (G_TYPE_CHECK_INSTANCE_CAST((obj), G_TYPE_DALVIK_POOL_OPERAND, GDalvikPoolOperand))  #define G_IS_DALVIK_POOL_OPERAND(obj)         (G_TYPE_CHECK_INSTANCE_TYPE((obj), G_TYPE_DALVIK_POOL_OPERAND)) @@ -80,20 +77,4 @@ uint32_t g_dalvik_pool_operand_get_index(const GDalvikPoolOperand *); -/* -------------------------- PARTAGES DE CONTENUS UNIQUES -------------------------- */ - - -/* Met en place les mécanismes de partage des opérandes Dalvik. */ -bool init_dalvik_pool_operand_sharing(void); - -/* Imprime des statistiques quant aux partages dans l'archi. */ -#ifdef DEBUG_DUMP_STATS -void dump_dalvik_pool_operand_share_stats(void); -#endif - -/* Supprime les mécanismes de partage des opérandes Dalvik. */ -void exit_dalvik_pool_operand_sharing(void); - - -  #endif  /* _ARCH_DALVIK_OPERANDS_POOL_H */ diff --git a/src/arch/dalvik/operands/register.c b/src/arch/dalvik/operands/register.c index cf29455..1516e8e 100644 --- a/src/arch/dalvik/operands/register.c +++ b/src/arch/dalvik/operands/register.c @@ -26,13 +26,9 @@  #include "../../operand-int.h"  #include "../../register.h" -#include "../../sharing/manager.h" -/* --------------------- MANIPULATION D'OPERANDES INDIVIDUELLES --------------------- */ - -  /* Définition d'un opérande visant un registre Dalvik (instance) */  struct _GDalvikRegisterOperand  { @@ -64,12 +60,6 @@ static void g_dalvik_register_operand_dispose(GDalvikRegisterOperand *);  /* Procède à la libération totale de la mémoire. */  static void g_dalvik_register_operand_finalize(GDalvikRegisterOperand *); -/* Initialise un nouvel objet partagé avec des informations. */ -static bool g_dalvik_register_operand_apply_template(GDalvikRegisterOperand *, const GDalvikRegisterOperand *); - -/* Réalise une copie minimale d'un contenu partagé. */ -static void g_dalvik_register_operand_define_template(const GDalvikRegisterOperand *, GDalvikRegisterOperand *); -  /* Compare un opérande avec un autre. */  static int g_dalvik_register_operand_compare(const GDalvikRegisterOperand *, const GDalvikRegisterOperand *); @@ -78,23 +68,6 @@ static void g_dalvik_register_operand_print(const GDalvikRegisterOperand *, GBuf -/* -------------------------- PARTAGES DE CONTENUS UNIQUES -------------------------- */ - - -/* Gestionnaire des partages d'instances */ -static GShareManager *_dalvik_register_operand_manager = NULL; - - -/* Fournit le gestionnaire de partages attribué à un type. */ -static GShareManager *get_dalvik_register_operand_share_manager(void); - - - -/* ---------------------------------------------------------------------------------- */ -/*                       MANIPULATION D'OPERANDES INDIVIDUELLES                       */ -/* ---------------------------------------------------------------------------------- */ - -  /* Indique le type défini par la GLib pour un opérande de registre Dalvik. */  G_DEFINE_TYPE(GDalvikRegisterOperand, g_dalvik_register_operand, G_TYPE_ARCH_OPERAND); @@ -123,12 +96,6 @@ static void g_dalvik_register_operand_class_init(GDalvikRegisterOperandClass *kl      operand = G_ARCH_OPERAND_CLASS(klass); -    operand->get_manager = (get_operand_manager_fc)get_dalvik_register_operand_share_manager; - -    operand->apply_template = (apply_operand_template_fc)g_dalvik_register_operand_apply_template; -    operand->define_template = (define_operand_template_fc)g_dalvik_register_operand_define_template; -    operand->free_template = (free_operand_template_fc)NULL; -      operand->compare = (operand_compare_fc)g_dalvik_register_operand_compare;      operand->print = (operand_print_fc)g_dalvik_register_operand_print; @@ -194,50 +161,6 @@ static void g_dalvik_register_operand_finalize(GDalvikRegisterOperand *operand)  /******************************************************************************  *                                                                             * -*  Paramètres  : operand  = objet partagé à initialiser.                      * -*                template = information à utiliser pour la mise en place.     * -*                                                                             * -*  Description : Initialise un nouvel objet partagé avec des informations.    * -*                                                                             * -*  Retour      : Bilan de l'opération.                                        * -*                                                                             * -*  Remarques   : -                                                            * -*                                                                             * -******************************************************************************/ - -static bool g_dalvik_register_operand_apply_template(GDalvikRegisterOperand *operand, const GDalvikRegisterOperand *template) -{ -    g_dalvik_register_operand_define_template(template, operand); - -    g_object_ref(G_OBJECT(operand->reg)); - -    return true; - -} - - -/****************************************************************************** -*                                                                             * -*  Paramètres  : operand  = objet partagé à consulter.                        * -*                template = informations à retrouver intégralement.           * -*                                                                             * -*  Description : Réalise une copie minimale d'un contenu partagé.             * -*                                                                             * -*  Retour      : -                                                            * -*                                                                             * -*  Remarques   : -                                                            * -*                                                                             * -******************************************************************************/ - -static void g_dalvik_register_operand_define_template(const GDalvikRegisterOperand *operand, GDalvikRegisterOperand *template) -{ -    template->reg = operand->reg; - -} - - -/****************************************************************************** -*                                                                             *  *  Paramètres  : a = premier opérande à consulter.                            *  *                b = second opérande à consulter.                             *  *                                                                             * @@ -349,9 +272,11 @@ GArchOperand *g_dalvik_register_operand_new(const GBinContent *content, vmpa2t *      } +    return result; +   gdron_exit: -    return result; +    return NULL;  } @@ -370,14 +295,13 @@ GArchOperand *g_dalvik_register_operand_new(const GBinContent *content, vmpa2t *  GArchOperand *g_dalvik_register_operand_new_from_existing(GDalvikRegister *reg)  { -    GArchOperand *result;                   /* Structure à retourner       */ -    GDalvikRegisterOperand fake;            /* Transport d'informations    */ +    GDalvikRegisterOperand *result;         /* Structure à retourner       */ -    fake.reg = reg; +    result = g_object_new(G_TYPE_DALVIK_REGISTER_OPERAND, NULL); -    result = G_ARCH_OPERAND(g_share_manager_build(_dalvik_register_operand_manager, (GSharedInstance *)&fake)); +    result->reg = reg; -    return result; +    return G_ARCH_OPERAND(result);  } @@ -437,88 +361,3 @@ bool g_dalvik_register_operand_is_written(const GDalvikRegisterOperand *operand)      return operand->is_written;  } - - - -/* ---------------------------------------------------------------------------------- */ -/*                            PARTAGES DE CONTENUS UNIQUES                            */ -/* ---------------------------------------------------------------------------------- */ - - -/****************************************************************************** -*                                                                             * -*  Paramètres  : -                                                            * -*                                                                             * -*  Description : Fournit le gestionnaire de partages attribué à un type.      * -*                                                                             * -*  Retour      : Gestionnaire de partages en place.                           * -*                                                                             * -*  Remarques   : -                                                            * -*                                                                             * -******************************************************************************/ - -static GShareManager *get_dalvik_register_operand_share_manager(void) -{ -    return _dalvik_register_operand_manager; - -} - - -/****************************************************************************** -*                                                                             * -*  Paramètres  : -                                                            * -*                                                                             * -*  Description : Met en place les mécanismes de partage des opérandes Dalvik. * -*                                                                             * -*  Retour      : Bilan de l'opération.                                        * -*                                                                             * -*  Remarques   : -                                                            * -*                                                                             * -******************************************************************************/ - -bool init_dalvik_register_operand_sharing(void) -{ -    _dalvik_register_operand_manager = g_share_manager_new(G_TYPE_DALVIK_REGISTER_OPERAND); - -    return true; - -} - - -/****************************************************************************** -*                                                                             * -*  Paramètres  : -                                                            * -*                                                                             * -*  Description : Imprime des statistiques quant aux partages dans l'archi.    * -*                                                                             * -*  Retour      : -                                                            * -*                                                                             * -*  Remarques   : -                                                            * -*                                                                             * -******************************************************************************/ -#ifdef DEBUG_DUMP_STATS -void dump_dalvik_register_operand_share_stats(void) -{ -    g_share_manager_dump_stats(_dalvik_register_operand_manager); - -} -#endif - - -/****************************************************************************** -*                                                                             * -*  Paramètres  : -                                                            * -*                                                                             * -*  Description : Supprime les mécanismes de partage des opérandes Dalvik.     * -*                                                                             * -*  Retour      : -                                                            * -*                                                                             * -*  Remarques   : -                                                            * -*                                                                             * -******************************************************************************/ - -void exit_dalvik_register_operand_sharing(void) -{ -    g_object_unref(G_OBJECT(_dalvik_register_operand_manager)); - -} diff --git a/src/arch/dalvik/operands/register.h b/src/arch/dalvik/operands/register.h index eeb7697..5798e5c 100644 --- a/src/arch/dalvik/operands/register.h +++ b/src/arch/dalvik/operands/register.h @@ -35,9 +35,6 @@ -/* --------------------- MANIPULATION D'OPERANDES INDIVIDUELLES --------------------- */ - -  #define G_TYPE_DALVIK_REGISTER_OPERAND            g_dalvik_register_operand_get_type()  #define G_DALVIK_REGISTER_OPERAND(obj)            (G_TYPE_CHECK_INSTANCE_CAST((obj), G_TYPE_DALVIK_REGISTER_OPERAND, GDalvikRegisterOperand))  #define G_IS_DALVIK_REGISTER_OPERAND(obj)         (G_TYPE_CHECK_INSTANCE_TYPE((obj), G_TYPE_DALVIK_REGISTER_OPERAND)) @@ -73,20 +70,4 @@ bool g_dalvik_register_operand_is_written(const GDalvikRegisterOperand *); -/* -------------------------- PARTAGES DE CONTENUS UNIQUES -------------------------- */ - - -/* Met en place les mécanismes de partage des opérandes Dalvik. */ -bool init_dalvik_register_operand_sharing(void); - -/* Imprime des statistiques quant aux partages dans l'archi. */ -#ifdef DEBUG_DUMP_STATS -void dump_dalvik_register_operand_share_stats(void); -#endif - -/* Supprime les mécanismes de partage des opérandes Dalvik. */ -void exit_dalvik_register_operand_sharing(void); - - -  #endif  /* _ARCH_DALVIK_OPERANDS_REGISTER_H */ diff --git a/src/arch/dalvik/register.c b/src/arch/dalvik/register.c index 2b5a285..068b925 100644 --- a/src/arch/dalvik/register.c +++ b/src/arch/dalvik/register.c @@ -28,14 +28,10 @@  #include "../register-int.h" -#include "../sharing/manager.h"  #include "../../common/sort.h" -/* ------------------------- ENCADREMENT DE REGISTRES BRUTS ------------------------- */ - -  /* Représentation d'un registre Dalvik (instance) */  struct _GDalvikRegister  { @@ -69,9 +65,6 @@ static void g_dalvik_register_dispose(GDalvikRegister *);  /* Procède à la libération totale de la mémoire. */  static void g_dalvik_register_finalize(GDalvikRegister *); -/* Réalise une copie minimale d'un contenu partagé. */ -static void g_dalvik_register_define_template(const GDalvikRegister *, GDalvikRegister *); -  /* Produit une empreinte à partir d'un registre. */  static guint g_dalvik_register_hash(const GDalvikRegister *); @@ -80,23 +73,6 @@ static void g_dalvik_register_print(const GDalvikRegister *, GBufferLine *, AsmS -/* -------------------------- PARTAGES DE CONTENUS UNIQUES -------------------------- */ - - -/* Gestionnaire des partages d'instances */ -static GShareManager *_dalvik_register_manager = NULL; - - -/* Fournit le gestionnaire de partages attribué à un type. */ -static GShareManager *get_dalvik_register_share_manager(void); - - - -/* ---------------------------------------------------------------------------------- */ -/*                           ENCADREMENT DE REGISTRES BRUTS                           */ -/* ---------------------------------------------------------------------------------- */ - -  /* Indique le type défini pour une représentation d'un registre Dalvik. */  G_DEFINE_TYPE(GDalvikRegister, g_dalvik_register, G_TYPE_ARCH_REGISTER); @@ -125,10 +101,6 @@ static void g_dalvik_register_class_init(GDalvikRegisterClass *klass)      register_class = G_ARCH_REGISTER_CLASS(klass); -    register_class->get_manager = (get_register_manager_fc)get_dalvik_register_share_manager; - -    register_class->define_template = (define_register_template_fc)g_dalvik_register_define_template; -      register_class->hash = (reg_hash_fc)g_dalvik_register_hash;      register_class->compare = (reg_compare_fc)g_dalvik_register_compare;      register_class->print = (reg_print_fc)g_dalvik_register_print; @@ -194,26 +166,6 @@ static void g_dalvik_register_finalize(GDalvikRegister *reg)  /******************************************************************************  *                                                                             * -*  Paramètres  : reg      = objet partagé à consulter.                        * -*                template = informations à retrouver intégralement.           * -*                                                                             * -*  Description : Réalise une copie minimale d'un contenu partagé.             * -*                                                                             * -*  Retour      : -                                                            * -*                                                                             * -*  Remarques   : -                                                            * -*                                                                             * -******************************************************************************/ - -static void g_dalvik_register_define_template(const GDalvikRegister *reg, GDalvikRegister *template) -{ -    template->index = reg->index; - -} - - -/****************************************************************************** -*                                                                             *  *  Paramètres  : reg = opérande à consulter pour le calcul.                   *  *                                                                             *  *  Description : Produit une empreinte à partir d'un registre.                * @@ -286,11 +238,10 @@ static void g_dalvik_register_print(const GDalvikRegister *reg, GBufferLine *lin  GDalvikRegister *g_dalvik_register_new(uint16_t index)  {      GDalvikRegister *result;                /* Structure à retourner       */ -    GDalvikRegister template;               /* Transport d'informations    */ -    template.index = index; +    result = g_object_new(G_TYPE_DALVIK_REGISTER, NULL); -    result = G_DALVIK_REGISTER(g_share_manager_build(_dalvik_register_manager, (GSharedInstance *)&template)); +    result->index = index;      return result; @@ -338,87 +289,3 @@ int g_dalvik_register_compare(const GDalvikRegister *a, const GDalvikRegister *b      return result;  } - - -/* ---------------------------------------------------------------------------------- */ -/*                            PARTAGES DE CONTENUS UNIQUES                            */ -/* ---------------------------------------------------------------------------------- */ - - -/****************************************************************************** -*                                                                             * -*  Paramètres  : -                                                            * -*                                                                             * -*  Description : Fournit le gestionnaire de partages attribué à un type.      * -*                                                                             * -*  Retour      : Gestionnaire de partages en place.                           * -*                                                                             * -*  Remarques   : -                                                            * -*                                                                             * -******************************************************************************/ - -static GShareManager *get_dalvik_register_share_manager(void) -{ -    return _dalvik_register_manager; - -} - - -/****************************************************************************** -*                                                                             * -*  Paramètres  : -                                                            * -*                                                                             * -*  Description : Met en place les mécanismes de partage des registres Dalvik. * -*                                                                             * -*  Retour      : Bilan de l'opération.                                        * -*                                                                             * -*  Remarques   : -                                                            * -*                                                                             * -******************************************************************************/ - -bool init_dalvik_register_sharing(void) -{ -    _dalvik_register_manager = g_share_manager_new(G_TYPE_DALVIK_REGISTER); - -    return true; - -} - - -/****************************************************************************** -*                                                                             * -*  Paramètres  : -                                                            * -*                                                                             * -*  Description : Imprime des statistiques quant aux partages dans l'archi.    * -*                                                                             * -*  Retour      : -                                                            * -*                                                                             * -*  Remarques   : -                                                            * -*                                                                             * -******************************************************************************/ -#ifdef DEBUG_DUMP_STATS -void dump_dalvik_register_share_stats(void) -{ -    g_share_manager_dump_stats(_dalvik_register_manager); - -} -#endif - - -/****************************************************************************** -*                                                                             * -*  Paramètres  : -                                                            * -*                                                                             * -*  Description : Supprime les mécanismes de partage des registres Dalvik.     * -*                                                                             * -*  Retour      : -                                                            * -*                                                                             * -*  Remarques   : -                                                            * -*                                                                             * -******************************************************************************/ - -void exit_dalvik_register_sharing(void) -{ -    g_object_unref(G_OBJECT(_dalvik_register_manager)); - -} diff --git a/src/arch/dalvik/register.h b/src/arch/dalvik/register.h index 3bd6286..b20bdf5 100644 --- a/src/arch/dalvik/register.h +++ b/src/arch/dalvik/register.h @@ -34,9 +34,6 @@ -/* ------------------------- ENCADREMENT DE REGISTRES BRUTS ------------------------- */ - -  #define G_TYPE_DALVIK_REGISTER               g_dalvik_register_get_type()  #define G_DALVIK_REGISTER(obj)               (G_TYPE_CHECK_INSTANCE_CAST((obj), g_dalvik_register_get_type(), GDalvikRegister))  #define G_IS_DALVIK_REGISTER(obj)            (G_TYPE_CHECK_INSTANCE_TYPE((obj), g_dalvik_register_get_type())) @@ -66,20 +63,4 @@ int g_dalvik_register_compare(const GDalvikRegister *, const GDalvikRegister *); -/* -------------------------- PARTAGES DE CONTENUS UNIQUES -------------------------- */ - - -/* Met en place les mécanismes de partage des registres Dalvik. */ -bool init_dalvik_register_sharing(void); - -/* Imprime des statistiques quant aux partages dans l'archi. */ -#ifdef DEBUG_DUMP_STATS -void dump_dalvik_register_share_stats(void); -#endif - -/* Supprime les mécanismes de partage des registres Dalvik. */ -void exit_dalvik_register_sharing(void); - - -  #endif  /* _ARCH_DALVIK_REGISTERS_H */ diff --git a/src/arch/immediate.c b/src/arch/immediate.c index 9c807db..25630bf 100644 --- a/src/arch/immediate.c +++ b/src/arch/immediate.c @@ -38,16 +38,12 @@  #include "operand-int.h" -#include "sharing/manager.h"  #include "../common/asm.h"  #include "../common/extstr.h"  #include "../format/format.h" -/* ------------------ MANIPULATION D'OPERANDES DE VALEUR IMMEDIATE ------------------ */ - -  /* Définition d'un opérande de valeur numérique (instance) */  struct _GImmOperand  { @@ -96,9 +92,6 @@ static void g_imm_operand_dispose(GImmOperand *);  /* Procède à la libération totale de la mémoire. */  static void g_imm_operand_finalize(GImmOperand *); -/* Réalise une copie minimale d'un contenu partagé. */ -static void g_imm_operand_define_template(const GImmOperand *, GImmOperand *); -  /* Compare un opérande avec un autre. */  static int g_imm_operand_compare(const GImmOperand *, const GImmOperand *); @@ -116,23 +109,6 @@ static char *g_imm_operand_build_tooltip(const GImmOperand *, const GLoadedBinar -/* -------------------------- PARTAGES DE CONTENUS UNIQUES -------------------------- */ - - -/* Gestionnaire des partages d'instances */ -static GShareManager *_imm_operand_manager = NULL; - - -/* Fournit le gestionnaire de partages attribué à un type. */ -static GShareManager *get_imm_operand_share_manager(void); - - - -/* ---------------------------------------------------------------------------------- */ -/*                    MANIPULATION D'OPERANDES DE VALEUR IMMEDIATE                    */ -/* ---------------------------------------------------------------------------------- */ - -  /* Indique le type défini pour un opérande de valeur numérique. */  G_DEFINE_TYPE(GImmOperand, g_imm_operand, G_TYPE_ARCH_OPERAND); @@ -161,12 +137,6 @@ static void g_imm_operand_class_init(GImmOperandClass *klass)      object->dispose = (GObjectFinalizeFunc/* ! */)g_imm_operand_dispose;      object->finalize = (GObjectFinalizeFunc)g_imm_operand_finalize; -    operand->get_manager = (get_operand_manager_fc)get_imm_operand_share_manager; - -    operand->apply_template = (apply_operand_template_fc)NULL; -    operand->define_template = (define_operand_template_fc)g_imm_operand_define_template; -    operand->free_template = (free_operand_template_fc)NULL; -      operand->compare = (operand_compare_fc)g_imm_operand_compare;      operand->print = (operand_print_fc)g_imm_operand_print;      operand->build_tooltip = (operand_build_tooltip_fc)g_imm_operand_build_tooltip; @@ -252,8 +222,7 @@ static void g_imm_operand_finalize(GImmOperand *operand)  GArchOperand *_g_imm_operand_new_from_data(MemoryDataSize size, const GBinContent *content, vmpa2t *addr, bool *low, SourceEndian endian)  { -    GArchOperand *result;                   /* Opérande à retourner        */ -    GImmOperand fake;                       /* Transport d'informations    */ +    GImmOperand *result;                    /* Opérande à retourner        */      uint8_t uval8;                          /* Valeur sur 8 bits           */      uint16_t uval16;                        /* Valeur sur 16 bits          */      uint32_t uval32;                        /* Valeur sur 32 bits          */ @@ -263,70 +232,70 @@ GArchOperand *_g_imm_operand_new_from_data(MemoryDataSize size, const GBinConten      int32_t sval32;                         /* Valeur sur 32 bits          */      int64_t sval64;                         /* Valeur sur 64 bits          */ -    g_imm_operand_init(&fake); +    result = g_object_new(G_TYPE_IMM_OPERAND, NULL); -    fake.size = size; +    result->size = size;      switch (size)      {          case MDS_4_BITS_UNSIGNED:              if (!g_binary_content_read_u4(content, addr, low, &uval8))                  goto gionfd_error; -            fake.raw = uval8; +            result->raw = uval8;              break;          case MDS_8_BITS_UNSIGNED:              if (!g_binary_content_read_u8(content, addr, &uval8))                  goto gionfd_error; -            fake.raw = uval8; +            result->raw = uval8;              break;          case MDS_16_BITS_UNSIGNED:              if (!g_binary_content_read_u16(content, addr, endian, &uval16))                  goto gionfd_error; -            fake.raw = uval16; +            result->raw = uval16;              break;          case MDS_32_BITS_UNSIGNED:              if (!g_binary_content_read_u32(content, addr, endian, &uval32))                  goto gionfd_error; -            fake.raw = uval32; +            result->raw = uval32;              break;          case MDS_64_BITS_UNSIGNED:              if (!g_binary_content_read_u64(content, addr, endian, &uval64))                  goto gionfd_error; -            fake.raw = uval64; +            result->raw = uval64;              break;          case MDS_4_BITS_SIGNED:              if (!g_binary_content_read_s4(content, addr, low, &sval8))                  goto gionfd_error; -            fake.raw = sval8; +            result->raw = sval8;              break;          case MDS_8_BITS_SIGNED:              if (!g_binary_content_read_s8(content, addr, &sval8))                  goto gionfd_error; -            fake.raw = sval8; +            result->raw = sval8;              break;          case MDS_16_BITS_SIGNED:              if (!g_binary_content_read_s16(content, addr, endian, &sval16))                  goto gionfd_error; -            fake.raw = sval16; +            result->raw = sval16;              break;          case MDS_32_BITS_SIGNED:              if (!g_binary_content_read_s32(content, addr, endian, &sval32))                  goto gionfd_error; -            fake.raw = sval32; +            result->raw = sval32;              break;          case MDS_64_BITS_SIGNED:              if (!g_binary_content_read_s64(content, addr, endian, &sval64))                  goto gionfd_error; -            fake.raw = sval64; +            result->raw = sval64;              break;          case MDS_UNDEFINED: @@ -335,12 +304,12 @@ GArchOperand *_g_imm_operand_new_from_data(MemoryDataSize size, const GBinConten      } -    result = G_ARCH_OPERAND(g_share_manager_build(_imm_operand_manager, (GSharedInstance *)&fake)); - -    return result; +    return G_ARCH_OPERAND(result);   gionfd_error: +    g_object_unref(G_OBJECT(result)); +      return NULL;  } @@ -361,49 +330,21 @@ GArchOperand *_g_imm_operand_new_from_data(MemoryDataSize size, const GBinConten  GArchOperand *g_imm_operand_new_from_value(MemoryDataSize size, uint64_t value)  { -    GArchOperand *result;                   /* Opérande à retourner        */ -    GImmOperand fake;                       /* Transport d'informations    */ +    GImmOperand *result;                    /* Opérande à retourner        */      if (size == MDS_UNDEFINED)          result = NULL;      else      { -        g_imm_operand_init(&fake); - -        fake.size = size; -        fake.raw = value; +        result = g_object_new(G_TYPE_IMM_OPERAND, NULL); -        result = G_ARCH_OPERAND(g_share_manager_build(_imm_operand_manager, (GSharedInstance *)&fake)); +        result->size = size; +        result->raw = value;      } -    return result; - -} - - -/****************************************************************************** -*                                                                             * -*  Paramètres  : operand  = objet partagé à consulter.                        * -*                template = informations à retrouver intégralement.           * -*                                                                             * -*  Description : Réalise une copie minimale d'un contenu partagé.             * -*                                                                             * -*  Retour      : -                                                            * -*                                                                             * -*  Remarques   : -                                                            * -*                                                                             * -******************************************************************************/ - -static void g_imm_operand_define_template(const GImmOperand *operand, GImmOperand *template) -{ -    template->raw = operand->raw; -    template->size = operand->size; - -    template->def_display = operand->def_display; -    template->display = operand->display; -    template->misc = operand->misc; +    return (result != NULL ? G_ARCH_OPERAND(result) : NULL);  } @@ -627,12 +568,12 @@ uint64_t g_imm_operand_get_raw_value(const GImmOperand *operand)  } +  /******************************************************************************  *                                                                             * -*  Paramètres  : operand   = structure dont le contenu est à actualiser. [OUT]* -*                size      = taille de l'opérande souhaitée.                  * -*                value     = valeur sur x bits à venir récupérer.             * -*                container = propriétaire d'origine à tenir au courant.       * +*  Paramètres  : operand = structure dont le contenu est à actualiser. [OUT]  * +*                size    = taille de l'opérande souhaitée.                    * +*                value   = valeur sur x bits à venir récupérer.               *  *                                                                             *  *  Description : Définit la nouvelle valeur de l'opérande à une valeur.       *  *                                                                             * @@ -642,32 +583,20 @@ uint64_t g_imm_operand_get_raw_value(const GImmOperand *operand)  *                                                                             *  ******************************************************************************/ -void g_imm_operand_set_value(GImmOperand **operand, MemoryDataSize size, uint64_t value, GShareContainer *container) +void g_imm_operand_set_value(GImmOperand *operand, MemoryDataSize size, uint64_t value)  { -    GSharedInstance *shared;                /* Instace de travail partagée */ -    GImmOperand template;                   /* Transport d'informations    */ -      assert(size != MDS_UNDEFINED); -    shared = G_SHARED_INSTANCE(*operand); - -    g_shared_instance_define_template(shared, (GSharedInstance *)&template); - -    template.size = size; -    template.raw = value; - -    shared = g_share_manager_update(_imm_operand_manager, shared, (GSharedInstance *)&template, container); - -    *operand = G_IMM_OPERAND(shared); +    operand->size = size; +    operand->raw = value;  }  /******************************************************************************  *                                                                             * -*  Paramètres  : operand   = structure dont le contenu est à actualiser. [OUT]* -*                state     = true si des zéro sont à ajouter, false sinon.    * -*                container = propriétaire d'origine à tenir au courant.       * +*  Paramètres  : operand = structure dont le contenu est à actualiser. [OUT]  * +*                state   = true si des zéro sont à ajouter, false sinon.      *  *                                                                             *  *  Description : Précise si des zéro doivent compléter l'affichage ou non.    *  *                                                                             * @@ -677,20 +606,9 @@ void g_imm_operand_set_value(GImmOperand **operand, MemoryDataSize size, uint64_  *                                                                             *  ******************************************************************************/ -void g_imm_operand_pad_by_default(GImmOperand **operand, bool state, GShareContainer *container) +void g_imm_operand_pad_by_default(GImmOperand *operand, bool state)  { -    GSharedInstance *shared;                /* Instace de travail partagée */ -    GImmOperand template;                   /* Transport d'informations    */ - -    shared = G_SHARED_INSTANCE(*operand); - -    g_shared_instance_define_template(shared, (GSharedInstance *)&template); - -    IMM_SET_DEF_ZERO_PADDING(&template, state); - -    shared = g_share_manager_update(_imm_operand_manager, shared, (GSharedInstance *)&template, container); - -    *operand = G_IMM_OPERAND(shared); +    IMM_SET_DEF_ZERO_PADDING(operand, state);  } @@ -717,11 +635,11 @@ bool g_imm_operand_does_padding_by_default(const GImmOperand *operand)  } +  /******************************************************************************  *                                                                             * -*  Paramètres  : operand   = structure dont le contenu est à actualiser. [OUT]* -*                state     = true si des zéro sont à ajouter, false sinon.    * -*                container = propriétaire d'origine à tenir au courant.       * +*  Paramètres  : operand = structure dont le contenu est à actualiser. [OUT]  * +*                state   = true si des zéro sont à ajouter, false sinon.      *  *                                                                             *  *  Description : Précise si des zéro doivent compléter l'affichage ou non.    *  *                                                                             * @@ -731,21 +649,10 @@ bool g_imm_operand_does_padding_by_default(const GImmOperand *operand)  *                                                                             *  ******************************************************************************/ -void g_imm_operand_pad(GImmOperand **operand, bool state, GShareContainer *container) +void g_imm_operand_pad(GImmOperand *operand, bool state)  { -    GSharedInstance *shared;                /* Instace de travail partagée */ -    GImmOperand template;                   /* Transport d'informations    */ - -    shared = G_SHARED_INSTANCE(*operand); - -    g_shared_instance_define_template(shared, (GSharedInstance *)&template); - -    IMM_SET_ZERO_PADDING(&template); -    IMM_SET_ZERO_PADDING_VALUE(&template, state); - -    shared = g_share_manager_update(_imm_operand_manager, shared, (GSharedInstance *)&template, container); - -    *operand = G_IMM_OPERAND(shared); +    IMM_SET_ZERO_PADDING(operand); +    IMM_SET_ZERO_PADDING_VALUE(operand, state);  } @@ -811,9 +718,8 @@ static bool g_imm_operand_does_padding_for_display(const GImmOperand *operand, I  /******************************************************************************  *                                                                             * -*  Paramètres  : operand   = structure dont le contenu est à actualiser. [OUT]* -*                display   = format global d'un affichage de valeur.          * -*                container = propriétaire d'origine à tenir au courant.       * +*  Paramètres  : operand = structure dont le contenu est à actualiser. [OUT]  * +*                display = format global d'un affichage de valeur.            *  *                                                                             *  *  Description : Définit le format textuel par défaut de la valeur.           *  *                                                                             * @@ -823,20 +729,9 @@ static bool g_imm_operand_does_padding_for_display(const GImmOperand *operand, I  *                                                                             *  ******************************************************************************/ -void g_imm_operand_set_default_display(GImmOperand **operand, ImmOperandDisplay display, GShareContainer *container) +void g_imm_operand_set_default_display(GImmOperand *operand, ImmOperandDisplay display)  { -    GSharedInstance *shared;                /* Instace de travail partagée */ -    GImmOperand template;                   /* Transport d'informations    */ - -    shared = G_SHARED_INSTANCE(*operand); - -    g_shared_instance_define_template(shared, (GSharedInstance *)&template); - -    template.def_display = display; - -    shared = g_share_manager_update(_imm_operand_manager, shared, (GSharedInstance *)&template, container); - -    *operand = G_IMM_OPERAND(shared); +    operand->def_display = display;  } @@ -862,9 +757,8 @@ ImmOperandDisplay g_imm_operand_get_default_display(const GImmOperand *operand)  /******************************************************************************  *                                                                             * -*  Paramètres  : operand   = structure dont le contenu est à actualiser. [OUT]* -*                display   = format global d'un affichage de valeur.          * -*                container = propriétaire d'origine à tenir au courant.       * +*  Paramètres  : operand = structure dont le contenu est à actualiser. [OUT]  * +*                display = format global d'un affichage de valeur.            *  *                                                                             *  *  Description : Définit la grande ligne du format textuel de la valeur.      *  *                                                                             * @@ -874,21 +768,10 @@ ImmOperandDisplay g_imm_operand_get_default_display(const GImmOperand *operand)  *                                                                             *  ******************************************************************************/ -void g_imm_operand_set_display(GImmOperand **operand, ImmOperandDisplay display, GShareContainer *container) +void g_imm_operand_set_display(GImmOperand *operand, ImmOperandDisplay display)  { -    GSharedInstance *shared;                /* Instace de travail partagée */ -    GImmOperand template;                   /* Transport d'informations    */ - -    shared = G_SHARED_INSTANCE(*operand); - -    g_shared_instance_define_template(shared, (GSharedInstance *)&template); - -    IMM_SET_DISPLAY(&template); -    template.display = display; - -    shared = g_share_manager_update(_imm_operand_manager, shared, (GSharedInstance *)&template, container); - -    *operand = G_IMM_OPERAND(shared); +    IMM_SET_DISPLAY(operand); +    operand->display = display;  } @@ -1474,88 +1357,3 @@ bool g_imm_operand_to_off_t(const GImmOperand *operand, off_t *value, bool *nega      return false;  } - - - -/* ---------------------------------------------------------------------------------- */ -/*                            PARTAGES DE CONTENUS UNIQUES                            */ -/* ---------------------------------------------------------------------------------- */ - - -/****************************************************************************** -*                                                                             * -*  Paramètres  : -                                                            * -*                                                                             * -*  Description : Fournit le gestionnaire de partages attribué à un type.      * -*                                                                             * -*  Retour      : Gestionnaire de partages en place.                           * -*                                                                             * -*  Remarques   : -                                                            * -*                                                                             * -******************************************************************************/ - -static GShareManager *get_imm_operand_share_manager(void) -{ -    return _imm_operand_manager; - -} - - -/****************************************************************************** -*                                                                             * -*  Paramètres  : -                                                            * -*                                                                             * -*  Description : Initialise les mécanismes de partage d'opérandes immédiates. * -*                                                                             * -*  Retour      : Bilan de l'opération.                                        * -*                                                                             * -*  Remarques   : -                                                            * -*                                                                             * -******************************************************************************/ - -bool init_imm_operand_sharing(void) -{ -    _imm_operand_manager = g_share_manager_new(G_TYPE_IMM_OPERAND); - -    return true; - -} - - -/****************************************************************************** -*                                                                             * -*  Paramètres  : -                                                            * -*                                                                             * -*  Description : Imprime des statistiques quant aux partages dans l'archi.    * -*                                                                             * -*  Retour      : -                                                            * -*                                                                             * -*  Remarques   : -                                                            * -*                                                                             * -******************************************************************************/ -#ifdef DEBUG_DUMP_STATS -void dump_imm_operand_share_stats(void) -{ -    g_share_manager_dump_stats(_imm_operand_manager); - -} -#endif - - -/****************************************************************************** -*                                                                             * -*  Paramètres  : -                                                            * -*                                                                             * -*  Description : Supprime les mécanismes de partage des opérandes immédiates. * -*                                                                             * -*  Retour      : -                                                            * -*                                                                             * -*  Remarques   : -                                                            * -*                                                                             * -******************************************************************************/ - -void exit_imm_operand_sharing(void) -{ -    g_object_unref(G_OBJECT(_imm_operand_manager)); - -} diff --git a/src/arch/immediate.h b/src/arch/immediate.h index 9becf91..84b3d2a 100644 --- a/src/arch/immediate.h +++ b/src/arch/immediate.h @@ -32,14 +32,10 @@  #include "archbase.h"  #include "operand.h" -#include "sharing/container.h"  #include "../analysis/content.h" -/* ------------------ MANIPULATION D'OPERANDES DE VALEUR IMMEDIATE ------------------ */ - -  /* Grande ligne d'un format d'affichage */  typedef enum _ImmOperandDisplay  { @@ -94,28 +90,28 @@ bool g_imm_operand_get_value(const GImmOperand *, MemoryDataSize, ...);  uint64_t g_imm_operand_get_raw_value(const GImmOperand *);  /* Définit la nouvelle valeur de l'opérande à une valeur. */ -void g_imm_operand_set_value(GImmOperand **, MemoryDataSize, uint64_t, GShareContainer *); +void g_imm_operand_set_value(GImmOperand *, MemoryDataSize, uint64_t);  /* Précise si des zéro doivent compléter l'affichage ou non. */ -void g_imm_operand_pad_by_default(GImmOperand **, bool, GShareContainer *); +void g_imm_operand_pad_by_default(GImmOperand *, bool);  /* Indique si une valeur est complétée par des zéros par défaut. */  bool g_imm_operand_does_padding_by_default(const GImmOperand *);  /* Précise si des zéro doivent compléter l'affichage ou non. */ -void g_imm_operand_pad(GImmOperand **, bool, GShareContainer *); +void g_imm_operand_pad(GImmOperand *, bool);  /* Indique si une valeur est complétée par des zéros. */  bool g_imm_operand_does_padding(const GImmOperand *);  /* Définit le format textuel par défaut de la valeur. */ -void g_imm_operand_set_default_display(GImmOperand **, ImmOperandDisplay, GShareContainer *); +void g_imm_operand_set_default_display(GImmOperand *, ImmOperandDisplay);  /* Indique le format textuel par défaut de la valeur. */  ImmOperandDisplay g_imm_operand_get_default_display(const GImmOperand *);  /* Définit la grande ligne du format textuel de la valeur. */ -void g_imm_operand_set_display(GImmOperand **, ImmOperandDisplay, GShareContainer *); +void g_imm_operand_set_display(GImmOperand *, ImmOperandDisplay);  /* Indique la grande ligne du format textuel de la valeur. */  ImmOperandDisplay g_imm_operand_get_display(const GImmOperand *); @@ -158,20 +154,4 @@ bool g_imm_operand_to_off_t(const GImmOperand *, off_t *, bool *) __attribute__ -/* -------------------------- PARTAGES DE CONTENUS UNIQUES -------------------------- */ - - -/* Initialise les mécanismes de partage des opérandes immédiates. */ -bool init_imm_operand_sharing(void); - -/* Imprime des statistiques quant aux partages dans l'archi. */ -#ifdef DEBUG_DUMP_STATS -void dump_imm_operand_share_stats(void); -#endif - -/* Supprime les mécanismes de partage des opérandes immédiates. */ -void exit_imm_operand_sharing(void); - - -  #endif  /* _ARCH_IMMEDIATE_H */ diff --git a/src/arch/instruction.c b/src/arch/instruction.c index bb98efb..c11f253 100644 --- a/src/arch/instruction.c +++ b/src/arch/instruction.c @@ -30,7 +30,6 @@  #include "instruction-int.h" -#include "sharing/container-int.h"  #include "../glibext/linegen-int.h" @@ -51,9 +50,6 @@ static void g_arch_instruction_class_init(GArchInstructionClass *);  /* Initialise une instance d'opérande d'architecture. */  static void g_arch_instruction_init(GArchInstruction *); -/* Procède à l'initialisation de l'interface de partage. */ -static void g_arch_instruction_share_interface_init(GShareContainerInterface *); -  /* Procède à l'initialisation de l'interface de génération. */  static void g_arch_instruction_generator_interface_init(GLineGeneratorInterface *); @@ -90,7 +86,6 @@ static void g_arch_instruction_print(GArchInstruction *, GBufferLine *, size_t,  /* Indique le type défini pour une instruction d'architecture. */  G_DEFINE_TYPE_WITH_CODE(GArchInstruction, g_arch_instruction, G_TYPE_OBJECT, -                        G_IMPLEMENT_INTERFACE(G_TYPE_SHARE_CONTAINER, g_arch_instruction_share_interface_init)                          G_IMPLEMENT_INTERFACE(G_TYPE_LINE_GENERATOR, g_arch_instruction_generator_interface_init)); @@ -149,25 +144,6 @@ static void g_arch_instruction_init(GArchInstruction *instr)  *                                                                             *  *  Paramètres  : iface = interface GLib à initialiser.                        *  *                                                                             * -*  Description : Procède à l'initialisation de l'interface de partage.        * -*                                                                             * -*  Retour      : -                                                            * -*                                                                             * -*  Remarques   : -                                                            * -*                                                                             * -******************************************************************************/ - -static void g_arch_instruction_share_interface_init(GShareContainerInterface *iface) -{ -    iface->replace = (replace_shared_fc)g_arch_instruction_replace_operand; - -} - - -/****************************************************************************** -*                                                                             * -*  Paramètres  : iface = interface GLib à initialiser.                        * -*                                                                             *  *  Description : Procède à l'initialisation de l'interface de génération.     *  *                                                                             *  *  Retour      : -                                                            * @@ -215,7 +191,7 @@ static void g_arch_instruction_dispose(GArchInstruction *instr)          rem_item_from_flat_array(&instr->operands, 0, sizeof(GArchOperand *)); -        g_shared_instance_unref(G_SHARED_INSTANCE(op)); +        g_object_unref(G_OBJECT(op));      } @@ -665,7 +641,7 @@ bool _g_arch_instruction_replace_operand(GArchInstruction *instr, GArchOperand *      {          rpl_item_in_flat_array(instr->operands, i, &new, sizeof(GArchOperand *)); -        g_shared_instance_unref(G_SHARED_INSTANCE(old)); +        g_object_unref(G_OBJECT(old));      } @@ -706,7 +682,7 @@ void _g_arch_instruction_detach_operand(GArchInstruction *instr, GArchOperand *t      rem_item_from_flat_array(&instr->operands, i, sizeof(GArchOperand *)); -    g_shared_instance_unref(G_SHARED_INSTANCE(target)); +    g_object_unref(G_OBJECT(target));  } diff --git a/src/arch/operand-int.h b/src/arch/operand-int.h index 3caca46..05c58d0 100644 --- a/src/arch/operand-int.h +++ b/src/arch/operand-int.h @@ -26,22 +26,9 @@  #include "operand.h" -#include "sharing/instance-int.h" -/* Fournit le gestionnaire de partages attribué à un type. */ -typedef GShareManager * (* get_operand_manager_fc) (void); - -/* Initialise un nouvel objet partagé avec des informations. */ -typedef bool (* apply_operand_template_fc) (GArchOperand *, const GArchOperand *); - -/* Procède à l'initialisation de l'interface de partage. */ -typedef void (* define_operand_template_fc) (const GArchOperand *, GArchOperand *); - -/* Initialise un nouvel objet partagé avec des informations. */ -typedef bool (* free_operand_template_fc) (const GArchOperand *, GArchOperand *); -  /* Compare un opérande avec un autre. */  typedef int (* operand_compare_fc) (const GArchOperand *, const GArchOperand *); @@ -78,12 +65,6 @@ struct _GArchOperandClass  {      GObjectClass parent;                    /* A laisser en premier        */ -    get_operand_manager_fc get_manager;     /* Accès au gestionnaire       */ - -    apply_operand_template_fc apply_template; /* Intialisation d'instance  */ -    define_operand_template_fc define_template; /* Copie de détails        */ -    free_operand_template_fc free_template; /* Libération d'un patron      */ -      operand_compare_fc compare;             /* Comparaison d'opérandes     */      operand_print_fc print;                 /* Texte humain équivalent     */      operand_build_tooltip_fc build_tooltip; /* Construction de description */ diff --git a/src/arch/operand.c b/src/arch/operand.c index 8bc85fb..e8a4e58 100644 --- a/src/arch/operand.c +++ b/src/arch/operand.c @@ -40,44 +40,16 @@ static void g_arch_operand_class_init(GArchOperandClass *);  /* Initialise une instance d'opérande d'architecture. */  static void g_arch_operand_init(GArchOperand *); -/* Procède à l'initialisation de l'interface de partage. */ -static void g_arch_operand_interface_init(GSharedInstanceInterface *); -  /* Supprime toutes les références externes. */  static void g_arch_operand_dispose(GArchOperand *);  /* Procède à la libération totale de la mémoire. */  static void g_arch_operand_finalize(GArchOperand *); -/* Fournit le gestionnaire de partages attribué à un type. */ -static GShareManager *get_arch_operand_share_manager(const GArchOperand *); - -/* Initialise un nouvel objet partagé avec des informations. */ -static bool g_arch_operand_apply_template(GArchOperand *, const GArchOperand *); - -/* Réalise une copie minimale d'un contenu partagé. */ -static void g_arch_operand_define_template(const GArchOperand *, GArchOperand *); - -/* Libère la mémoire utilisée par un patron d'instance. */ -static void g_arch_operand_free_template(const GArchOperand *, GArchOperand *); - -/* Fournit la valeur du compteur de partage. */ -static unsigned int g_arch_operand_get_references(const GArchOperand *); - -/* Incrémente le compteur de partage. */ -static void g_arch_operand_inc_references(GArchOperand *); - -/* Décrémente le compteur de partage. */ -static void g_arch_operand_dec_references(GArchOperand *); - -/* Compare le contenu d'un opérande avec un autre. */ -static int g_arch_operand_compare_shared(const GArchOperand * const *, const GArchOperand * const *); -  /* Indique le type défini pour un opérande d'architecture. */ -G_DEFINE_TYPE_WITH_CODE(GArchOperand, g_arch_operand, G_TYPE_OBJECT, -                        G_IMPLEMENT_INTERFACE(G_TYPE_SHARED_INSTANCE, g_arch_operand_interface_init)); +G_DEFINE_TYPE(GArchOperand, g_arch_operand, G_TYPE_OBJECT); @@ -125,35 +97,6 @@ static void g_arch_operand_init(GArchOperand *operand)  /******************************************************************************  *                                                                             * -*  Paramètres  : iface = interface GLib à initialiser.                        * -*                                                                             * -*  Description : Procède à l'initialisation de l'interface de partage.        * -*                                                                             * -*  Retour      : -                                                            * -*                                                                             * -*  Remarques   : -                                                            * -*                                                                             * -******************************************************************************/ - -static void g_arch_operand_interface_init(GSharedInstanceInterface *iface) -{ -    iface->get_manager = (get_share_manager_fc)get_arch_operand_share_manager; - -    iface->apply_template = (apply_shared_template_fc)g_arch_operand_apply_template; -    iface->define_template = (define_shared_template_fc)g_arch_operand_define_template; -    iface->free_template = (free_shared_template_fc)g_arch_operand_free_template; - -    iface->get_ref = (get_shared_ref_fc)g_arch_operand_get_references; -    iface->inc_ref = (inc_shared_ref_fc)g_arch_operand_inc_references; -    iface->dec_ref = (dec_shared_ref_fc)g_arch_operand_dec_references; - -    iface->compare = (compare_shared_fc)g_arch_operand_compare_shared; - -} - - -/****************************************************************************** -*                                                                             *  *  Paramètres  : operand = instance d'objet GLib à traiter.                   *  *                                                                             *  *  Description : Supprime toutes les références externes.                     * @@ -194,195 +137,6 @@ static void g_arch_operand_finalize(GArchOperand *operand)  /******************************************************************************  *                                                                             * -*  Paramètres  : operand = instance partagée à consulter.                     * -*                                                                             * -*  Description : Fournit le gestionnaire de partages attribué à un type.      * -*                                                                             * -*  Retour      : Gestionnaire de partages en place.                           * -*                                                                             * -*  Remarques   : -                                                            * -*                                                                             * -******************************************************************************/ - -static GShareManager *get_arch_operand_share_manager(const GArchOperand *operand) -{ -    GShareManager *result;                  /* Instance à retourner        */ - -    if (G_ARCH_OPERAND_GET_CLASS(operand)->get_manager == NULL) -        printf("No manager for '%s'\n", G_OBJECT_TYPE_NAME(operand)); - -    result = G_ARCH_OPERAND_GET_CLASS(operand)->get_manager(); - -    return result; - -} - - -/****************************************************************************** -*                                                                             * -*  Paramètres  : operand  = objet partagé à initialiser.                      * -*                template = information à utiliser pour la mise en place.     * -*                                                                             * -*  Description : Initialise un nouvel objet partagé avec des informations.    * -*                                                                             * -*  Retour      : Bilan de l'opération.                                        * -*                                                                             * -*  Remarques   : -                                                            * -*                                                                             * -******************************************************************************/ - -static bool g_arch_operand_apply_template(GArchOperand *operand, const GArchOperand *template) -{ -    bool result;                            /* Bilan à retourner           */ -    apply_operand_template_fc func;         /* Fonction à appeler          */ - -    func = G_ARCH_OPERAND_GET_CLASS(operand)->apply_template; - -    if (func != NULL) -        result = func(operand, template); - -    else -    { -        if (G_ARCH_OPERAND_GET_CLASS(operand)->define_template == NULL) -            printf("No def for '%s'\n", G_OBJECT_TYPE_NAME(operand)); - - -        G_ARCH_OPERAND_GET_CLASS(operand)->define_template(template, operand); -        result = true; -    } - -    return result; - -} - - -/****************************************************************************** -*                                                                             * -*  Paramètres  : operand  = objet partagé à consulter.                        * -*                template = informations à retrouver intégralement.           * -*                                                                             * -*  Description : Réalise une copie minimale d'un contenu partagé.             * -*                                                                             * -*  Retour      : -                                                            * -*                                                                             * -*  Remarques   : -                                                            * -*                                                                             * -******************************************************************************/ - -static void g_arch_operand_define_template(const GArchOperand *operand, GArchOperand *template) -{ -    G_ARCH_OPERAND_GET_CLASS(operand)->define_template(operand, template); - -} - - -/****************************************************************************** -*                                                                             * -*  Paramètres  : operand  = objet partagé à consulter.                        * -*                template = informations dont le contenu est à libérer.       * -*                                                                             * -*  Description : Libère la mémoire utilisée par un patron d'instance.         * -*                                                                             * -*  Retour      : -                                                            * -*                                                                             * -*  Remarques   : -                                                            * -*                                                                             * -******************************************************************************/ - -static void g_arch_operand_free_template(const GArchOperand *operand, GArchOperand *template) -{ -    free_operand_template_fc func;          /* Fonction à appeler          */ - -    func = G_ARCH_OPERAND_GET_CLASS(operand)->free_template; - -    if (func != NULL) -        func(operand, template); - -} - - -/****************************************************************************** -*                                                                             * -*  Paramètres  : operand = objet partagé à consulter.                         * -*                                                                             * -*  Description : Fournit la valeur du compteur de partage.                    * -*                                                                             * -*  Retour      : Nombre de partages courant.                                  * -*                                                                             * -*  Remarques   : -                                                            * -*                                                                             * -******************************************************************************/ - -static unsigned int g_arch_operand_get_references(const GArchOperand *operand) -{ -    return operand->shared_count; - -} - - -/****************************************************************************** -*                                                                             * -*  Paramètres  : operand = objet partagé à modifier.                          * -*                                                                             * -*  Description : Incrémente le compteur de partage.                           * -*                                                                             * -*  Retour      : -                                                            * -*                                                                             * -*  Remarques   : -                                                            * -*                                                                             * -******************************************************************************/ - -static void g_arch_operand_inc_references(GArchOperand *operand) -{ -    operand->shared_count++; - -} - - -/****************************************************************************** -*                                                                             * -*  Paramètres  : operand = objet partagé à modifier.                          * -*                                                                             * -*  Description : Décrémente le compteur de partage.                           * -*                                                                             * -*  Retour      : -                                                            * -*                                                                             * -*  Remarques   : -                                                            * -*                                                                             * -******************************************************************************/ - -static void g_arch_operand_dec_references(GArchOperand *operand) -{ -    operand->shared_count--; - -} - - -/****************************************************************************** -*                                                                             * -*  Paramètres  : a = premier opérande à consulter.                            * -*                b = second opérande à consulter.                             * -*                                                                             * -*  Description : Compare le contenu d'un opérande avec un autre.              * -*                                                                             * -*  Retour      : Bilan de la comparaison.                                     * -*                                                                             * -*  Remarques   : -                                                            * -*                                                                             * -******************************************************************************/ - -static int g_arch_operand_compare_shared(const GArchOperand * const *a, const GArchOperand * const *b) -{ -    int result;                             /* Bilan à faire remonter      */ - -    result = G_ARCH_OPERAND_GET_CLASS(*a)->compare(*a, *b); - -    return result; - -} - -/****************************************************************************** -*                                                                             *  *  Paramètres  : a = premier opérande à consulter.                            *  *                b = second opérande à consulter.                             *  *                                                                             * diff --git a/src/arch/post.c b/src/arch/post.c index f8864aa..59522bf 100644 --- a/src/arch/post.c +++ b/src/arch/post.c @@ -78,7 +78,7 @@ void post_process_target_resolution(GArchInstruction *instr, GArchProcessor *pro          new = G_TARGET_OPERAND(g_target_operand_new(ptr_size, &target)); -        if (!g_target_operand_resolve(&new, bfmt, true, NULL)) +        if (!g_target_operand_resolve(new, bfmt, true))          {              init_mrange(&trange, &target, 0); @@ -111,7 +111,7 @@ void post_process_target_resolution(GArchInstruction *instr, GArchProcessor *pro              g_binary_format_add_symbol(bfmt, symbol); -            g_target_operand_resolve(&new, bfmt, true, NULL); +            g_target_operand_resolve(new, bfmt, true);          } diff --git a/src/arch/raw.c b/src/arch/raw.c index 4a82aef..8ab788f 100644 --- a/src/arch/raw.c +++ b/src/arch/raw.c @@ -203,7 +203,7 @@ GArchInstruction *g_raw_instruction_new_from_value(const vmpa2t *addr, MemoryDat      operand = G_IMM_OPERAND(g_imm_operand_new_from_value(size, value));      if (operand == NULL) goto grinfv_error; -    g_imm_operand_pad(&operand, true, NULL); +    g_imm_operand_pad(operand, true);      g_arch_instruction_attach_extra_operand(result, G_ARCH_OPERAND(operand)); @@ -290,7 +290,7 @@ GArchInstruction *g_raw_instruction_new_uleb128(const GBinContent *content, vmpa      operand = G_IMM_OPERAND(g_imm_operand_new_from_value(leb_size, (uint64_t)value));      if (operand == NULL) goto grinu_error; -    g_imm_operand_pad(&operand, true, NULL); +    g_imm_operand_pad(operand, true);      g_arch_instruction_attach_extra_operand(result, G_ARCH_OPERAND(operand)); @@ -344,7 +344,7 @@ GArchInstruction *g_raw_instruction_new_sleb128(const GBinContent *content, vmpa      operand = G_IMM_OPERAND(g_imm_operand_new_from_value(leb_size, (uint64_t)value));      if (operand == NULL) goto grins_error; -    g_imm_operand_pad(&operand, true, NULL); +    g_imm_operand_pad(operand, true);      g_arch_instruction_attach_extra_operand(result, G_ARCH_OPERAND(operand)); @@ -393,7 +393,7 @@ GArchInstruction *g_raw_instruction_new_array(const GBinContent *content, Memory          operand = G_IMM_OPERAND(g_imm_operand_new_from_data(size, content, addr, endian));          if (operand == NULL) goto grina_error; -        g_imm_operand_pad(&operand, true, NULL); +        g_imm_operand_pad(operand, true);          g_arch_instruction_attach_extra_operand(result, G_ARCH_OPERAND(operand)); diff --git a/src/arch/register-int.h b/src/arch/register-int.h index 0934f95..3397200 100644 --- a/src/arch/register-int.h +++ b/src/arch/register-int.h @@ -29,25 +29,9 @@  #include "operand-int.h" -#include "sharing/instance-int.h" -/* ---------------------------- PUR REGISTRE DU MATERIEL ---------------------------- */ - - -/* Fournit le gestionnaire de partages attribué à un type. */ -typedef GShareManager * (* get_register_manager_fc) (void); - -/* Initialise un nouvel objet partagé avec des informations. */ -typedef bool (* apply_register_template_fc) (GArchRegister *, const GArchRegister *); - -/* Réalise une copie minimale d'un contenu partagé. */ -typedef void (* define_register_template_fc) (const GArchRegister *, GArchRegister *); - -/* Libère la mémoire utilisée par un patron d'instance. */ -typedef void (* free_register_template_fc) (const GArchRegister *, GArchOperand *); -  /* Produit une empreinte à partir d'un registre. */  typedef guint (* reg_hash_fc) (const GArchRegister *); @@ -80,12 +64,6 @@ struct _GArchRegisterClass  {      GObjectClass parent;                    /* A laisser en premier        */ -    get_register_manager_fc get_manager;    /* Accès au gestionnaire       */ - -    apply_register_template_fc apply_template; /* Intialisation d'instance */ -    define_register_template_fc define_template; /* Copie de détails       */ -    free_register_template_fc free_template; /* Libération d'un patron     */ -      reg_hash_fc hash;                       /* Production d'empreinte      */      reg_compare_fc compare;                 /* Comparaison de registres    */      reg_print_fc print;                     /* Impression du registre      */ diff --git a/src/arch/register.c b/src/arch/register.c index 3071198..bbad23f 100644 --- a/src/arch/register.c +++ b/src/arch/register.c @@ -37,37 +37,12 @@ static void g_arch_register_class_init(GArchRegisterClass *);  /* Initialise une instance de registre. */  static void g_arch_register_init(GArchRegister *); -/* Procède à l'initialisation de l'interface de partage. */ -static void g_arch_register_interface_init(GSharedInstanceInterface *); -  /* Supprime toutes les références externes. */  static void g_arch_register_dispose(GArchRegister *);  /* Procède à la libération totale de la mémoire. */  static void g_arch_register_finalize(GArchRegister *); -/* Fournit le gestionnaire de partages attribué à un type. */ -static GShareManager *get_arch_register_share_manager(const GArchRegister *); - -/* Initialise un nouvel objet partagé avec des informations. */ -static bool g_arch_register_apply_template(GArchRegister *, const GArchRegister *); - -/* Réalise une copie minimale d'un contenu partagé. */ -static void g_arch_register_define_template(const GArchRegister *, GArchRegister *); - -/* Fournit la valeur du compteur de partage. */ -static unsigned int g_arch_register_get_references(const GArchRegister *); - -/* Incrémente le compteur de partage. */ -static void g_arch_register_inc_references(GArchRegister *); - -/* Décrémente le compteur de partage. */ -static void g_arch_register_dec_references(GArchRegister *); - -/* Compare de façon accélérée un registre avec un autre. */ -static int g_arch_register_compare_shared(const GArchRegister * const *, const GArchRegister * const *); - -  /* ------------------------- REGISTRE SOUS FORME D'OPERANDE ------------------------- */ @@ -84,12 +59,6 @@ static void g_register_operand_dispose(GRegisterOperand *);  /* Procède à la libération totale de la mémoire. */  static void g_register_operand_finalize(GRegisterOperand *); -/* Initialise un nouvel objet partagé avec des informations. */ -static bool g_register_operand_apply_template(GRegisterOperand *, const GRegisterOperand *); - -/* Réalise une copie minimale d'un contenu partagé. */ -static void g_register_operand_define_template(const GRegisterOperand *, GRegisterOperand *); -  /* Compare un opérande avec un autre. */  static int g_register_operand_compare(const GRegisterOperand *, const GRegisterOperand *); @@ -98,26 +67,13 @@ static void g_register_operand_print(const GRegisterOperand *, GBufferLine *, As -/* -------------------------- PARTAGES DE CONTENUS UNIQUES -------------------------- */ - - -/* Gestionnaire des partages d'instances */ -static GShareManager *_register_operand_manager = NULL; - - -/* Fournit le gestionnaire de partages attribué à un type. */ -static GShareManager *get_register_operand_share_manager(void); - - -  /* ---------------------------------------------------------------------------------- */  /*                              PUR REGISTRE DU MATERIEL                              */  /* ---------------------------------------------------------------------------------- */  /* Indique le type défini pour une représentation d'un registre. */ -G_DEFINE_TYPE_WITH_CODE(GArchRegister, g_arch_register, G_TYPE_OBJECT, -                        G_IMPLEMENT_INTERFACE(G_TYPE_SHARED_INSTANCE, g_arch_register_interface_init)); +G_DEFINE_TYPE(GArchRegister, g_arch_register, G_TYPE_OBJECT);  /****************************************************************************** @@ -164,35 +120,6 @@ static void g_arch_register_init(GArchRegister *reg)  /******************************************************************************  *                                                                             * -*  Paramètres  : iface = interface GLib à initialiser.                        * -*                                                                             * -*  Description : Procède à l'initialisation de l'interface de partage.        * -*                                                                             * -*  Retour      : -                                                            * -*                                                                             * -*  Remarques   : -                                                            * -*                                                                             * -******************************************************************************/ - -static void g_arch_register_interface_init(GSharedInstanceInterface *iface) -{ -    iface->get_manager = (get_share_manager_fc)get_arch_register_share_manager; - -    iface->apply_template = (apply_shared_template_fc)g_arch_register_apply_template; -    iface->define_template = (define_shared_template_fc)g_arch_register_define_template; -    iface->free_template = (free_shared_template_fc)NULL; - -    iface->get_ref = (get_shared_ref_fc)g_arch_register_get_references; -    iface->inc_ref = (inc_shared_ref_fc)g_arch_register_inc_references; -    iface->dec_ref = (dec_shared_ref_fc)g_arch_register_dec_references; - -    iface->compare = (compare_shared_fc)g_arch_register_compare_shared; - -} - - -/****************************************************************************** -*                                                                             *  *  Paramètres  : reg = instance d'objet GLib à traiter.                       *  *                                                                             *  *  Description : Supprime toutes les références externes.                     * @@ -231,164 +158,6 @@ static void g_arch_register_finalize(GArchRegister *reg)  /******************************************************************************  *                                                                             * -*  Paramètres  : reg = instance partagée à consulter.                         * -*                                                                             * -*  Description : Fournit le gestionnaire de partages attribué à un type.      * -*                                                                             * -*  Retour      : Gestionnaire de partages en place.                           * -*                                                                             * -*  Remarques   : -                                                            * -*                                                                             * -******************************************************************************/ - -static GShareManager *get_arch_register_share_manager(const GArchRegister *reg) -{ -    GShareManager *result;                  /* Instance à retourner        */ - -    result = G_ARCH_REGISTER_GET_CLASS(reg)->get_manager(); - -    return result; - -} - - -/****************************************************************************** -*                                                                             * -*  Paramètres  : reg      = objet partagé à initialiser.                      * -*                template = information à utiliser pour la mise en place.     * -*                                                                             * -*  Description : Initialise un nouvel objet partagé avec des informations.    * -*                                                                             * -*  Retour      : Bilan de l'opération.                                        * -*                                                                             * -*  Remarques   : -                                                            * -*                                                                             * -******************************************************************************/ - -static bool g_arch_register_apply_template(GArchRegister *reg, const GArchRegister *template) -{ -    bool result;                            /* Bilan à retourner           */ -    apply_register_template_fc func;         /* Fonction à appeler          */ - -    func = G_ARCH_REGISTER_GET_CLASS(reg)->apply_template; - -    if (func != NULL) -        result = func(reg, template); - -    else -    { -        G_ARCH_REGISTER_GET_CLASS(reg)->define_template(template, reg); -        result = true; -    } - -    return result; - -} - - -/****************************************************************************** -*                                                                             * -*  Paramètres  : reg      = objet partagé à consulter.                        * -*                template = informations à retrouver intégralement.           * -*                                                                             * -*  Description : Réalise une copie minimale d'un contenu partagé.             * -*                                                                             * -*  Retour      : -                                                            * -*                                                                             * -*  Remarques   : -                                                            * -*                                                                             * -******************************************************************************/ - -static void g_arch_register_define_template(const GArchRegister *reg, GArchRegister *template) -{ -    G_ARCH_REGISTER_GET_CLASS(reg)->define_template(reg, template); - -} - - -/****************************************************************************** -*                                                                             * -*  Paramètres  : reg = objet partagé à consulter.                             * -*                                                                             * -*  Description : Fournit la valeur du compteur de partage.                    * -*                                                                             * -*  Retour      : Nombre de partages courant.                                  * -*                                                                             * -*  Remarques   : -                                                            * -*                                                                             * -******************************************************************************/ - -static unsigned int g_arch_register_get_references(const GArchRegister *reg) -{ -    return reg->shared_count; - -} - - -/****************************************************************************** -*                                                                             * -*  Paramètres  : reg = objet partagé à modifier.                              * -*                                                                             * -*  Description : Incrémente le compteur de partage.                           * -*                                                                             * -*  Retour      : -                                                            * -*                                                                             * -*  Remarques   : -                                                            * -*                                                                             * -******************************************************************************/ - -static void g_arch_register_inc_references(GArchRegister *reg) -{ -    reg->shared_count++; - -} - - -/****************************************************************************** -*                                                                             * -*  Paramètres  : reg = objet partagé à modifier.                              * -*                                                                             * -*  Description : Décrémente le compteur de partage.                           * -*                                                                             * -*  Retour      : -                                                            * -*                                                                             * -*  Remarques   : -                                                            * -*                                                                             * -******************************************************************************/ - -static void g_arch_register_dec_references(GArchRegister *reg) -{ -    reg->shared_count--; - -} - - -/****************************************************************************** -*                                                                             * -*  Paramètres  : a = premier registre à consulter.                            * -*                b = second registre à consulter.                             * -*                                                                             * -*  Description : Compare de façon accélérée un registre avec un autre.        * -*                                                                             * -*  Retour      : Bilan de la comparaison.                                     * -*                                                                             * -*  Remarques   : -                                                            * -*                                                                             * -******************************************************************************/ - -static int g_arch_register_compare_shared(const GArchRegister * const *a, const GArchRegister * const *b) -{ -    int result;                             /* Bilan à faire remonter      */ - -    result = G_ARCH_REGISTER_GET_CLASS(*a)->compare(*a, *b); - -    return result; - -} - - -/****************************************************************************** -*                                                                             *  *  Paramètres  : reg = opérande à consulter pour le calcul.                   *  *                                                                             *  *  Description : Produit une empreinte à partir d'un registre.                * @@ -532,12 +301,6 @@ static void g_register_operand_class_init(GRegisterOperandClass *klass)      object->dispose = (GObjectFinalizeFunc/* ! */)g_register_operand_dispose;      object->finalize = (GObjectFinalizeFunc)g_register_operand_finalize; -    operand->get_manager = (get_operand_manager_fc)get_register_operand_share_manager; - -    operand->apply_template = (apply_operand_template_fc)g_register_operand_apply_template; -    operand->define_template = (define_operand_template_fc)g_register_operand_define_template; -    operand->free_template = (free_operand_template_fc)NULL; -      operand->compare = (operand_compare_fc)g_register_operand_compare;      operand->print = (operand_print_fc)g_register_operand_print; @@ -605,34 +368,35 @@ static void g_register_operand_finalize(GRegisterOperand *operand)  /******************************************************************************  *                                                                             * -*  Paramètres  : operand  = objet partagé à initialiser.                      * -*                template = information à utiliser pour la mise en place.     * +*  Paramètres  : a = premier opérande à consulter.                            * +*                b = second opérande à consulter.                             *  *                                                                             * -*  Description : Initialise un nouvel objet partagé avec des informations.    * +*  Description : Compare un opérande avec un autre.                           *  *                                                                             * -*  Retour      : Bilan de l'opération.                                        * +*  Retour      : Bilan de la comparaison.                                     *  *                                                                             *  *  Remarques   : -                                                            *  *                                                                             *  ******************************************************************************/ -static bool g_register_operand_apply_template(GRegisterOperand *operand, const GRegisterOperand *template) +static int g_register_operand_compare(const GRegisterOperand *a, const GRegisterOperand *b)  { -    g_register_operand_define_template(template, operand); +    int result;                             /* Bilan à retourner           */ -    g_object_ref(G_OBJECT(operand->reg)); +    result = g_arch_register_compare(a->reg, b->reg); -    return true; +    return result;  }  /******************************************************************************  *                                                                             * -*  Paramètres  : operand  = objet partagé à consulter.                        * -*                template = informations à retrouver intégralement.           * +*  Paramètres  : operand = opérande à traiter.                                * +*                line    = ligne tampon où imprimer l'opérande donné.         * +*                syntax  = type de représentation demandée.                   *  *                                                                             * -*  Description : Réalise une copie minimale d'un contenu partagé.             * +*  Description : Traduit un opérande en version humainement lisible.          *  *                                                                             *  *  Retour      : -                                                            *  *                                                                             * @@ -640,11 +404,9 @@ static bool g_register_operand_apply_template(GRegisterOperand *operand, const G  *                                                                             *  ******************************************************************************/ -static void g_register_operand_define_template(const GRegisterOperand *operand, GRegisterOperand *template) +static void g_register_operand_print(const GRegisterOperand *operand, GBufferLine *line, AsmSyntax syntax)  { -    template->reg = operand->reg; - -    template->is_written = operand->is_written; +    g_arch_register_print(operand->reg, line, syntax);  } @@ -697,51 +459,6 @@ GArchRegister *g_register_operand_get_register(const GRegisterOperand *operand)  /******************************************************************************  *                                                                             * -*  Paramètres  : a = premier opérande à consulter.                            * -*                b = second opérande à consulter.                             * -*                                                                             * -*  Description : Compare un opérande avec un autre.                           * -*                                                                             * -*  Retour      : Bilan de la comparaison.                                     * -*                                                                             * -*  Remarques   : -                                                            * -*                                                                             * -******************************************************************************/ - -static int g_register_operand_compare(const GRegisterOperand *a, const GRegisterOperand *b) -{ -    int result;                             /* Bilan à retourner           */ - -    result = g_arch_register_compare(a->reg, b->reg); - -    return result; - -} - - -/****************************************************************************** -*                                                                             * -*  Paramètres  : operand = opérande à traiter.                                * -*                line    = ligne tampon où imprimer l'opérande donné.         * -*                syntax  = type de représentation demandée.                   * -*                                                                             * -*  Description : Traduit un opérande en version humainement lisible.          * -*                                                                             * -*  Retour      : -                                                            * -*                                                                             * -*  Remarques   : -                                                            * -*                                                                             * -******************************************************************************/ - -static void g_register_operand_print(const GRegisterOperand *operand, GBufferLine *line, AsmSyntax syntax) -{ -    g_arch_register_print(operand->reg, line, syntax); - -} - - -/****************************************************************************** -*                                                                             *  *  Paramètres  : operand = opérande représentant un registre à mettre à jour. *  *                                                                             *  *  Description : Marque l'opérande comme étant écrit plutôt que consulté.     * @@ -776,88 +493,3 @@ bool g_register_operand_is_written(const GRegisterOperand *operand)      return operand->is_written;  } - - - -/* ---------------------------------------------------------------------------------- */ -/*                            PARTAGES DE CONTENUS UNIQUES                            */ -/* ---------------------------------------------------------------------------------- */ - - -/****************************************************************************** -*                                                                             * -*  Paramètres  : -                                                            * -*                                                                             * -*  Description : Fournit le gestionnaire de partages attribué à un type.      * -*                                                                             * -*  Retour      : Gestionnaire de partages en place.                           * -*                                                                             * -*  Remarques   : -                                                            * -*                                                                             * -******************************************************************************/ - -static GShareManager *get_register_operand_share_manager(void) -{ -    return _register_operand_manager; - -} - - -/****************************************************************************** -*                                                                             * -*  Paramètres  : -                                                            * -*                                                                             * -*  Description : Met en place les mécanismes de partage des registres.        * -*                                                                             * -*  Retour      : Bilan de l'opération.                                        * -*                                                                             * -*  Remarques   : -                                                            * -*                                                                             * -******************************************************************************/ - -bool init_register_operand_sharing(void) -{ -    _register_operand_manager = g_share_manager_new(G_TYPE_REGISTER_OPERAND); - -    return true; - -} - - -/****************************************************************************** -*                                                                             * -*  Paramètres  : -                                                            * -*                                                                             * -*  Description : Imprime des statistiques quant aux partages dans l'archi.    * -*                                                                             * -*  Retour      : -                                                            * -*                                                                             * -*  Remarques   : -                                                            * -*                                                                             * -******************************************************************************/ -#ifdef DEBUG_DUMP_STATS -void dump_register_operand_share_stats(void) -{ -    g_share_manager_dump_stats(_register_operand_manager); - -} -#endif - - -/****************************************************************************** -*                                                                             * -*  Paramètres  : -                                                            * -*                                                                             * -*  Description : Supprime les mécanismes de partage des opérandes de registre.* -*                                                                             * -*  Retour      : -                                                            * -*                                                                             * -*  Remarques   : -                                                            * -*                                                                             * -******************************************************************************/ - -void exit_register_operand_sharing(void) -{ -    g_object_unref(G_OBJECT(_register_operand_manager)); - -} diff --git a/src/arch/sharing/Makefile.am b/src/arch/sharing/Makefile.am deleted file mode 100644 index 48c6636..0000000 --- a/src/arch/sharing/Makefile.am +++ /dev/null @@ -1,16 +0,0 @@ - -noinst_LTLIBRARIES = libarchsharing.la - -libarchsharing_la_SOURCES =				\ -	container-int.h						\ -	container.h container.c				\ -	instance-int.h						\ -	instance.h instance.c				\ -	manager.h manager.c - -libarchdalvik_la_CFLAGS = $(AM_CFLAGS) - - -AM_CPPFLAGS = $(LIBGTK_CFLAGS) $(LIBXML_CFLAGS) - -AM_CFLAGS = $(DEBUG_CFLAGS) $(WARNING_FLAGS) $(COMPLIANCE_FLAGS) diff --git a/src/arch/sharing/container-int.h b/src/arch/sharing/container-int.h deleted file mode 100644 index bc67bf6..0000000 --- a/src/arch/sharing/container-int.h +++ /dev/null @@ -1,51 +0,0 @@ - -/* Chrysalide - Outil d'analyse de fichiers binaires - * container-int.h - définitions internes propres aux intégrateurs de contenu - * - * Copyright (C) 2016-2017 Cyrille Bagard - * - *  This file is part of Chrysalide. - * - *  Chrysalide 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. - * - *  Chrysalide 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 _ARCH_SHARING_CONTAINER_INT_H -#define _ARCH_SHARING_CONTAINER_INT_H - - -#include "container.h" - - - -/* Assure la mise à jour du contenu d'un intégrateur. */ -typedef bool (* replace_shared_fc) (GShareContainer *, GSharedInstance *, GSharedInstance *); - - -/* Règles de partage d'une instance GObject (interface) */ -struct _GShareContainerIface -{ -    GTypeInterface base_iface;              /* A laisser en premier        */ - -    replace_shared_fc replace;              /* Mise à jour du conteneur    */ - -}; - - -/* Redéfinition */ -typedef GShareContainerIface GShareContainerInterface; - - - -#endif  /* _ARCH_SHARING_CONTAINER_INT_H */ diff --git a/src/arch/sharing/container.c b/src/arch/sharing/container.c deleted file mode 100644 index 5ff62b7..0000000 --- a/src/arch/sharing/container.c +++ /dev/null @@ -1,93 +0,0 @@ - -/* Chrysalide - Outil d'analyse de fichiers binaires - * content.c - intégration de données partagées - * - * Copyright (C) 2016-2017 Cyrille Bagard - * - *  This file is part of Chrysalide. - * - *  Chrysalide 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. - * - *  Chrysalide 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 "container.h" - - -#include <assert.h> - - -#include "container-int.h" - - - -/* Procède à l'initialisation de l'interface d'intégration. */ -static void g_share_container_default_init(GShareContainerInterface *); - - - -/* Détermine le type d'une interface pour l'intégration de contenu partagé. */ -G_DEFINE_INTERFACE(GShareContainer, g_share_container, G_TYPE_OBJECT) - - -/****************************************************************************** -*                                                                             * -*  Paramètres  : iface = interface GLib à initialiser.                        * -*                                                                             * -*  Description : Procède à l'initialisation de l'interface d'intégration.     * -*                                                                             * -*  Retour      : -                                                            * -*                                                                             * -*  Remarques   : -                                                            * -*                                                                             * -******************************************************************************/ - -static void g_share_container_default_init(GShareContainerInterface *iface) -{ - -} - - -/****************************************************************************** -*                                                                             * -*  Paramètres  : instance = intégrateur à éventuellement manipuler.           * -*                old      = ancien contenu à remplacer si besoin est.         * -*                new      = nouveau contenu, potentiellement original.        * -*                                                                             * -*  Description : Assure la mise à jour du contenu d'un intégrateur.           * -*                                                                             * -*  Retour      : Bilan de l'opération.                                        * -*                                                                             * -*  Remarques   : -                                                            * -*                                                                             * -******************************************************************************/ - -bool g_share_container_replace(GShareContainer *container, GSharedInstance *old, GSharedInstance *new) -{ -    bool result;                            /* Bilan à retourner           */ -    GShareContainerIface *iface;            /* Interface utilisée          */ - -    if (old != new) -    { -        iface = G_SHARE_CONTAINER_GET_IFACE(container); - -        result = iface->replace(container, old, new); - -    } - -    else -        result = false; - -    return result; - -} diff --git a/src/arch/sharing/container.h b/src/arch/sharing/container.h deleted file mode 100644 index 3312f9d..0000000 --- a/src/arch/sharing/container.h +++ /dev/null @@ -1,59 +0,0 @@ - -/* Chrysalide - Outil d'analyse de fichiers binaires - * content.h - prototypes pour l'intégration de données partagées - * - * Copyright (C) 2016-2017 Cyrille Bagard - * - *  This file is part of Chrysalide. - * - *  Chrysalide 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. - * - *  Chrysalide 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 _ARCH_SHARING_CONTAINER_H -#define _ARCH_SHARING_CONTAINER_H - - -#include <stdbool.h> -#include <glib-object.h> - - -#include "instance.h" - - - -#define G_TYPE_SHARE_CONTAINER               (g_share_container_get_type()) -#define G_SHARE_CONTAINER(obj)               (G_TYPE_CHECK_INSTANCE_CAST((obj), G_TYPE_SHARE_CONTAINER, GShareContainer)) -#define G_SHARE_CONTAINER_CLASS(vtable)      (G_TYPE_CHECK_CLASS_CAST((vtable), G_TYPE_SHARE_CONTAINER, GShareContainerIface)) -#define GTK_IS_SHARE_CONTAINER(obj)          (G_TYPE_CHECK_INSTANCE_TYPE((obj), G_TYPE_SHARE_CONTAINER)) -#define GTK_IS_SHARE_CONTAINER_CLASS(vtable) (G_TYPE_CHECK_CLASS_TYPE((vtable), G_TYPE_SHARE_CONTAINER)) -#define G_SHARE_CONTAINER_GET_IFACE(inst)    (G_TYPE_INSTANCE_GET_INTERFACE((inst), G_TYPE_SHARE_CONTAINER, GShareContainerIface)) - - -/* Intégrateur de contenu partagé (coquille vide) */ -typedef struct _GShareContainer GShareContainer; - -/* Intégrateur de contenu partagé (interface) */ -typedef struct _GShareContainerIface GShareContainerIface; - - -/* Détermine le type d'une interface pour l'intégration de contenu partagé. */ -GType g_share_container_get_type(void) G_GNUC_CONST; - -/* Assure la mise à jour du contenu d'un intégrateur. */ -bool g_share_container_replace(GShareContainer *, GSharedInstance *, GSharedInstance *); - - - -#endif  /* _ARCH_SHARING_CONTAINER_H */ diff --git a/src/arch/sharing/instance-int.h b/src/arch/sharing/instance-int.h deleted file mode 100644 index cf5a56d..0000000 --- a/src/arch/sharing/instance-int.h +++ /dev/null @@ -1,83 +0,0 @@ - -/* Chrysalide - Outil d'analyse de fichiers binaires - * instance-int.h - définitions internes propres aux instances partagées - * - * Copyright (C) 2016-2017 Cyrille Bagard - * - *  This file is part of Chrysalide. - * - *  Chrysalide 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. - * - *  Chrysalide 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 _ARCH_SHARING_INSTANCE_INT_H -#define _ARCH_SHARING_INSTANCE_INT_H - - -#include "instance.h" -#include "manager.h" - - - -/* Fournit le gestionnaire de partages attribué à un type. */ -typedef GShareManager * (* get_share_manager_fc) (const GSharedInstance *); - -/* Initialise un nouvel objet partagé avec des informations. */ -typedef bool (* apply_shared_template_fc) (GSharedInstance *, const GSharedInstance *); - -/* Procède à l'initialisation de l'interface de partage. */ -typedef void (* define_shared_template_fc) (const GSharedInstance *, GSharedInstance *); - -/* Initialise un nouvel objet partagé avec des informations. */ -typedef bool (* free_shared_template_fc) (const GSharedInstance *, GSharedInstance *); - -/* Fournit la valeur du compteur de partage. */ -typedef unsigned int (* get_shared_ref_fc) (const GSharedInstance *); - -/* Incrémente le compteur de partage. */ -typedef void (* inc_shared_ref_fc) (GSharedInstance *); - -/* Décrémente le compteur de partage. */ -typedef void (* dec_shared_ref_fc) (GSharedInstance *); - -/* Procède à l'initialisation de l'interface de partage. */ -typedef int (* compare_shared_fc) (const GSharedInstance * const *, const GSharedInstance * const *); - - -/* Règles de partage d'une instance GObject (interface) */ -struct _GSharedInstanceIface -{ -    GTypeInterface base_iface;              /* A laisser en premier        */ - -    get_share_manager_fc get_manager;       /* Accès au gestionnaire       */ - -    apply_shared_template_fc apply_template;/* Intialisation d'instance    */ -    define_shared_template_fc define_template; /* Copie minimale de détails*/ -    free_shared_template_fc free_template;  /* Libération d'un patron      */ - -    get_shared_ref_fc get_ref;              /* Obtention du compteur       */ -    inc_shared_ref_fc inc_ref;              /* Incrémentation du compteur  */ -    dec_shared_ref_fc dec_ref;              /* Décrémentation du compteur  */ - -    compare_shared_fc compare;              /* Comparaison des détails     */ - -}; - - -/* Redéfinition */ -typedef GSharedInstanceIface GSharedInstanceInterface; - - - -#endif  /* _ARCH_SHARING_INSTANCE_INT_H */ diff --git a/src/arch/sharing/instance.c b/src/arch/sharing/instance.c deleted file mode 100644 index 05081bb..0000000 --- a/src/arch/sharing/instance.c +++ /dev/null @@ -1,273 +0,0 @@ - -/* Chrysalide - Outil d'analyse de fichiers binaires - * instance.c - partage de données d'architecture quelconques - * - * Copyright (C) 2016-2017 Cyrille Bagard - * - *  This file is part of Chrysalide. - * - *  Chrysalide 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. - * - *  Chrysalide 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 "instance.h" - - -#include <assert.h> - - -#include "instance-int.h" - - - -/* Procède à l'initialisation de l'interface de partage. */ -static void g_shared_instance_default_init(GSharedInstanceInterface *); - - - -/* Détermine le type d'une interface pour le partage d'instance. */ -G_DEFINE_INTERFACE(GSharedInstance, g_shared_instance, G_TYPE_OBJECT) - - -/****************************************************************************** -*                                                                             * -*  Paramètres  : iface = interface GLib à initialiser.                        * -*                                                                             * -*  Description : Procède à l'initialisation de l'interface de partage.        * -*                                                                             * -*  Retour      : -                                                            * -*                                                                             * -*  Remarques   : -                                                            * -*                                                                             * -******************************************************************************/ - -static void g_shared_instance_default_init(GSharedInstanceInterface *iface) -{ - -} - - -/****************************************************************************** -*                                                                             * -*  Paramètres  : instance = objet partagé à initialiser.                      * -*                template = informations à retrouver intégralement.           * -*                                                                             * -*  Description : Initialise un nouvel objet partagé avec des informations.    * -*                                                                             * -*  Retour      : Bilan de l'opération.                                        * -*                                                                             * -*  Remarques   : -                                                            * -*                                                                             * -******************************************************************************/ - -bool g_shared_instance_apply_template(GSharedInstance *instance, const GSharedInstance *template) -{ -    bool result;                            /* Bilan à retourner           */ -    GSharedInstanceIface *iface;            /* Interface utilisée          */ - -    iface = G_SHARED_INSTANCE_GET_IFACE(instance); - -    /** -     * Le compteur de références des objets GLib doit être incrémenté ici, -     * à la différence d'une opération de copie minimaliste. -     */ - -    result = iface->apply_template(instance, template); - -    return result; - -} - - -/****************************************************************************** -*                                                                             * -*  Paramètres  : instance = objet partagé à consulter.                        * -*                template = informations à retrouver intégralement.           * -*                                                                             * -*  Description : Réalise une copie minimale d'un contenu partagé.             * -*                                                                             * -*  Retour      : -                                                            * -*                                                                             * -*  Remarques   : -                                                            * -*                                                                             * -******************************************************************************/ - -void g_shared_instance_define_template(const GSharedInstance *instance, GSharedInstance *template) -{ -    GSharedInstanceIface *iface;            /* Interface utilisée          */ - -    iface = G_SHARED_INSTANCE_GET_IFACE(instance); - -    /** -     * Le compteur de références des objets GLib ne doit pas être incrémenté ici. -     * Ce genre de traitement est réservé à la phase d'initialisation. -     */ - -    iface->define_template(instance, template); - -} - - -/****************************************************************************** -*                                                                             * -*  Paramètres  : instance = objet partagé à modifier.                         * -*                                                                             * -*  Description : Incrémente le compteur de références d'un élément partagé.   * -*                                                                             * -*  Retour      : -                                                            * -*                                                                             * -*  Remarques   : -                                                            * -*                                                                             * -******************************************************************************/ - -void g_shared_instance_ref(GSharedInstance *instance) -{ -    GSharedInstanceIface *iface;            /* Interface utilisée          */ -    GShareManager *manager;                 /* Gestionnaire associé        */ - -    iface = G_SHARED_INSTANCE_GET_IFACE(instance); - -    manager = iface->get_manager(instance); - -    g_share_manager_get(manager, instance); - -} - - -/****************************************************************************** -*                                                                             * -*  Paramètres  : instance = objet partagé à modifier.                         * -*                                                                             * -*  Description : Décrémente le compteur de références d'un élément partagé.   * -*                                                                             * -*  Retour      : -                                                            * -*                                                                             * -*  Remarques   : -                                                            * -*                                                                             * -******************************************************************************/ - -void g_shared_instance_unref(GSharedInstance *instance) -{ -    GSharedInstanceIface *iface;            /* Interface utilisée          */ -    GShareManager *manager;                 /* Gestionnaire associé        */ - -    iface = G_SHARED_INSTANCE_GET_IFACE(instance); - -    manager = iface->get_manager(instance); - -    g_share_manager_put(manager, instance); - -} - - -/****************************************************************************** -*                                                                             * -*  Paramètres  : instance = objet partagé à consulter.                        * -*                                                                             * -*  Description : Fournit la valeur du compteur de partage.                    * -*                                                                             * -*  Retour      : Nombre de partages courant.                                  * -*                                                                             * -*  Remarques   : -                                                            * -*                                                                             * -******************************************************************************/ - -unsigned int g_shared_instance_get_references(const GSharedInstance *instance) -{ -    GSharedInstanceIface *iface;            /* Interface utilisée          */ - -    iface = G_SHARED_INSTANCE_GET_IFACE(instance); - -    return iface->get_ref(instance); - -} - - -/****************************************************************************** -*                                                                             * -*  Paramètres  : instance = objet partagé à modifier.                         * -*                                                                             * -*  Description : Incrémente le compteur de partage.                           * -*                                                                             * -*  Retour      : -                                                            * -*                                                                             * -*  Remarques   : -                                                            * -*                                                                             * -******************************************************************************/ - -void g_shared_instance_inc_references(GSharedInstance *instance) -{ -    GSharedInstanceIface *iface;            /* Interface utilisée          */ - -    iface = G_SHARED_INSTANCE_GET_IFACE(instance); - -    iface->inc_ref(instance); - -} - - -/****************************************************************************** -*                                                                             * -*  Paramètres  : instance = objet partagé à modifier.                         * -*                                                                             * -*  Description : Décrémente le compteur de partage.                           * -*                                                                             * -*  Retour      : -                                                            * -*                                                                             * -*  Remarques   : -                                                            * -*                                                                             * -******************************************************************************/ - -void g_shared_instance_dec_references(GSharedInstance *instance) -{ -    GSharedInstanceIface *iface;            /* Interface utilisée          */ - -    iface = G_SHARED_INSTANCE_GET_IFACE(instance); - -    iface->dec_ref(instance); - -} - - -/****************************************************************************** -*                                                                             * -*  Paramètres  : a = premier objet partagé à consulter.                       * -*                b = second objet partagé à consulter.                        * -*                                                                             * -*  Description : Compare de façon accélérée un object partagé avec un autre.  * -*                                                                             * -*  Retour      : Bilan de la comparaison.                                     * -*                                                                             * -*  Remarques   : -                                                            * -*                                                                             * -******************************************************************************/ - -int g_shared_instance_compare(const GSharedInstance * const *a, const GSharedInstance * const *b) -{ -    int result;                             /* Bilan à faire remonter      */ -    GSharedInstanceIface *iface;            /* Interface utilisée          */ - -    /** -     * Comme les insertions dans les tableaux triés à l'aide de qinsert() -     * font passer la clef en premier argument et que celle ci n'est pas un -     * objet valide, on inverse les arguments, puis on inverse le résultat obtenu. -     */ - -    iface = G_SHARED_INSTANCE_GET_IFACE(*b); - -    result = iface->compare(b, a) * -1; - -    return result; - -} diff --git a/src/arch/sharing/instance.h b/src/arch/sharing/instance.h deleted file mode 100644 index d9653ff..0000000 --- a/src/arch/sharing/instance.h +++ /dev/null @@ -1,77 +0,0 @@ - -/* Chrysalide - Outil d'analyse de fichiers binaires - * instance.h - prototypes pour le partage de données d'architecture quelconques - * - * Copyright (C) 2016-2017 Cyrille Bagard - * - *  This file is part of Chrysalide. - * - *  Chrysalide 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. - * - *  Chrysalide 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 _ARCH_SHARING_INSTANCE_H -#define _ARCH_SHARING_INSTANCE_H - - -#include <stdbool.h> -#include <glib-object.h> - - - -#define G_TYPE_SHARED_INSTANCE               (g_shared_instance_get_type()) -#define G_SHARED_INSTANCE(obj)               (G_TYPE_CHECK_INSTANCE_CAST((obj), G_TYPE_SHARED_INSTANCE, GSharedInstance)) -#define G_SHARED_INSTANCE_CLASS(vtable)      (G_TYPE_CHECK_CLASS_CAST((vtable), G_TYPE_SHARED_INSTANCE, GSharedInstanceIface)) -#define GTK_IS_SHARED_INSTANCE(obj)          (G_TYPE_CHECK_INSTANCE_TYPE((obj), G_TYPE_SHARED_INSTANCE)) -#define GTK_IS_SHARED_INSTANCE_CLASS(vtable) (G_TYPE_CHECK_CLASS_TYPE((vtable), G_TYPE_SHARED_INSTANCE)) -#define G_SHARED_INSTANCE_GET_IFACE(inst)    (G_TYPE_INSTANCE_GET_INTERFACE((inst), G_TYPE_SHARED_INSTANCE, GSharedInstanceIface)) - - -/* Règles de partage d'une instance GObject (coquille vide) */ -typedef struct _GSharedInstance GSharedInstance; - -/* Règles de partage d'une instance GObject (interface) */ -typedef struct _GSharedInstanceIface GSharedInstanceIface; - - -/* Détermine le type d'une interface pour le partage d'instance. */ -GType g_shared_instance_get_type(void) G_GNUC_CONST; - -/* Initialise un nouvel objet partagé avec des informations. */ -bool g_shared_instance_apply_template(GSharedInstance *, const GSharedInstance *); - -/* Réalise une copie minimale d'un contenu partagé. */ -void g_shared_instance_define_template(const GSharedInstance *, GSharedInstance *); - -/* Incrémente le compteur de références d'un élément partagé. */ -void g_shared_instance_ref(GSharedInstance *); - -/* Décrémente le compteur de références d'un élément partagé. */ -void g_shared_instance_unref(GSharedInstance *); - -/* Fournit la valeur du compteur de partage. */ -unsigned int g_shared_instance_get_references(const GSharedInstance *); - -/* Incrémente le compteur de partage. */ -void g_shared_instance_inc_references(GSharedInstance *); - -/* Décrémente le compteur de partage. */ -void g_shared_instance_dec_references(GSharedInstance *); - -/* Compare de façon accélérée un object partagé avec un autre. */ -int g_shared_instance_compare(const GSharedInstance * const *, const GSharedInstance * const *); - - - -#endif  /* _ARCH_SHARING_INSTANCE_H */ diff --git a/src/arch/sharing/manager.c b/src/arch/sharing/manager.c deleted file mode 100644 index 379c342..0000000 --- a/src/arch/sharing/manager.c +++ /dev/null @@ -1,431 +0,0 @@ - -/* Chrysalide - Outil d'analyse de fichiers binaires - * manager.c - collecte et gestion des instances partagées - * - * Copyright (C) 2016-2017 Cyrille Bagard - * - *  This file is part of Chrysalide. - * - *  Chrysalide 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. - * - *  Chrysalide 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 "manager.h" - - -#include <assert.h> -#include <malloc.h> -#ifdef DEBUG_DUMP_STATS -#   include <stdio.h> -#endif -#include <string.h> - - -#include "../../common/sort.h" - - - -/* Gestionnaire d'instances de type identique partagées (instance) */ -struct _GShareManager -{ -    GObject parent;                         /* A laisser en premier        */ - -    GSharedInstance **instances;            /* Instances partagées         */ -    size_t count;                           /* Quantité de ces instances   */ -    GMutex access;                          /* Accès à la table            */ - -    GType managed;                          /* Type d'instances gérées     */ - -}; - -/* Gestionnaire d'instances de type identique partagées (classe) */ -struct _GShareManagerClass -{ -    GObjectClass parent;                    /* A laisser en premier        */ - -}; - - -/* Procède à l'initialisation d'une classe de suivi de largeurs. */ -static void g_share_manager_class_init(GShareManagerClass *); - -/* Procède à l'initialisation d'un suivi de largeurs de lignes. */ -static void g_share_manager_init(GShareManager *); - -/* Supprime toutes les références externes. */ -static void g_share_manager_dispose(GShareManager *); - -/* Procède à la libération totale de la mémoire. */ -static void g_share_manager_finalize(GShareManager *); - -/* Note une augmentation des utilisations d'un élément partagé. */ -static void _g_share_manager_get(GShareManager *, GSharedInstance *); - - - -/* Détermine le type du gestionnaire d'instances partagées. */ -G_DEFINE_TYPE(GShareManager, g_share_manager, G_TYPE_OBJECT); - - -/****************************************************************************** -*                                                                             * -*  Paramètres  : class = classe de composant GTK à initialiser.               * -*                                                                             * -*  Description : Procède à l'initialisation d'une classe de suivi de largeurs.* -*                                                                             * -*  Retour      : -                                                            * -*                                                                             * -*  Remarques   : -                                                            * -*                                                                             * -******************************************************************************/ - -static void g_share_manager_class_init(GShareManagerClass *class) -{ -    GObjectClass *object;                   /* Autre version de la classe  */ - -    object = G_OBJECT_CLASS(class); - -    object->dispose = (GObjectFinalizeFunc/* ! */)g_share_manager_dispose; -    object->finalize = (GObjectFinalizeFunc)g_share_manager_finalize; - -} - - -/****************************************************************************** -*                                                                             * -*  Paramètres  : manager = composant GLib à initialiser.                      * -*                                                                             * -*  Description : Procède à l'initialisation d'un suivi de largeurs de lignes. * -*                                                                             * -*  Retour      : -                                                            * -*                                                                             * -*  Remarques   : -                                                            * -*                                                                             * -******************************************************************************/ - -static void g_share_manager_init(GShareManager *manager) -{ -    manager->instances = NULL; -    manager->count = 0; - -    g_mutex_init(&manager->access); - -} - - -/****************************************************************************** -*                                                                             * -*  Paramètres  : manager = instance d'objet GLib à traiter.                   * -*                                                                             * -*  Description : Supprime toutes les références externes.                     * -*                                                                             * -*  Retour      : -                                                            * -*                                                                             * -*  Remarques   : -                                                            * -*                                                                             * -******************************************************************************/ - -static void g_share_manager_dispose(GShareManager *manager) -{ -    size_t i;                               /* Boucle de parcours          */ - -    for (i = 0; i < manager->count; i++) -        g_object_unref(G_OBJECT(manager->instances[i])); - -    g_mutex_clear(&manager->access); - -    G_OBJECT_CLASS(g_share_manager_parent_class)->dispose(G_OBJECT(manager)); - -} - - -/****************************************************************************** -*                                                                             * -*  Paramètres  : manager = instance d'objet GLib à traiter.                   * -*                                                                             * -*  Description : Procède à la libération totale de la mémoire.                * -*                                                                             * -*  Retour      : -                                                            * -*                                                                             * -*  Remarques   : -                                                            * -*                                                                             * -******************************************************************************/ - -static void g_share_manager_finalize(GShareManager *manager) -{ -    if (manager->instances != NULL) -        free(manager->instances); - -    G_OBJECT_CLASS(g_share_manager_parent_class)->finalize(G_OBJECT(manager)); - -} - - -/****************************************************************************** -*                                                                             * -*  Paramètres  : type = type d'instances encadrées ici.                       * -*                                                                             * -*  Description : Crée un nouveau gestionnaire d'instances partagées.          * -*                                                                             * -*  Retour      : Composant GLib créé.                                         * -*                                                                             * -*  Remarques   : -                                                            * -*                                                                             * -******************************************************************************/ - -GShareManager *g_share_manager_new(GType type) -{ -    GShareManager *result;                  /* Gestionnaire à renvoyer     */ - -    result = g_object_new(G_TYPE_SHARE_MANAGER, NULL); - -    result->managed = type; - -    return result; - -} - - -/****************************************************************************** -*                                                                             * -*  Paramètres  : manager  = gestionnaire d'instance à consulter.              * -*                template = informations à retrouver intégralement.           * -*                                                                             * -*  Description : Retrouve ou crée une instance partagée.                      * -*                                                                             * -*  Retour      : Instance existante déjà partagée ou nouvellement créée.      * -*                                                                             * -*  Remarques   : -                                                            * -*                                                                             * -******************************************************************************/ - -GSharedInstance *g_share_manager_build(GShareManager *manager, GSharedInstance *template) -{ -    GSharedInstance *result;                /* Trouvaille à retourner      */ -    size_t index;                           /* Indice d'une instance idéale*/ -    bool found;                             /* Existence de cette instance */ -    bool status;                            /* Conclusion d'initialisation */ - -    g_mutex_lock(&manager->access); - -    found = bsearch_index(&template, manager->instances, manager->count, sizeof(GSharedInstance *), -                          (__compar_fn_t)g_shared_instance_compare, &index); - -    if (!found) -    { -        result = g_object_new(manager->managed, NULL); - -        status = g_shared_instance_apply_template(result, template); - -        if (!status) -        { -            g_object_unref(result); -            result = NULL; -        } - -        else -        { -            g_shared_instance_inc_references(result); - -            manager->instances = _qinsert(manager->instances, &manager->count, -                                          sizeof(GSharedInstance *), &result, index); - -        } - -    } - -    else -        result = manager->instances[index]; - -    _g_share_manager_get(manager, result); - -    g_mutex_unlock(&manager->access); - -    return result; - -} - - -/****************************************************************************** -*                                                                             * -*  Paramètres  : manager   = gestionnaire d'instance à consulter.             * -*                old       = ancienne instance partagée à faire évoluer.      * -*                template  = informations à retrouver intégralement.          * -*                container = propriétaire de l'ancienne version à contacter.  * -*                                                                             * -*  Description : Met à jour une instance partagée.                            * -*                                                                             * -*  Retour      : Instance existante déjà partagée ou nouvellement créée.      * -*                                                                             * -*  Remarques   : -                                                            * -*                                                                             * -******************************************************************************/ - -GSharedInstance *g_share_manager_update(GShareManager *manager, GSharedInstance *old, GSharedInstance *template, GShareContainer *container) -{ -    GSharedInstance *result;                /* Nouvelle instance à renvoyer*/ -    bool replaced;                          /* Remplacement effectué ?     */ - -    result = g_share_manager_build(manager, template); - -    if (container != NULL) -        replaced = g_share_container_replace(container, old, result); -    else -        replaced = true; - -    if (replaced) -        g_share_manager_put(manager, old); - -    else -    { -        g_share_manager_put(manager, result); -        result = old; -    } - -    return result; - -} - - -/****************************************************************************** -*                                                                             * -*  Paramètres  : manager  = gestionnaire d'instance à consulter.              * -*                instance = élément partagé à manipuler.                      * -*                                                                             * -*  Description : Note une augmentation des utilisations d'un élément partagé. * -*                                                                             * -*  Retour      : -                                                            * -*                                                                             * -*  Remarques   : -                                                            * -*                                                                             * -******************************************************************************/ - -static void _g_share_manager_get(GShareManager *manager, GSharedInstance *instance) -{ -#ifndef NDEBUG -    bool found;                             /* Existence de cette instance */ -#endif - -#ifndef NDEBUG - -    found = bsearch_index(&instance, manager->instances, manager->count, sizeof(GSharedInstance *), -                          (__compar_fn_t)g_shared_instance_compare, (size_t []) { 0 }); - -    assert(found); - -#endif - -    g_object_ref(G_OBJECT(instance)); -    g_shared_instance_inc_references(instance); - -} - - -/****************************************************************************** -*                                                                             * -*  Paramètres  : manager  = gestionnaire d'instance à consulter.              * -*                instance = élément partagé à manipuler.                      * -*                                                                             * -*  Description : Note une augmentation des utilisations d'un élément partagé. * -*                                                                             * -*  Retour      : -                                                            * -*                                                                             * -*  Remarques   : -                                                            * -*                                                                             * -******************************************************************************/ - -void g_share_manager_get(GShareManager *manager, GSharedInstance *instance) -{ -    g_mutex_lock(&manager->access); - -    _g_share_manager_get(manager, instance); - -    g_mutex_unlock(&manager->access); - -} - - -/****************************************************************************** -*                                                                             * -*  Paramètres  : manager = gestionnaire d'instance à consulter.               * -*                shared  = instance partagée à libérer.                       * -*                                                                             * -*  Description : Abandonne un usage d'une instance partagée.                  * -*                                                                             * -*  Retour      : -                                                            * -*                                                                             * -*  Remarques   : -                                                            * -*                                                                             * -******************************************************************************/ - -void g_share_manager_put(GShareManager *manager, GSharedInstance *shared) -{ -    g_mutex_lock(&manager->access); - -    g_shared_instance_dec_references(shared); - -    if (g_shared_instance_get_references(shared) == 1) -    { -        manager->instances = qdelete(manager->instances, &manager->count, -                                     sizeof(GSharedInstance *), -                                     (__compar_fn_t)g_shared_instance_compare, -                                     &shared); - -        g_object_unref(G_OBJECT(shared)); - -    } - -    g_mutex_unlock(&manager->access); - -} - - -/****************************************************************************** -*                                                                             * -*  Paramètres  : manager = gestionnaire d'instance à consulter.               * -*                                                                             * -*  Description : Imprime des statistiques d'utilisation du gestionnaire.      * -*                                                                             * -*  Retour      : -                                                            * -*                                                                             * -*  Remarques   : -                                                            * -*                                                                             * -******************************************************************************/ -#ifdef DEBUG_DUMP_STATS -void g_share_manager_dump_stats(GShareManager *manager) -{ -    unsigned int counter;                   /* Quantité nécessaire         */ -    size_t i;                               /* Boucle de parcours          */ -    GTypeQuery query;                       /* Informations sur un type    */ - -    counter = 0; - -    g_mutex_lock(&manager->access); - -    for (i = 0; i < manager->count; i++) -        counter += g_shared_instance_get_references(manager->instances[i]); - -    g_mutex_unlock(&manager->access); - -    g_type_query(manager->managed, &query); - -    printf("%s: current = %zu / %zu - needed = %u / %u (size=%u, saved=%zu)\n", -           query.type_name, -           manager->count, manager->count * query.instance_size, -           counter, counter * query.instance_size, -           query.instance_size, -           (counter - manager->count) * query.instance_size); - -} -#endif diff --git a/src/arch/sharing/manager.h b/src/arch/sharing/manager.h deleted file mode 100644 index c24fcc6..0000000 --- a/src/arch/sharing/manager.h +++ /dev/null @@ -1,81 +0,0 @@ - -/* Chrysalide - Outil d'analyse de fichiers binaires - * manager.h - prototypes pour la collecte et la gestion des instances partagées - * - * Copyright (C) 2016-2017 Cyrille Bagard - * - *  This file is part of Chrysalide. - * - *  Chrysalide 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. - * - *  Chrysalide 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 _ARCH_SHARING_MANAGER_H -#define _ARCH_SHARING_MANAGER_H - - -#include <glib-object.h> -#include <stdbool.h> - - -#include "container.h" -#include "instance.h" - - - -/* Compare une instance avec des informations similaires. */ -typedef gboolean (* compare_with_info_fc) (const GSharedInstance *, const void *); - - -#define G_TYPE_SHARE_MANAGER            (g_share_manager_get_type()) -#define G_SHARE_MANAGER(obj)            (G_TYPE_CHECK_INSTANCE_CAST((obj), G_TYPE_SHARE_MANAGER, GShareManager)) -#define G_SHARE_MANAGER_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST((klass), G_TYPE_SHARE_MANAGER, GShareManagerClass)) -#define G_IS_SHARE_MANAGER(obj)         (G_TYPE_CHECK_INSTANCE_TYPE((obj), G_TYPE_SHARE_MANAGER)) -#define G_IS_SHARE_MANAGER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), G_TYPE_SHARE_MANAGER)) -#define G_SHARE_MANAGER_GET_CLASS(obj)  (G_TYPE_INSTANCE_GET_CLASS((obj), G_TYPE_SHARE_MANAGER, GShareManagerClass)) - - -/* Gestionnaire d'instances de type identique partagées (instance) */ -typedef struct _GShareManager GShareManager; - -/* Gestionnaire d'instances de type identique partagées (classe) */ -typedef struct _GShareManagerClass GShareManagerClass; - - -/* Détermine le type du gestionnaire d'instances partagées. */ -GType g_share_manager_get_type(void); - -/* Crée un nouveau gestionnaire d'instances partagées. */ -GShareManager *g_share_manager_new(GType); - -/* Retrouve ou crée une instance partagée. */ -GSharedInstance *g_share_manager_build(GShareManager *, GSharedInstance *); - -/* Met à jour une instance partagée. */ -GSharedInstance *g_share_manager_update(GShareManager *, GSharedInstance *, GSharedInstance *, GShareContainer *); - -/* Note une augmentation des utilisations d'un élément partagé. */ -void g_share_manager_get(GShareManager *, GSharedInstance *); - -/* Abandonne un usage d'une instance partagée. */ -void g_share_manager_put(GShareManager *, GSharedInstance *); - -/* Imprime des statistiques d'utilisation du gestionnaire. */ -#ifdef DEBUG_DUMP_STATS -void g_share_manager_dump_stats(GShareManager *); -#endif - - - -#endif  /* _ARCH_SHARING_MANAGER_H */ diff --git a/src/arch/target.c b/src/arch/target.c index 3f6d9a5..2cd8518 100644 --- a/src/arch/target.c +++ b/src/arch/target.c @@ -33,16 +33,12 @@  #include "operand-int.h" -#include "sharing/manager.h"  #include "../analysis/routine.h"  #include "../common/extstr.h"  #include "../format/format.h" -/* ------------------------ GESTION DES OPERANDES DE CIBLAGE ------------------------ */ - -  /* Définition d'un opérande ciblant idéalement un symbole connu (instance) */  struct _GTargetOperand  { @@ -77,12 +73,6 @@ static void g_target_operand_dispose(GTargetOperand *);  /* Procède à la libération totale de la mémoire. */  static void g_target_operand_finalize(GTargetOperand *); -/* Initialise un nouvel objet partagé avec des informations. */ -static bool g_target_operand_apply_template(GTargetOperand *, const GTargetOperand *); - -/* Réalise une copie minimale d'un contenu partagé. */ -static void g_target_operand_define_template(const GTargetOperand *, GTargetOperand *); -  /* Compare un opérande avec un autre. */  static int g_target_operand_compare(const GTargetOperand *, const GTargetOperand *); @@ -94,23 +84,6 @@ static char *g_target_operand_build_tooltip(const GTargetOperand *, const GLoade -/* -------------------------- PARTAGES DE CONTENUS UNIQUES -------------------------- */ - - -/* Gestionnaire des partages d'instances */ -static GShareManager *_target_operand_manager = NULL; - - -/* Fournit le gestionnaire de partages attribué à un type. */ -static GShareManager *get_target_operand_share_manager(void); - - - -/* ---------------------------------------------------------------------------------- */ -/*                          GESTION DES OPERANDES DE CIBLAGE                          */ -/* ---------------------------------------------------------------------------------- */ - -  /* Indique le type défini pour un opérande de valeur numérique. */  G_DEFINE_TYPE(GTargetOperand, g_target_operand, G_TYPE_ARCH_OPERAND); @@ -139,11 +112,6 @@ static void g_target_operand_class_init(GTargetOperandClass *klass)      object->dispose = (GObjectFinalizeFunc/* ! */)g_target_operand_dispose;      object->finalize = (GObjectFinalizeFunc)g_target_operand_finalize; -    operand->get_manager = (get_operand_manager_fc)get_target_operand_share_manager; - -    operand->apply_template = (apply_operand_template_fc)g_target_operand_apply_template; -    operand->define_template = (define_operand_template_fc)g_target_operand_define_template; -      operand->compare = (operand_compare_fc)g_target_operand_compare;      operand->print = (operand_print_fc)g_target_operand_print;      operand->build_tooltip = (operand_build_tooltip_fc)g_target_operand_build_tooltip; @@ -217,55 +185,6 @@ static void g_target_operand_finalize(GTargetOperand *operand)  /******************************************************************************  *                                                                             * -*  Paramètres  : operand  = objet partagé à initialiser.                      * -*                template = coquille vide contenant les infos à enregistrer.  * -*                                                                             * -*  Description : Initialise un nouvel objet partagé avec des informations.    * -*                                                                             * -*  Retour      : Bilan de l'opération.                                        * -*                                                                             * -*  Remarques   : -                                                            * -*                                                                             * -******************************************************************************/ - -static bool g_target_operand_apply_template(GTargetOperand *operand, const GTargetOperand *template) -{ -    g_target_operand_define_template(template, operand); - -    if (operand->symbol != NULL) -        g_object_ref(G_OBJECT(operand->symbol)); - -    return true; - -} - - -/****************************************************************************** -*                                                                             * -*  Paramètres  : operand  = objet partagé à consulter.                        * -*                template = informations à retrouver intégralement.           * -*                                                                             * -*  Description : Réalise une copie minimale d'un contenu partagé.             * -*                                                                             * -*  Retour      : -                                                            * -*                                                                             * -*  Remarques   : -                                                            * -*                                                                             * -******************************************************************************/ - -static void g_target_operand_define_template(const GTargetOperand *operand, GTargetOperand *template) -{ -    template->size = operand->size; -    copy_vmpa(&template->addr, &operand->addr); - -    template->symbol = operand->symbol; -    template->diff = operand->diff; - -} - - -/****************************************************************************** -*                                                                             *  *  Paramètres  : a = premier opérande à consulter.                            *  *                b = second opérande à consulter.                             *  *                                                                             * @@ -401,17 +320,14 @@ static void g_target_operand_print(const GTargetOperand *operand, GBufferLine *l  GArchOperand *g_target_operand_new(MemoryDataSize size, const vmpa2t *addr)  { -    GArchOperand *result;                   /* Opérande à retourner        */ -    GTargetOperand fake;                    /* Transport d'informations    */ +    GTargetOperand *result;                 /* Opérande à retourner        */ -    g_target_operand_init(&fake); +    result = g_object_new(G_TYPE_TARGET_OPERAND, NULL); -    fake.size = size; -    copy_vmpa(&fake.addr, addr); +    result->size = size; +    copy_vmpa(&result->addr, addr); -    result = G_ARCH_OPERAND(g_share_manager_build(_target_operand_manager, (GSharedInstance *)&fake)); - -    return result; +    return G_ARCH_OPERAND(result);  } @@ -527,10 +443,9 @@ void g_target_operand_get_addr(const GTargetOperand *operand, vmpa2t *addr)  /******************************************************************************  *                                                                             * -*  Paramètres  : operand   = opérande dont le contenu est à raffiner. [OUT]   * -*                format    = format du binaire d'origine à consulter.         * -*                strict    = indique la perfection attendue de la résolution. * -*                container = propriétaire d'origine à tenir au courant.       * +*  Paramètres  : operand = opérande dont le contenu est à raffiner. [OUT]     * +*                format  = format du binaire d'origine à consulter.           * +*                strict  = indique la perfection attendue de la résolution.   *  *                                                                             *  *  Description : Tente une résolution de symbole.                             *  *                                                                             * @@ -540,28 +455,18 @@ void g_target_operand_get_addr(const GTargetOperand *operand, vmpa2t *addr)  *                                                                             *  ******************************************************************************/ -bool g_target_operand_resolve(GTargetOperand **operand, GBinFormat *format, bool strict, GShareContainer *container) +bool g_target_operand_resolve(GTargetOperand *operand, GBinFormat *format, bool strict)  {      bool result;                            /* Bilan à retourner           */ -    GSharedInstance *shared;                /* Instace de travail partagée */ -    GTargetOperand template;                /* Transport d'informations    */      GBinSymbol *symbol;                     /* Facilités d'accès au symbole*/      SymbolType stype;                       /* Type de symbole trouvé      */      const mrange_t *range;                  /* Couverture du symbole       */      char *label;                            /* Désignation de la chaîne    */ -    shared = G_SHARED_INSTANCE(*operand); - -    g_shared_instance_define_template(shared, (GSharedInstance *)&template); - -    result = g_binary_format_resolve_symbol(format, &template.addr, strict, &template.symbol, &template.diff); - -    shared = g_share_manager_update(_target_operand_manager, shared, (GSharedInstance *)&template, container); - -    if (template.symbol != NULL) -        g_object_unref(G_OBJECT(template.symbol)); +    if (operand->symbol != NULL) +        g_object_unref(G_OBJECT(operand->symbol)); -    *operand = G_TARGET_OPERAND(shared); +    result = g_binary_format_resolve_symbol(format, &operand->addr, strict, &operand->symbol, &operand->diff);      /**       * Si plusieurs chaînes se suivent, la seconde et les suivantes bénéficient @@ -575,9 +480,9 @@ bool g_target_operand_resolve(GTargetOperand **operand, GBinFormat *format, bool       * attribue à cette ligne une étiquette propre.       */ -    if (result && (*operand)->diff == 0) +    if (result && operand->diff == 0)      { -        symbol = (*operand)->symbol; +        symbol = operand->symbol;          stype = g_binary_symbol_get_target_type(symbol); @@ -587,7 +492,7 @@ bool g_target_operand_resolve(GTargetOperand **operand, GBinFormat *format, bool              {                  range = g_binary_symbol_get_range(symbol); -                assert(cmp_vmpa(&(*operand)->addr, get_mrange_addr(range)) == 0); +                assert(cmp_vmpa(&operand->addr, get_mrange_addr(range)) == 0);                  label = create_string_label(format, get_mrange_addr(range), get_mrange_length(range)); @@ -634,88 +539,3 @@ GBinSymbol *g_target_operand_get_symbol(const GTargetOperand *operand, phys_t *d      return result;  } - - - -/* ---------------------------------------------------------------------------------- */ -/*                            PARTAGES DE CONTENUS UNIQUES                            */ -/* ---------------------------------------------------------------------------------- */ - - -/****************************************************************************** -*                                                                             * -*  Paramètres  : -                                                            * -*                                                                             * -*  Description : Fournit le gestionnaire de partages attribué à un type.      * -*                                                                             * -*  Retour      : Gestionnaire de partages en place.                           * -*                                                                             * -*  Remarques   : -                                                            * -*                                                                             * -******************************************************************************/ - -static GShareManager *get_target_operand_share_manager(void) -{ -    return _target_operand_manager; - -} - - -/****************************************************************************** -*                                                                             * -*  Paramètres  : -                                                            * -*                                                                             * -*  Description : Initialise les mécanismes de partage d'opérandes de ciblage. * -*                                                                             * -*  Retour      : Bilan de l'opération.                                        * -*                                                                             * -*  Remarques   : -                                                            * -*                                                                             * -******************************************************************************/ - -bool init_target_operand_sharing(void) -{ -    _target_operand_manager = g_share_manager_new(G_TYPE_TARGET_OPERAND); - -    return true; - -} - - -/****************************************************************************** -*                                                                             * -*  Paramètres  : -                                                            * -*                                                                             * -*  Description : Imprime des statistiques quant aux partages dans l'archi.    * -*                                                                             * -*  Retour      : -                                                            * -*                                                                             * -*  Remarques   : -                                                            * -*                                                                             * -******************************************************************************/ -#ifdef DEBUG_DUMP_STATS -void dump_target_operand_share_stats(void) -{ -    g_share_manager_dump_stats(_target_operand_manager); - -} -#endif - - -/****************************************************************************** -*                                                                             * -*  Paramètres  : -                                                            * -*                                                                             * -*  Description : Supprime les mécanismes de partage des opérandes de ciblage. * -*                                                                             * -*  Retour      : -                                                            * -*                                                                             * -*  Remarques   : -                                                            * -*                                                                             * -******************************************************************************/ - -void exit_target_operand_sharing(void) -{ -    g_object_unref(G_OBJECT(_target_operand_manager)); - -} diff --git a/src/arch/target.h b/src/arch/target.h index affe59e..529dba8 100644 --- a/src/arch/target.h +++ b/src/arch/target.h @@ -32,14 +32,10 @@  #include "archbase.h"  #include "operand.h"  #include "vmpa.h" -#include "sharing/container.h"  #include "../format/format.h" -/* ------------------------ GESTION DES OPERANDES DE CIBLAGE ------------------------ */ - -  #define G_TYPE_TARGET_OPERAND               g_target_operand_get_type()  #define G_TARGET_OPERAND(obj)               (G_TYPE_CHECK_INSTANCE_CAST((obj), g_target_operand_get_type(), GTargetOperand))  #define G_IS_TARGET_OPERAND(obj)            (G_TYPE_CHECK_INSTANCE_TYPE((obj), g_target_operand_get_type())) @@ -68,27 +64,11 @@ MemoryDataSize g_target_operand_get_size(const GTargetOperand *);  void g_target_operand_get_addr(const GTargetOperand *, vmpa2t *);  /* Tente une résolution de symbole. */ -bool g_target_operand_resolve(GTargetOperand **, GBinFormat *, bool, GShareContainer *); +bool g_target_operand_resolve(GTargetOperand *, GBinFormat *, bool);  /* Fournit les indications concernant le symbole associé. */  GBinSymbol *g_target_operand_get_symbol(const GTargetOperand *, phys_t *); -/* -------------------------- PARTAGES DE CONTENUS UNIQUES -------------------------- */ - - -/* Initialise les mécanismes de partage des opérandes de ciblage. */ -bool init_target_operand_sharing(void); - -/* Imprime des statistiques quant aux partages dans l'archi. */ -#ifdef DEBUG_DUMP_STATS -void dump_target_operand_share_stats(void); -#endif - -/* Supprime les mécanismes de partage des opérandes de ciblage. */ -void exit_target_operand_sharing(void); - - -  #endif  /* _ARCH_TARGET_H */  | 
