summaryrefslogtreecommitdiff
path: root/src/analysis/decomp/il.c
diff options
context:
space:
mode:
authorCyrille Bagard <nocbos@gmail.com>2013-01-10 22:47:37 (GMT)
committerCyrille Bagard <nocbos@gmail.com>2013-01-10 22:47:37 (GMT)
commit221bcaeeb06415d501f9abbb9bc4b7d8339af1fe (patch)
tree243a1709589d3733d6525b0a143ecf0c539caae7 /src/analysis/decomp/il.c
parentc455057e634b30c3214a49db009bad5fd0c631ff (diff)
Simplified the decompilation process by using links between basic blocks.
git-svn-id: svn://svn.gna.org/svn/chrysalide/trunk@322 abbe820e-26c8-41b2-8c08-b7b2b41f8b0a
Diffstat (limited to 'src/analysis/decomp/il.c')
-rw-r--r--src/analysis/decomp/il.c30
1 files changed, 12 insertions, 18 deletions
diff --git a/src/analysis/decomp/il.c b/src/analysis/decomp/il.c
index c2bc0be..f3c2265 100644
--- a/src/analysis/decomp/il.c
+++ b/src/analysis/decomp/il.c
@@ -46,7 +46,7 @@
static GDecInstruction *merge_decompiled_instructions(GDecInstruction *, GDecInstruction *);
/* Procède à la décompilation d'un bloc déterminé. */
-static GDecInstruction *decompiled_instructions_block(GFlowBlock *, GVirtualBlock *, GDecContext *);
+static GDecInstruction *decompiled_instructions_block(GFlowBlock *, GDecContext *);
/* Procède à la décompilation d'un ensemble de blocs déterminé. */
static GDecInstruction *decompiled_instructions_blocks(GVirtualBlock *, GDecContext *);
@@ -111,9 +111,8 @@ static GDecInstruction *merge_decompiled_instructions(GDecInstruction *group, GD
/******************************************************************************
* *
-* Paramètres : block = ensemble des instructions d'assemblage à traiter. *
-* parent = groupe de blocs d'appartenance. *
-* ctx = contexte de soutien à associer à l'opération. *
+* Paramètres : block = ensemble des instructions d'assemblage à traiter. *
+* ctx = contexte de soutien à associer à l'opération. *
* *
* Description : Procède à la décompilation d'un bloc déterminé. *
* *
@@ -123,7 +122,7 @@ static GDecInstruction *merge_decompiled_instructions(GDecInstruction *group, GD
* *
******************************************************************************/
-static GDecInstruction *decompiled_instructions_block(GFlowBlock *block, GVirtualBlock *parent, GDecContext *ctx)
+static GDecInstruction *decompiled_instructions_block(GFlowBlock *block, GDecContext *ctx)
{
GDecInstruction *res;
@@ -137,7 +136,8 @@ static GDecInstruction *decompiled_instructions_block(GFlowBlock *block, GVirtua
GDecInstruction *false_dinstr; /* Décompilation 'cond fausse' */
GArchInstruction *next; /* Instruction de branchement */
vmpa_t next_addr; /* Adresse de cette instruct° */
- GInstrBlock *next_block; /* Bloc basique correspondant */
+ GInstrBlock *next_parent; /* Bloc basique correspondant */
+ GInstrBlock *next_block; /* Sous-bloc basique direct */
instrs = g_flow_block_get_all_instructions_list(block);
g_flow_block_get_boundary(block, &first, &last);
@@ -172,13 +172,10 @@ static GDecInstruction *decompiled_instructions_block(GFlowBlock *block, GVirtua
if (next != NULL)
{
g_arch_instruction_get_location(next, NULL, NULL, &next_addr);
- next_block = g_instr_block_find_by_addr(G_INSTR_BLOCK(parent), next_addr);
+ next_block = g_instr_block_find_by_addr(g_instr_block_get_links_block(block), next_addr);
if (next_block != NULL)
- {
- next_block = g_instr_block_find_by_addr(next_block, next_addr);
true_dinstr = decompiled_basic_block(next_block, ctx);
- }
}
@@ -191,21 +188,18 @@ static GDecInstruction *decompiled_instructions_block(GFlowBlock *block, GVirtua
if (next != NULL)
{
g_arch_instruction_get_location(next, NULL, NULL, &next_addr);
- next_block = g_instr_block_find_by_addr(G_INSTR_BLOCK(parent), next_addr);
+ next_block = g_instr_block_find_by_addr(g_instr_block_get_links_block(block), next_addr);
if (next_block != NULL)
- {
- next_block = g_instr_block_find_by_addr(next_block, next_addr);
false_dinstr = decompiled_basic_block(next_block, ctx);
- }
}
printf(" -> ite : %p + %p\n", true_dinstr, false_dinstr);
printf(" -> ite : %s + %s\n",
- g_type_name(G_TYPE_FROM_INSTANCE(true_dinstr)),
- g_type_name(G_TYPE_FROM_INSTANCE(false_dinstr)));
+ true_dinstr ? g_type_name(G_TYPE_FROM_INSTANCE(true_dinstr)) : "none",
+ false_dinstr ? g_type_name(G_TYPE_FROM_INSTANCE(false_dinstr)) : "none");
g_ite_instruction_set_branches(G_ITE_INSTRUCTION(decomp), true_dinstr, false_dinstr);
@@ -259,7 +253,7 @@ static GDecInstruction *decompiled_instructions_blocks(GVirtualBlock *block, GDe
/* FIXME */
g_dec_context_set_decomp_instrs(ctx, NULL);
- dinstrs = decompiled_instructions_block(G_FLOW_BLOCK(sub_block), block, ctx);
+ dinstrs = decompiled_instructions_block(G_FLOW_BLOCK(sub_block), ctx);
result = merge_decompiled_instructions(result, dinstrs);
}
@@ -294,7 +288,7 @@ static GDecInstruction *decompiled_basic_block(GInstrBlock *block, GDecContext *
else
{
- result = decompiled_instructions_block(G_FLOW_BLOCK(block), NULL, ctx);
+ result = decompiled_instructions_block(G_FLOW_BLOCK(block), ctx);
if (!G_IS_EXPR_BLOCK(result))
result = merge_decompiled_instructions(NULL, result);