diff options
Diffstat (limited to 'src/arch/processor.c')
-rw-r--r-- | src/arch/processor.c | 45 |
1 files changed, 21 insertions, 24 deletions
diff --git a/src/arch/processor.c b/src/arch/processor.c index 24e2db6..5cc1951 100644 --- a/src/arch/processor.c +++ b/src/arch/processor.c @@ -405,8 +405,9 @@ size_t g_arch_processor_count_instructions(const GArchProcessor *proc) /****************************************************************************** * * -* Paramètres : proc = architecture visée par la procédure. * -* list = liste des instructions désassemblées. * +* Paramètres : proc = architecture visée par la procédure. * +* list = liste des instructions désassemblées. * +* count = taille de cette liste. * * * * Description : Note les instructions désassemblées avec une architecture. * * * @@ -416,48 +417,44 @@ size_t g_arch_processor_count_instructions(const GArchProcessor *proc) * * ******************************************************************************/ -void g_arch_processor_set_disassembled_instructions(GArchProcessor *proc, GArchInstruction *list) +void g_arch_processor_set_instructions(GArchProcessor *proc, GArchInstruction **list, size_t count) { GArchInstruction *last; /* Dernière instruction traitée*/ - GArchInstruction *iter; /* Boucle de parcours */ + size_t i; /* Boucle de parcours */ + GArchInstruction *instr; /* Instruction à analyser */ + + g_arch_processor_lock(proc); - /* TODO : vider une éventuelle liste existante */ - /* TODO : incrémenter les références (cf. code Python) */ + proc->instructions = list; + proc->instr_count = count; + proc->stamp++; last = NULL; - ainstr_list_for_each(iter, list) + for (i = 0; i < count; i++) { - /* Mise à disposition de d'avantage d'espace */ - if (proc->instr_allocated == proc->instr_count) - { - proc->instr_allocated += INSTR_ALLOC_BLOCK; - - proc->instructions = (GArchInstruction **)realloc(proc->instructions, - proc->instr_allocated * sizeof(GArchInstruction *)); - - } + instr = list[i]; /* Constitution des groupes */ - if (last == NULL || g_arch_instruction_get_flags(iter) & AIF_ROUTINE_START) + + if (last == NULL || g_arch_instruction_get_flags(instr) & AIF_ROUTINE_START) { if (last != NULL) - g_arch_processor_finish_last_coverage(proc, last, proc->instr_count - 1); + g_arch_processor_finish_last_coverage(proc, last, i - 1); - g_arch_processor_add_new_coverage(proc, iter, proc->instr_count); + g_arch_processor_add_new_coverage(proc, instr, i); } - /* Enregistrement */ - proc->instructions[proc->instr_count++] = iter; - - last = iter; + last = instr; } if (last != NULL) g_arch_processor_finish_last_coverage(proc, last, proc->instr_count - 1); + g_arch_processor_unlock(proc); + } @@ -527,7 +524,7 @@ static void g_arch_processor_add_new_coverage(GArchProcessor *proc, GArchInstruc /* Mise à disposition de d'avantage d'espace */ if (proc->cov_allocated == proc->cov_count) { - proc->cov_allocated += INSTR_ALLOC_BLOCK; + proc->cov_allocated += COV_ALLOC_BLOCK; proc->coverages = (instr_coverage *)realloc(proc->coverages, proc->cov_allocated * sizeof(instr_coverage)); |