diff options
Diffstat (limited to 'src/analysis/disass/dragon.c')
-rw-r--r-- | src/analysis/disass/dragon.c | 51 |
1 files changed, 32 insertions, 19 deletions
diff --git a/src/analysis/disass/dragon.c b/src/analysis/disass/dragon.c index 01e985d..cc1346c 100644 --- a/src/analysis/disass/dragon.c +++ b/src/analysis/disass/dragon.c @@ -49,7 +49,7 @@ struct _dragon_node /* Dénombre le nombre de noeuds présents dans une routine. */ -static dragon_node *create_dragon_nodes(const GArchProcessor *, const instr_coverage *, const mrange_t *, const vmpa2t *, size_t *); +static dragon_node *create_dragon_nodes(GArchProcessor *, const instr_coverage *, const mrange_t *, const vmpa2t *, size_t *); /* Supprime de la mémoire tous les noeuds détectés. */ static void delete_dragon_nodes(dragon_node *, size_t); @@ -93,13 +93,14 @@ struct _dragon_knight * * ******************************************************************************/ -static dragon_node *create_dragon_nodes(const GArchProcessor *proc, const instr_coverage *coverage, const mrange_t *range, const vmpa2t *start, size_t *count) +static dragon_node *create_dragon_nodes(GArchProcessor *proc, const instr_coverage *coverage, const mrange_t *range, const vmpa2t *start, size_t *count) { dragon_node *result; /* Liste à créer et renvoyer */ size_t allocated; /* Dimensionnement en mémoire */ bool need_alloc; /* Besoin d'une extension ? */ GArchInstruction *last; /* Mémorisation du passé */ - GArchInstruction *iter; /* Boucle de parcours */ + instr_iter_t *iter; /* Boucle de parcours */ + GArchInstruction *instr; /* Instruction analysée */ const mrange_t *irange; /* Emplacement d'instruction */ instr_link_t *sources; /* Liste des instructions liées*/ size_t scount; /* Nombre de liens de source */ @@ -115,16 +116,22 @@ static dragon_node *create_dragon_nodes(const GArchProcessor *proc, const instr_ allocated = 0; need_alloc = true; - for (last = NULL, iter = g_arch_processor_find_covered_instr_by_address(proc, coverage, start); - iter != NULL; - last = iter, iter = g_arch_instruction_get_next_iter(iter /* FIXME : list*/, iter, ~0)) + iter = g_arch_processor_get_covered_iter_from_address(proc, coverage, start); + if (iter == NULL) goto cdn_no_coverage; + + for (last = NULL, instr = get_instruction_iterator_current(iter); + instr != NULL; + last = instr, instr = get_instruction_iterator_next(iter)) { /* L'instruction sort-elle des clous ? */ - irange = g_arch_instruction_get_range(iter); + irange = g_arch_instruction_get_range(instr); if (!mrange_contains_mrange(range, irange)) + { + g_object_unref(G_OBJECT(instr)); break; + } /* Découpage en blocs */ @@ -142,7 +149,7 @@ static dragon_node *create_dragon_nodes(const GArchProcessor *proc, const instr_ new = &result[*count - 1]; - new->first = iter; + new->first = instr; } @@ -165,8 +172,8 @@ static dragon_node *create_dragon_nodes(const GArchProcessor *proc, const instr_ { /* Analyse des sources */ - g_arch_instruction_rlock_src(iter); - scount = g_arch_instruction_get_sources(iter, &sources); + g_arch_instruction_rlock_src(instr); + scount = g_arch_instruction_get_sources(instr, &sources); cut = false; @@ -192,7 +199,7 @@ static dragon_node *create_dragon_nodes(const GArchProcessor *proc, const instr_ new = &result[*count - 1]; - new->first = iter; + new->first = instr; cut = true; @@ -203,14 +210,14 @@ static dragon_node *create_dragon_nodes(const GArchProcessor *proc, const instr_ } - g_arch_instruction_runlock_src(iter); + g_arch_instruction_runlock_src(instr); } /* Analyse des destinations */ - g_arch_instruction_rlock_dest(iter); - dcount = g_arch_instruction_get_destinations(iter, &dests); + g_arch_instruction_rlock_dest(instr); + dcount = g_arch_instruction_get_destinations(instr, &dests); cut = false; @@ -219,7 +226,7 @@ static dragon_node *create_dragon_nodes(const GArchProcessor *proc, const instr_ { case ILT_JUMP: - result[*count - 1].last = iter; + result[*count - 1].last = instr; cut = true; @@ -232,21 +239,27 @@ static dragon_node *create_dragon_nodes(const GArchProcessor *proc, const instr_ } - g_arch_instruction_runlock_dest(iter); + g_arch_instruction_runlock_dest(instr); - if (!need_alloc && g_arch_instruction_get_flags(iter) & AIF_RETURN_POINT) + if (!need_alloc && g_arch_instruction_get_flags(instr) & AIF_RETURN_POINT) { - result[*count - 1].last = iter; + result[*count - 1].last = instr; need_alloc = true; } + g_object_unref(G_OBJECT(instr)); + } if (*count > 0) result[*count - 1].last = last; + delete_instruction_iterator(iter); + + cdn_no_coverage: + return result; } @@ -623,7 +636,7 @@ const bitfield_t *get_domination_bits(const dragon_node *node) * * ******************************************************************************/ -dragon_knight *begin_dragon_knight(const GArchProcessor *proc, const instr_coverage *coverage, const mrange_t *range, const vmpa2t *start) +dragon_knight *begin_dragon_knight(GArchProcessor *proc, const instr_coverage *coverage, const mrange_t *range, const vmpa2t *start) { dragon_knight *result; /* Données à retourner */ dragon_node *nodes; /* Noeuds mis en place */ |