diff options
Diffstat (limited to 'src/arch')
-rw-r--r-- | src/arch/processor-int.h | 3 | ||||
-rw-r--r-- | src/arch/processor.c | 45 | ||||
-rw-r--r-- | src/arch/processor.h | 2 |
3 files changed, 23 insertions, 27 deletions
diff --git a/src/arch/processor-int.h b/src/arch/processor-int.h index b170cad..4eaa690 100644 --- a/src/arch/processor-int.h +++ b/src/arch/processor-int.h @@ -44,7 +44,7 @@ /* Taille des pré-allocations pour les instructions */ -#define INSTR_ALLOC_BLOCK 100 +#define COV_ALLOC_BLOCK 100 @@ -85,7 +85,6 @@ struct _GArchProcessor //get_decomp_context_fc get_dec_ctx; /* Obtention d'un contexte #2 */ GArchInstruction **instructions; /* Instructions désassemblées */ - size_t instr_allocated; /* Taille de la liste allouée */ size_t instr_count; /* Taille de la liste aplatie */ unsigned int stamp; /* Marque de suivi des modifs */ GMutex mutex; /* Verrou pour l'accès */ 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)); diff --git a/src/arch/processor.h b/src/arch/processor.h index 05ea77a..76691ec 100644 --- a/src/arch/processor.h +++ b/src/arch/processor.h @@ -91,7 +91,7 @@ unsigned int g_arch_processor_get_stamp(const GArchProcessor *); size_t g_arch_processor_count_instructions(const GArchProcessor *); /* Note les instructions désassemblées avec une architecture. */ -void g_arch_processor_set_disassembled_instructions(GArchProcessor *, GArchInstruction *); +void g_arch_processor_set_instructions(GArchProcessor *, GArchInstruction **, size_t); /* Fournit une instruction désassemblée pour une architecture. */ GArchInstruction *g_arch_processor_get_instruction(const GArchProcessor *, size_t); |