From b9811a151ebeca6b64cdfc0a07df697ecfe84d7e Mon Sep 17 00:00:00 2001 From: Cyrille Bagard Date: Thu, 30 May 2019 12:45:31 +0200 Subject: Introduced a new flag for instruction calls. --- src/arch/instruction.c | 77 ++++++++++++++++++++++++++++++++++++++++++++++---- src/arch/instruction.h | 9 +++++- 2 files changed, 80 insertions(+), 6 deletions(-) diff --git a/src/arch/instruction.c b/src/arch/instruction.c index 8e9d3d3..5880c34 100644 --- a/src/arch/instruction.c +++ b/src/arch/instruction.c @@ -288,20 +288,21 @@ bool g_arch_instruction_set_flag(GArchInstruction *instr, ArchInstrFlag flag) /****************************************************************************** * * * Paramètres : instr = instruction quelconque à consulter. * +* flag = drapeau d'information à rechercher. * * * -* Description : Fournit l'identifiant unique pour un ensemble d'instructions.* +* Description : Détermine si une instruction possède un fanion particulier. * * * -* Retour : Identifiant unique par type d'instruction et architecture. * +* Retour : Bilan de la détection. * * * * Remarques : - * * * ******************************************************************************/ -itid_t g_arch_instruction_get_unique_id(const GArchInstruction *instr) +bool g_arch_instruction_has_flag(const GArchInstruction *instr, ArchInstrFlag flag) { - itid_t result; /* Numéro à retourner */ + bool result; /* Bilan à retourner */ - result = instr->uid; + result = (instr->flags & flag); return result; @@ -329,6 +330,29 @@ ArchInstrFlag g_arch_instruction_get_flags(const GArchInstruction *instr) /****************************************************************************** * * +* Paramètres : instr = instruction quelconque à consulter. * +* * +* Description : Fournit l'identifiant unique pour un ensemble d'instructions.* +* * +* Retour : Identifiant unique par type d'instruction et architecture. * +* * +* Remarques : - * +* * +******************************************************************************/ + +itid_t g_arch_instruction_get_unique_id(const GArchInstruction *instr) +{ + itid_t result; /* Numéro à retourner */ + + result = instr->uid; + + return result; + +} + + +/****************************************************************************** +* * * Paramètres : instr = instruction quelconque à traiter. * * type = type de procédure à utiliser. * * proc = représentation de l'architecture utilisée. * @@ -714,6 +738,49 @@ void g_arch_instruction_lock_unlock_links(GArchInstruction *instr, bool src, boo /****************************************************************************** * * * Paramètres : instr = instruction dont les informations sont à consulter. * +* type = type de lien à détecter. * +* * +* Description : Détermine si un type de lien existe dans une instruction. * +* * +* Retour : Bilan du statut courant de l'instruction. * +* * +* Remarques : - * +* * +******************************************************************************/ + +bool g_arch_instruction_has_link(GArchInstruction *instr, InstructionLinkType type) +{ + bool result; /* Bilan à retourner */ + size_t count; /* Nombre de liens à parcourir */ + size_t i; /* Boucle de parcours */ + const instr_link_t *dlink; /* Définition de destination */ + + result = false; + + g_arch_instruction_lock_dest(instr); + + count = g_arch_instruction_count_destinations(instr); + + for (i = 0; i < count && !result; i++) + { + dlink = g_arch_instruction_get_destination(instr, i); + + result = (dlink->type == type); + + unref_instr_link(dlink); + + } + + g_arch_instruction_unlock_dest(instr); + + return result; + +} + + +/****************************************************************************** +* * +* Paramètres : instr = instruction dont les informations sont à consulter. * * dest = ligne visée par la liaison (côté destination). * * * * Description : Détermine si un lien est déjà établi entre deux instructions.* diff --git a/src/arch/instruction.h b/src/arch/instruction.h index cf9189b..d1bfbe2 100644 --- a/src/arch/instruction.h +++ b/src/arch/instruction.h @@ -58,7 +58,8 @@ typedef enum _ArchInstrFlag { AIF_NONE = (0 << 0), /* Aucune information */ AIF_ROUTINE_START = (1 << 0), /* Début de routine */ - AIF_RETURN_POINT = (1 << 1) /* Retour de fonction appelée */ + AIF_RETURN_POINT = (1 << 1), /* Retour de fonction appelée */ + AIF_CALL = (1 << 2) /* Instruction d'appel */ } ArchInstrFlag; @@ -86,6 +87,9 @@ const char *g_arch_instruction_get_encoding(const GArchInstruction *); /* Ajoute une information complémentaire à une instruction. */ bool g_arch_instruction_set_flag(GArchInstruction *, ArchInstrFlag); +/* Détermine si une instruction possède un fanion particulier. */ +bool g_arch_instruction_has_flag(const GArchInstruction *, ArchInstrFlag); + /* Fournit les informations complémentaires d'une instruction. */ ArchInstrFlag g_arch_instruction_get_flags(const GArchInstruction *); @@ -228,6 +232,9 @@ typedef struct _instr_link_t /* Met à disposition un encadrement des accès aux liens. */ void g_arch_instruction_lock_unlock_links(GArchInstruction *, bool, bool); +/* Détermine si un type de lien existe dans une instruction. */ +bool g_arch_instruction_has_link(GArchInstruction *, InstructionLinkType); + /* Détermine si un lien est déjà établi entre deux instructions. */ bool g_arch_instruction_has_link_to(GArchInstruction *, const GArchInstruction *); -- cgit v0.11.2-87-g4458