diff options
| author | Cyrille Bagard <nocbos@gmail.com> | 2018-04-02 11:58:42 (GMT) | 
|---|---|---|
| committer | Cyrille Bagard <nocbos@gmail.com> | 2018-04-02 12:39:30 (GMT) | 
| commit | 1db4ef323b7a76093356ae76268132f3760e1631 (patch) | |
| tree | fec36ee0ec1b6b2010b62ca4177edca0e31e2114 /src | |
| parent | 1bc80837dde03a32b5ab185067f7bd4c499a9850 (diff) | |
Rewritten the whole instruction definition format.
Diffstat (limited to 'src')
| -rw-r--r-- | src/arch/instruction-int.h | 14 | ||||
| -rw-r--r-- | src/arch/instruction.c | 24 | ||||
| -rw-r--r-- | src/arch/instruction.h | 44 | 
3 files changed, 65 insertions, 17 deletions
| diff --git a/src/arch/instruction-int.h b/src/arch/instruction-int.h index 081adba..782c827 100644 --- a/src/arch/instruction-int.h +++ b/src/arch/instruction-int.h @@ -40,6 +40,9 @@ typedef const char * (* get_instruction_keyword_fc) (GArchInstruction *, AsmSynt  /* Construit un petit résumé concis de l'instruction. */  typedef char * (* build_instruction_tooltip_fc) (const GArchInstruction *); +/* Fournit une description pour l'instruction manipulée. */ +typedef const char * (* get_instruction_desc_fc) (const GArchInstruction *); +  /* Ajoute à un tampon GLib le contenu de l'instance spécifiée. */  typedef GBufferLine * (* print_instruction_fc) (const GArchInstruction *, GBufferLine *, size_t, size_t, const GBinContent *); @@ -82,6 +85,8 @@ struct _GArchInstruction      flat_array_t *from;                     /* Origines des références     */      flat_array_t *to;                       /* Instructions visées         */ +    itid_t uid;                             /* Identifiant unique du type  */ +      ArchInstrFlag flags;                    /* Informations complémentaires*/  }; @@ -95,6 +100,7 @@ struct _GArchInstructionClass      get_instruction_encoding_fc get_encoding; /* Obtention de l'encodage   */      get_instruction_keyword_fc get_keyword; /* Texte humain équivalent     */      build_instruction_tooltip_fc build_tooltip; /* Construction d'une bulle*/ +    get_instruction_desc_fc get_desc;       /* Description assez complète  */      print_instruction_fc print;             /* Imprime l'ensemble          */ @@ -103,5 +109,13 @@ struct _GArchInstructionClass  }; +/** + * Fournit une marge pour toutes les instructions particulières communes + * à l'ensemble des architectures (GRawInstruction, GUndefInstruction). + */ + +#define INSTR_TYPE_ID_OFFSET 5 + +  #endif  /* _ARCH_INSTRUCTION_INT_H */ diff --git a/src/arch/instruction.c b/src/arch/instruction.c index 0041129..9c0a47c 100644 --- a/src/arch/instruction.c +++ b/src/arch/instruction.c @@ -1089,6 +1089,30 @@ char *g_arch_instruction_build_tooltip(const GArchInstruction *instr)  } +/****************************************************************************** +*                                                                             * +*  Paramètres  : instr = instruction d'assemblage à consulter.                * +*                                                                             * +*  Description : Fournit une description pour l'instruction manipulée.        * +*                                                                             * +*  Retour      : Chaîne de caractères avec balises éventuelles.               * +*                                                                             * +*  Remarques   : -                                                            * +*                                                                             * +******************************************************************************/ +   +const char *g_arch_instruction_get_description(const GArchInstruction *instr) +{ +    const char *result;                     /* Description à retourner     */ + +    result = G_ARCH_INSTRUCTION_GET_CLASS(instr)->get_desc(instr); + +    return result; +   +} + + +  /* ---------------------------------------------------------------------------------- */  /*                          OFFRE DE CAPACITES DE GENERATION                          */  /* ---------------------------------------------------------------------------------- */ diff --git a/src/arch/instruction.h b/src/arch/instruction.h index ca047b7..0f6eac6 100644 --- a/src/arch/instruction.h +++ b/src/arch/instruction.h @@ -53,12 +53,6 @@ typedef struct _GArchInstruction GArchInstruction;  typedef struct _GArchInstructionClass GArchInstructionClass; -/* Indique le type défini pour une instruction d'architecture. */ -GType g_arch_instruction_get_type(void); - -/* Indique l'encodage d'une instruction de façon détaillée. */ -const char *g_arch_instruction_get_encoding(const GArchInstruction *); -  /* Drapeaux pour informations complémentaires */  typedef enum _ArchInstrFlag  { @@ -68,12 +62,36 @@ typedef enum _ArchInstrFlag  } ArchInstrFlag; +/* Type pour les types d'instructions */ +typedef uint16_t itid_t; + +/* Types de crochet de traitement */ +typedef enum _InstrProcessHook +{ +    IPH_FETCH,                              /* Itinéraire de désassemblage */ +    IPH_LINK,                               /* Edition des liens           */ +    IPH_POST,                               /* Résolution des symboles     */ + +    IPH_COUNT + +} InstrProcessHook; + + +/* Indique le type défini pour une instruction d'architecture. */ +GType g_arch_instruction_get_type(void); + +/* Indique l'encodage d'une instruction de façon détaillée. */ +const char *g_arch_instruction_get_encoding(const GArchInstruction *); +  /* Ajoute une information complémentaire à une instruction. */  bool g_arch_instruction_set_flag(GArchInstruction *, ArchInstrFlag);  /* Fournit les informations complémentaires d'une instruction. */  ArchInstrFlag g_arch_instruction_get_flags(const GArchInstruction *); +/* Fournit l'identifiant unique pour un ensemble d'instructions. */ +itid_t g_arch_instruction_get_type_id(const GArchInstruction *instr); +  /**   * La définition de "GArchProcessor", utile aux traitements complémentaires, ne peut @@ -87,17 +105,6 @@ ArchInstrFlag g_arch_instruction_get_flags(const GArchInstruction *);  typedef struct _GArchProcessor GArchProcessor; -/* Types de crochet de traitement */ -typedef enum _InstrProcessHook -{ -    IPH_FETCH,                              /* Itinéraire de désassemblage */ -    IPH_LINK,                               /* Edition des liens           */ -    IPH_POST,                               /* Résolution des symboles     */ - -    IPH_COUNT - -} InstrProcessHook; -  /* Complète un désassemblage accompli pour une instruction. */  typedef void (* instr_hook_fc) (GArchInstruction *, GArchProcessor *, GProcContext *, GExeFormat *); @@ -251,6 +258,9 @@ const char *g_arch_instruction_get_keyword(GArchInstruction *, AsmSyntax);  /* Construit un petit résumé concis de l'instruction. */  char *g_arch_instruction_build_tooltip(const GArchInstruction *); +/* Fournit une description pour l'instruction manipulée. */ +const char *g_arch_instruction_get_description(const GArchInstruction *); +  #endif  /* _ARCH_INSTRUCTION_H */ | 
