summaryrefslogtreecommitdiff
path: root/src/arch
diff options
context:
space:
mode:
Diffstat (limited to 'src/arch')
-rw-r--r--src/arch/processor.c54
1 files changed, 7 insertions, 47 deletions
diff --git a/src/arch/processor.c b/src/arch/processor.c
index 25a38b4..2c86ffe 100644
--- a/src/arch/processor.c
+++ b/src/arch/processor.c
@@ -381,62 +381,22 @@ GArchInstruction *g_arch_processor_get_disassembled_instructions(const GArchProc
GArchInstruction *g_arch_processor_find_instr_by_address(const GArchProcessor *proc, const vmpa2t *addr)
{
GArchInstruction *result; /* Trouvaille à retourner */
- GArchInstruction *fake; /* Coquille vide à comparer */
void *ptr; /* Résultat des recherches */
- size_t i; /* Boucle de parcours */
- const mrange_t *range; /* Emplacement d'instruction */
- if (has_phys_addr(addr))
+ int search_for_instr_by_addr(const vmpa2t *a, const GArchInstruction **b)
{
- fake = g_raw_instruction_new_from_value(addr, MDS_8_BITS_UNSIGNED, 0);
+ const mrange_t *range_b; /* Emplacement pour l'instr. B */
- int search_for_instr_by_addr(const GArchInstruction **a, const GArchInstruction **b)
- {
- const mrange_t *range_a; /* Emplacement pour l'instr. A */
- const mrange_t *range_b; /* Emplacement pour l'instr. B */
-
- range_a = g_arch_instruction_get_range(*a);
- range_b = g_arch_instruction_get_range(*b);
-
- /*
- printf(" -- cmp -- 0x%08x vs 0x%08x => %d\n",
- (unsigned int)range_a->addr.virtual,
- (unsigned int)range_b->addr.virtual,
- cmp_vmpa(get_mrange_addr(range_a), get_mrange_addr(range_b)));
- */
+ range_b = g_arch_instruction_get_range(*b);
- return cmp_vmpa(get_mrange_addr(range_a), get_mrange_addr(range_b));
-
- }
-
- ptr = bsearch(&fake, proc->instructions, proc->instr_count,
- sizeof(GArchInstruction *), (__compar_fn_t)search_for_instr_by_addr);
-
- g_object_unref(G_OBJECT(fake));
-
- result = (ptr != NULL ? *((GArchInstruction **)ptr) : NULL);
+ return cmp_vmpa(a, get_mrange_addr(range_b));
}
- else
- {
- result = NULL;
-
- for (i = 0; i < proc->instr_count && result == NULL; i++)
- {
- range = g_arch_instruction_get_range(proc->instructions[i]);
-
- if (cmp_vmpa(addr, get_mrange_addr(range)) == 0)
- result = proc->instructions[i];
+ ptr = bsearch(addr, proc->instructions, proc->instr_count,
+ sizeof(GArchInstruction *), (__compar_fn_t)search_for_instr_by_addr);
- }
-
- /*
- for (i = 0; i < proc->instr_count; i++)
- printf(" # %04zu 0x%08x\n", i, proc->instructions[i]->range.addr.virtual);
- */
-
- }
+ result = (ptr != NULL ? *((GArchInstruction **)ptr) : NULL);
return result;