summaryrefslogtreecommitdiff
path: root/src/arch/dalvik
diff options
context:
space:
mode:
authorCyrille Bagard <nocbos@gmail.com>2010-11-12 22:13:21 (GMT)
committerCyrille Bagard <nocbos@gmail.com>2010-11-12 22:13:21 (GMT)
commitae8cf6257c8d929de1b7ee86e29fcb45ab4af91c (patch)
tree59fa356b2f83020e23df4cf6975ca5d97567df4d /src/arch/dalvik
parentabaf85fdc0edb2bfe67d07d52ae734d50c6fbf61 (diff)
Changed the display of the pseudo registers by using an index.
git-svn-id: svn://svn.gna.org/svn/chrysalide/trunk@192 abbe820e-26c8-41b2-8c08-b7b2b41f8b0a
Diffstat (limited to 'src/arch/dalvik')
-rw-r--r--src/arch/dalvik/dop_aget.c6
-rw-r--r--src/arch/dalvik/dop_aput.c6
-rw-r--r--src/arch/dalvik/dop_arithm.c14
-rw-r--r--src/arch/dalvik/dop_array.c4
-rw-r--r--src/arch/dalvik/dop_const.c4
-rw-r--r--src/arch/dalvik/dop_invoke.c6
-rw-r--r--src/arch/dalvik/operand.c30
-rw-r--r--src/arch/dalvik/register.c29
-rw-r--r--src/arch/dalvik/register.h3
9 files changed, 79 insertions, 23 deletions
diff --git a/src/arch/dalvik/dop_aget.c b/src/arch/dalvik/dop_aget.c
index 77e6ef2..5ea57cc 100644
--- a/src/arch/dalvik/dop_aget.c
+++ b/src/arch/dalvik/dop_aget.c
@@ -52,13 +52,13 @@ GDecInstruction *dalvik_decomp_instr_aget(const GArchInstruction *instr, GDecCon
GDecInstruction *access; /* Représentation de l'accès */
operand = g_arch_instruction_get_operand(instr, 0);
- content = g_pseudo_register_new();
+ content = g_dec_context_convert_register(ctx, operand);
operand = g_arch_instruction_get_operand(instr, 1);
- array = g_pseudo_register_new();
+ array = g_dec_context_convert_register(ctx, operand);
operand = g_arch_instruction_get_operand(instr, 2);
- index = g_pseudo_register_new();
+ index = g_dec_context_convert_register(ctx, operand);
access = g_array_access_new(G_DEC_EXPRESSION(array), G_DEC_EXPRESSION(index));
result = g_assign_expression_new(G_DEC_EXPRESSION(content), G_DEC_EXPRESSION(access));
diff --git a/src/arch/dalvik/dop_aput.c b/src/arch/dalvik/dop_aput.c
index 2e4527e..3b75667 100644
--- a/src/arch/dalvik/dop_aput.c
+++ b/src/arch/dalvik/dop_aput.c
@@ -52,13 +52,13 @@ GDecInstruction *dalvik_decomp_instr_aput(const GArchInstruction *instr, GDecCon
GDecInstruction *access; /* Représentation de l'accès */
operand = g_arch_instruction_get_operand(instr, 0);
- content = g_pseudo_register_new();
+ content = g_dec_context_convert_register(ctx, operand);
operand = g_arch_instruction_get_operand(instr, 1);
- array = g_pseudo_register_new();
+ array = g_dec_context_convert_register(ctx, operand);
operand = g_arch_instruction_get_operand(instr, 2);
- index = g_pseudo_register_new();
+ index = g_dec_context_convert_register(ctx, operand);
access = g_array_access_new(G_DEC_EXPRESSION(array), G_DEC_EXPRESSION(index));
result = g_assign_expression_new(G_DEC_EXPRESSION(access), G_DEC_EXPRESSION(content));
diff --git a/src/arch/dalvik/dop_arithm.c b/src/arch/dalvik/dop_arithm.c
index 388f906..7657f99 100644
--- a/src/arch/dalvik/dop_arithm.c
+++ b/src/arch/dalvik/dop_arithm.c
@@ -51,7 +51,6 @@ GDecInstruction *dalvik_decomp_instr_arithm_2addr(const GArchInstruction *instr,
GArchOperand *operand; /* Opérande de l'instruction */
GDecInstruction *dest; /* Enregistrement du résultat */
GDecInstruction *op1; /* Premier opérande utilisé */
- GDecInstruction *op2; /* Second opérande utilisé */
GDecInstruction *arithm; /* Opération arithmétique */
switch (g_dalvik_instruction_get_opcode(G_DALVIK_INSTRUCTION(instr)))
@@ -84,15 +83,12 @@ GDecInstruction *dalvik_decomp_instr_arithm_2addr(const GArchInstruction *instr,
}
operand = g_arch_instruction_get_operand(instr, 0);
- dest = g_pseudo_register_new();
+ dest = g_dec_context_convert_register(ctx, operand);
operand = g_arch_instruction_get_operand(instr, 1);
- op1 = g_pseudo_register_new();
-
- operand = g_arch_instruction_get_operand(instr, 2);
- op2 = g_pseudo_register_new();
+ op1 = g_dec_context_convert_register(ctx, operand);
- arithm = g_arithm_expression_new(G_DEC_EXPRESSION(op1), type, G_DEC_EXPRESSION(op2));
+ arithm = g_arithm_expression_new(G_DEC_EXPRESSION(dest), type, G_DEC_EXPRESSION(op1));
result = g_assign_expression_new(G_DEC_EXPRESSION(dest), G_DEC_EXPRESSION(arithm));
return result;
@@ -159,10 +155,10 @@ GDecInstruction *dalvik_decomp_instr_arithm_lit(const GArchInstruction *instr, G
}
operand = g_arch_instruction_get_operand(instr, 0);
- dest = g_pseudo_register_new();
+ dest = g_dec_context_convert_register(ctx, operand);
operand = g_arch_instruction_get_operand(instr, 1);
- op1 = g_pseudo_register_new();
+ op1 = g_dec_context_convert_register(ctx, operand);
operand = g_arch_instruction_get_operand(instr, 2);
op2 = g_imm_expression_new(G_IMM_OPERAND(operand));
diff --git a/src/arch/dalvik/dop_array.c b/src/arch/dalvik/dop_array.c
index 035b3eb..fa9f94f 100644
--- a/src/arch/dalvik/dop_array.c
+++ b/src/arch/dalvik/dop_array.c
@@ -60,11 +60,11 @@ GDecInstruction *dalvik_decomp_instr_array_length(const GArchInstruction *instr,
operand = g_arch_instruction_get_operand(instr, 1);
- reg = g_pseudo_register_new();
+ reg = g_dec_context_convert_register(ctx, operand);
len = g_dalvik_alength_new(G_DEC_EXPRESSION(reg));
operand = g_arch_instruction_get_operand(instr, 0);
- reg = g_pseudo_register_new();
+ reg = g_dec_context_convert_register(ctx, operand);
result = g_assign_expression_new(G_DEC_EXPRESSION(reg), G_DEC_EXPRESSION(len));
diff --git a/src/arch/dalvik/dop_const.c b/src/arch/dalvik/dop_const.c
index eab7acd..ea88089 100644
--- a/src/arch/dalvik/dop_const.c
+++ b/src/arch/dalvik/dop_const.c
@@ -59,8 +59,8 @@ GDecInstruction *dalvik_decomp_instr_const(const GArchInstruction *instr, GDecCo
- operand = g_arch_instruction_get_operand(instr, 1);
- reg = g_pseudo_register_new();
+ operand = g_arch_instruction_get_operand(instr, 0);
+ reg = g_dec_context_convert_register(ctx, operand);
operand = g_arch_instruction_get_operand(instr, 1);
imm = g_imm_expression_new(G_IMM_OPERAND(operand));
diff --git a/src/arch/dalvik/dop_invoke.c b/src/arch/dalvik/dop_invoke.c
index e4fa1fb..6fdca06 100644
--- a/src/arch/dalvik/dop_invoke.c
+++ b/src/arch/dalvik/dop_invoke.c
@@ -117,7 +117,7 @@ GDecInstruction *dalvik_decomp_instr_invoke_virtual(const GArchInstruction *inst
//GDecInstruction *g_routine_call_new(GBinRoutine *routine, bool is_object)
/*
operand = g_arch_instruction_get_operand(instr, 1);
- reg = g_pseudo_register_new();
+ reg = g_dec_context_convert_register(ctx, operand);
operand = g_arch_instruction_get_operand(instr, 1);
imm = g_imm_expression_new(G_IMM_OPERAND(operand));
@@ -141,8 +141,8 @@ GDecInstruction *dalvik_decomp_instr_invoke_virtual(const GArchInstruction *inst
{
case DOP_MOVE_RESULT:
- operand = g_arch_instruction_get_operand(instr, 0);
- reg = g_pseudo_register_new();
+ operand = g_arch_instruction_get_operand(iter, 0);
+ reg = g_dec_context_convert_register(ctx, operand);
result = g_assign_expression_new(G_DEC_EXPRESSION(reg), G_DEC_EXPRESSION(result));
diff --git a/src/arch/dalvik/operand.c b/src/arch/dalvik/operand.c
index 9c4a2c2..3227184 100644
--- a/src/arch/dalvik/operand.c
+++ b/src/arch/dalvik/operand.c
@@ -87,6 +87,9 @@ static void g_dalvik_register_operand_class_init(GDalvikRegisterOperandClass *);
/* Initialise une instance d'opérande de registre Dalvik. */
static void g_dalvik_register_operand_init(GDalvikRegisterOperand *);
+/* Compare un opérande avec un autre. */
+static bool g_dalvik_register_operand_compare(const GDalvikRegisterOperand *, const GDalvikRegisterOperand *);
+
/* Ajoute du texte simple à un fichier ouvert en écriture. */
static void g_dalvik_register_operand_add_text(const GDalvikRegisterOperand *, GRenderingOptions *, MainRendering, FILE *);
@@ -325,13 +328,18 @@ static void g_dalvik_register_operand_class_init(GDalvikRegisterOperandClass *kl
static void g_dalvik_register_operand_init(GDalvikRegisterOperand *operand)
{
- GContentExporter *parent; /* Instance parente */
+ GContentExporter *parent; /* Instance parente #1 */
+ GArchOperand *arch; /* Instance parente #2 */
parent = G_CONTENT_EXPORTER(operand);
parent->add_text = (add_text_fc)g_dalvik_register_operand_add_text;
parent->export_buffer = (export_buffer_fc)g_dalvik_register_operand_to_buffer;
+ arch = G_ARCH_OPERAND(operand);
+
+ arch->compare = (operand_compare_fc)g_dalvik_register_operand_compare;
+
}
@@ -400,6 +408,26 @@ GArchOperand *g_dalvik_register_operand_new(const bin_t *data, off_t *pos, off_t
/******************************************************************************
* *
+* Paramètres : a = premier opérande à consulter. *
+* b = second opérande à consulter. *
+* *
+* Description : Compare un opérande avec un autre. *
+* *
+* Retour : Bilan de la comparaison. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static bool g_dalvik_register_operand_compare(const GDalvikRegisterOperand *a, const GDalvikRegisterOperand *b)
+{
+ return g_dalvik_register_compare(a->reg, b->reg);
+
+}
+
+
+/******************************************************************************
+* *
* Paramètres : operand = opérande à transcrire. *
* options = options de rendu. *
* rendering = support effectif final des lignes de code. *
diff --git a/src/arch/dalvik/register.c b/src/arch/dalvik/register.c
index fc7757d..dd5a512 100644
--- a/src/arch/dalvik/register.c
+++ b/src/arch/dalvik/register.c
@@ -134,6 +134,35 @@ GDalvikRegister *g_dalvik_register_new(uint16_t index)
}
+/******************************************************************************
+* *
+* Paramètres : a = premier opérande à consulter. *
+* b = second opérande à consulter. *
+* *
+* Description : Compare un registre avec un autre. *
+* *
+* Retour : Bilan de la comparaison. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+bool g_dalvik_register_compare(const GDalvikRegister *a, const GDalvikRegister *b)
+{
+ /* FIXME : GCC (Debian 4.4.5-4) trouble ? */
+
+ if (a == NULL)
+ printf("Alerte :: %hd & %hd\n", a->index, b->index);
+
+ /*
+ printf("Compare :: %p & %p\n", a, b);
+ printf("Compare :: %hd & %hd\n", a->index, b->index);
+ */
+
+ return (a->index == b->index);
+
+}
+
/******************************************************************************
* *
diff --git a/src/arch/dalvik/register.h b/src/arch/dalvik/register.h
index 5ac5617..7767a9b 100644
--- a/src/arch/dalvik/register.h
+++ b/src/arch/dalvik/register.h
@@ -54,6 +54,9 @@ GType g_dalvik_register_get_type(void);
/* Crée une réprésentation de registre Dalvik. */
GDalvikRegister *g_dalvik_register_new(uint16_t);
+/* Compare un registre avec un autre. */
+bool g_dalvik_register_compare(const GDalvikRegister *, const GDalvikRegister *);
+
/* Indique si le registre correspond à ebp ou similaire. */
bool g_dalvik_register_is_base_pointer(const GDalvikRegister *);