diff options
author | Cyrille Bagard <nocbos@gmail.com> | 2016-05-24 21:45:53 (GMT) |
---|---|---|
committer | Cyrille Bagard <nocbos@gmail.com> | 2016-05-24 21:46:04 (GMT) |
commit | 0e2849345be5018152d60b5aa27eebb2de75e1df (patch) | |
tree | 524c6f7e5a5a32fa65427c44d8baa2e6204eb732 /src/arch/context.c | |
parent | 3a77653d347c8e60a1c80bd4d57a4fd5e317490f (diff) |
Attached priority levels with disassembly starting points.
Diffstat (limited to 'src/arch/context.c')
-rw-r--r-- | src/arch/context.c | 62 |
1 files changed, 39 insertions, 23 deletions
diff --git a/src/arch/context.c b/src/arch/context.c index 98eebb2..979a403 100644 --- a/src/arch/context.c +++ b/src/arch/context.c @@ -40,7 +40,7 @@ static void g_proc_context_class_init(GProcContextClass *); static void g_proc_context_init(GProcContext *); /* Ajoute une adresse virtuelle comme point de départ de code. */ -static void _g_proc_context_push_drop_point(GProcContext *, unsigned int, virt_t, va_list); +static void _g_proc_context_push_drop_point(GProcContext *, DisassPriorityLevel, virt_t, va_list); @@ -90,9 +90,15 @@ static void g_proc_context_class_init(GProcContextClass *klass) static void g_proc_context_init(GProcContext *ctx) { - ctx->drop_points = NULL; - ctx->dp_allocated = 0; - ctx->dp_count = 0; + DisassPriorityLevel i; /* Boucle de parcours */ + + for (i = 0; i < DPL_COUNT; i++) + { + ctx->drop_points[i] = NULL; + ctx->dp_allocated[i] = 0; + ctx->dp_count[i] = 0; + } + g_mutex_init(&ctx->dp_access); ctx->extra_symbols = NULL; @@ -137,17 +143,22 @@ void g_proc_context_attach_counter(GProcContext *ctx, gint *counter) * * ******************************************************************************/ -static void _g_proc_context_push_drop_point(GProcContext *ctx, unsigned int level, virt_t addr, va_list ap) +static void _g_proc_context_push_drop_point(GProcContext *ctx, DisassPriorityLevel level, virt_t addr, va_list ap) { - if (ctx->dp_count >= ctx->dp_allocated) + assert(level < DPL_COUNT); + + if (ctx->dp_count[level] >= ctx->dp_allocated[level]) { - ctx->dp_allocated += DP_ALLOC_BLOCK; + ctx->dp_allocated[level] += DP_ALLOC_BLOCK; - ctx->drop_points = (virt_t *)realloc(ctx->drop_points, ctx->dp_allocated * sizeof(virt_t)); + ctx->drop_points[level] = (virt_t *)realloc(ctx->drop_points[level], + ctx->dp_allocated[level] * sizeof(virt_t)); } - ctx->drop_points[ctx->dp_count++] = addr; + ctx->drop_points[level][ctx->dp_count[level]] = addr; + + ctx->dp_count[level]++; } @@ -167,7 +178,7 @@ static void _g_proc_context_push_drop_point(GProcContext *ctx, unsigned int leve * * ******************************************************************************/ -void g_proc_context_push_drop_point(GProcContext *ctx, unsigned int level, virt_t addr, ...) +void g_proc_context_push_drop_point(GProcContext *ctx, DisassPriorityLevel level, virt_t addr, ...) { va_list ap; /* Arguments complémentaires ? */ @@ -191,8 +202,9 @@ void g_proc_context_push_drop_point(GProcContext *ctx, unsigned int level, virt_ /****************************************************************************** * * -* Paramètres : ctx = contexte de désassemblage à compléter. * -* virt = adresse d'un point de départ de code à traiter. * +* Paramètres : ctx = contexte de désassemblage à compléter. * +* level = degré d'importance de l'adresse retournée. [OUT] * +* virt = adresse d'un point de départ de code à traiter. [OUT]* * * * Description : Fournit une adresse virtuelle comme point de départ de code. * * * @@ -202,26 +214,30 @@ void g_proc_context_push_drop_point(GProcContext *ctx, unsigned int level, virt_ * * ******************************************************************************/ -bool g_proc_context_pop_drop_point(GProcContext *ctx, virt_t *virt) +bool g_proc_context_pop_drop_point(GProcContext *ctx, DisassPriorityLevel *level, virt_t *virt) { bool result; /* Bilan d'accès à retourner */ + DisassPriorityLevel i; /* Boucle de parcours */ + + result = false; g_mutex_lock(&ctx->dp_access); - if (ctx->dp_count > 0) - { - result = true; + for (i = 0; i < DPL_COUNT && !result; i++) + if (ctx->dp_count[i] > 0) + { + result = true; - *virt = ctx->drop_points[0]; + *level = i; + *virt = ctx->drop_points[i][0]; - if (ctx->dp_count > 1) - memmove(&ctx->drop_points[0], &ctx->drop_points[1], (ctx->dp_count - 1) * sizeof(virt_t)); + if (ctx->dp_count[i] > 1) + memmove(&ctx->drop_points[i][0], &ctx->drop_points[i][1], + (ctx->dp_count[i] - 1) * sizeof(virt_t)); - ctx->dp_count--; + ctx->dp_count[i]--; - } - else - result = false; + } g_mutex_unlock(&ctx->dp_access); |