diff options
Diffstat (limited to 'src/analysis/disass/dragon.c')
-rw-r--r-- | src/analysis/disass/dragon.c | 64 |
1 files changed, 42 insertions, 22 deletions
diff --git a/src/analysis/disass/dragon.c b/src/analysis/disass/dragon.c index b4c85c0..75ccc40 100644 --- a/src/analysis/disass/dragon.c +++ b/src/analysis/disass/dragon.c @@ -101,13 +101,13 @@ static dragon_node *create_dragon_nodes(GArchProcessor *proc, const instr_covera GArchInstruction *last; /* Mémorisation du passé */ instr_iter_t *iter; /* Boucle de parcours */ GArchInstruction *instr; /* Instruction analysée */ - instr_link_t *sources; /* Liste des instructions liées*/ size_t scount; /* Nombre de liens de source */ bool cut; /* Un découpage a été réalisé ?*/ size_t i; /* Boucle de parcours */ + instr_link_t *source; /* Instruction de source liée */ dragon_node *new; /* Nouvel élément à créer */ - instr_link_t *dests; /* Liste des instructions liées*/ size_t dcount; /* Nombre de liens de dest. */ + instr_link_t *dest; /* Instruction de destination */ result = NULL; *count = 0; @@ -163,13 +163,16 @@ static dragon_node *create_dragon_nodes(GArchProcessor *proc, const instr_covera { /* Analyse des sources */ - g_arch_instruction_rlock_src(instr); - scount = g_arch_instruction_get_sources(instr, &sources); + g_arch_instruction_lock_src(instr); + scount = g_arch_instruction_count_sources(instr); cut = false; for (i = 0; i < scount && !cut; i++) - switch (sources[i].type) + { + source = g_arch_instruction_get_source(instr, i); + + switch (source->type) { case ILT_EXEC_FLOW: case ILT_JUMP: @@ -201,19 +204,24 @@ static dragon_node *create_dragon_nodes(GArchProcessor *proc, const instr_covera } - g_arch_instruction_runlock_src(instr); + } + + g_arch_instruction_unlock_src(instr); } /* Analyse des destinations */ - g_arch_instruction_rlock_dest(instr); - dcount = g_arch_instruction_get_destinations(instr, &dests); + g_arch_instruction_lock_dest(instr); + dcount = g_arch_instruction_count_destinations(instr); cut = false; for (i = 0; i < dcount && !cut; i++) - switch (dests[i].type) + { + dest = g_arch_instruction_get_destination(instr, i); + + switch (dest->type) { case ILT_JUMP: @@ -230,7 +238,9 @@ static dragon_node *create_dragon_nodes(GArchProcessor *proc, const instr_covera } - g_arch_instruction_runlock_dest(instr); + } + + g_arch_instruction_unlock_dest(instr); if (!need_alloc && g_arch_instruction_get_flags(instr) & AIF_RETURN_POINT) { @@ -436,17 +446,20 @@ void compute_all_paths(dragon_node *nodes, size_t count) { void follow_flow_in_nodes(dragon_node *node) { - instr_link_t *dests; /* Liste des instructions liées*/ size_t dcount; /* Nombre de liens de dest. */ size_t i; /* Boucle de parcours */ + instr_link_t *dest; /* Instructions de destination */ dragon_node *next; /* Noeud suivant dans le code */ size_t id; /* Indice du bit associé */ - g_arch_instruction_rlock_dest(node->last); - dcount = g_arch_instruction_get_destinations(node->last, &dests); + g_arch_instruction_lock_dest(node->last); + dcount = g_arch_instruction_count_destinations(node->last); for (i = 0; i < dcount; i++) - switch (dests[i].type) + { + dest = g_arch_instruction_get_destination(node->last, i); + + switch (dest->type) { case ILT_EXEC_FLOW: case ILT_JUMP: @@ -454,7 +467,7 @@ void compute_all_paths(dragon_node *nodes, size_t count) case ILT_JUMP_IF_TRUE: case ILT_JUMP_IF_FALSE: - next = find_node_for_instruction(nodes, count, false, dests[i].linked); + next = find_node_for_instruction(nodes, count, false, dest->linked); if (next == NULL) break; id = get_dragon_node_index(nodes, next); @@ -470,7 +483,9 @@ void compute_all_paths(dragon_node *nodes, size_t count) } - g_arch_instruction_runlock_dest(node->last); + } + + g_arch_instruction_unlock_dest(node->last); } @@ -518,9 +533,9 @@ void compute_all_dominators(dragon_node *nodes, size_t count) size_t k; /* Boucle de parcours #1 */ dragon_node *node; /* Noeud à traiter */ dragon_node *predecessor; /* Noeud prédécesseur direct */ - instr_link_t *sources; /* Instructions d'origine */ size_t scount; /* Nombre de liens de source */ size_t i; /* Boucle de parcours #2 */ + instr_link_t *source; /* Instruction d'origine */ inter = create_bit_field(count, false); @@ -534,12 +549,15 @@ void compute_all_dominators(dragon_node *nodes, size_t count) set_all_in_bit_field(inter); - g_arch_instruction_rlock_src(node->first); - scount = g_arch_instruction_get_sources(node->first, &sources); + g_arch_instruction_lock_src(node->first); + scount = g_arch_instruction_count_sources(node->first); //assert(scount > 0); // un 'ret' coupe, le suivant n'a pas de source for (i = 0; i < scount; i++) - switch (sources[i].type) + { + source = g_arch_instruction_get_source(node->first, i); + + switch (source->type) { case ILT_EXEC_FLOW: case ILT_JUMP: @@ -547,7 +565,7 @@ void compute_all_dominators(dragon_node *nodes, size_t count) case ILT_JUMP_IF_TRUE: case ILT_JUMP_IF_FALSE: - predecessor = find_node_for_instruction(nodes, count, true, sources[i].linked); + predecessor = find_node_for_instruction(nodes, count, true, source->linked); /* printf(" -- finding pred @ 0x%08x -> 0x%08x :: %p\n", @@ -567,7 +585,9 @@ void compute_all_dominators(dragon_node *nodes, size_t count) } - g_arch_instruction_runlock_src(node->first); + } + + g_arch_instruction_unlock_src(node->first); set_in_bit_field(inter, k, 1); |