summaryrefslogtreecommitdiff
path: root/src/analysis/blocks
diff options
context:
space:
mode:
authorCyrille Bagard <nocbos@gmail.com>2013-01-01 23:29:57 (GMT)
committerCyrille Bagard <nocbos@gmail.com>2013-01-01 23:29:57 (GMT)
commitbfd81d1f289913f4d6e09cd8d99f4aaeed98436b (patch)
treeefc747ec80f83fc248da1e8e4ac06c4e7d3347dd /src/analysis/blocks
parentbb6d0c758f8c720d8074bf74e6bd001e36d6a918 (diff)
Fixed the computing of basic blocks and used them in graphic views.
git-svn-id: svn://svn.gna.org/svn/chrysalide/trunk@316 abbe820e-26c8-41b2-8c08-b7b2b41f8b0a
Diffstat (limited to 'src/analysis/blocks')
-rw-r--r--src/analysis/blocks/flow.c57
-rw-r--r--src/analysis/blocks/flow.h3
-rw-r--r--src/analysis/blocks/virtual.c34
3 files changed, 87 insertions, 7 deletions
diff --git a/src/analysis/blocks/flow.c b/src/analysis/blocks/flow.c
index 2bdd0cf..f80b7c8 100644
--- a/src/analysis/blocks/flow.c
+++ b/src/analysis/blocks/flow.c
@@ -71,6 +71,9 @@ static void g_flow_block_memorize_access(GFlowBlock *, GArchRegister *, RegAcces
/* Note les différents accès aux registres. */
static void g_flow_block_compute_regs_access(GFlowBlock *);
+/* Etablit la liste de tous les blocs présents. */
+static void g_flow_block_list_all_blocks(const GFlowBlock *, GInstrBlock ***, size_t *);
+
/* Fournit les différents accès aux registres. */
static const reg_access *g_flow_block_list_regs_accesses(const GFlowBlock *, size_t *);
@@ -122,6 +125,7 @@ static void g_flow_block_init(GFlowBlock *block)
parent = G_INSTR_BLOCK(block);
+ parent->list_blocks = (list_all_blocks_fc)g_flow_block_list_all_blocks;
parent->list_regs = (list_regs_accesses_fc)g_flow_block_list_regs_accesses;
}
@@ -201,13 +205,13 @@ GInstrBlock *g_flow_block_new(GArchInstruction *instrs, GArchInstruction *first,
result = g_object_new(G_TYPE_FLOW_BLOCK, NULL);
-
+ /*
g_arch_instruction_get_location(first, NULL, NULL, &addr);
- //printf(" ! new block @ 0x%llx - ", addr);
+ printf(" ! new block @ 0x%llx - ", addr);
g_arch_instruction_get_location(last, NULL, NULL, &addr);
- //printf("0x%llx\n", addr);
-
+ printf("0x%llx\n", addr);
+ */
@@ -228,6 +232,29 @@ GInstrBlock *g_flow_block_new(GArchInstruction *instrs, GArchInstruction *first,
/******************************************************************************
* *
+* Paramètres : block = bloc d'instructions à consulter. *
+* list = ensemble de blocs à compléter. [OUT] *
+* count = nombre de blocs au total. [OUT] *
+* *
+* Description : Etablit la liste de tous les blocs présents. *
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static void g_flow_block_list_all_blocks(const GFlowBlock *block, GInstrBlock ***list, size_t *count)
+{
+ (*list) = (GInstrBlock **)realloc(*list, ++(*count) * sizeof(GInstrBlock *));
+
+ (*list)[*count - 1] = G_INSTR_BLOCK(block);
+
+}
+
+
+/******************************************************************************
+* *
* Paramètres : block = bloc d'instructions à mettre à jour. *
* reg = registre visé par l'opération. *
* type = type d'accès à l'opérande. *
@@ -362,3 +389,25 @@ static const reg_access *g_flow_block_list_regs_accesses(const GFlowBlock *block
return block->accesses;
}
+
+
+/******************************************************************************
+* *
+* Paramètres : block = bloc d'instructions à consulter. *
+* start = adresse de départ du bloc. [OUT] *
+* end = dernière adresse du bloc. [OUT] *
+* *
+* Description : Fournit les adresses limites d'un bloc d'exécution. *
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+void g_flow_block_get_boundary_addresses(const GFlowBlock *block, vmpa_t *start, vmpa_t *end)
+{
+ g_arch_instruction_get_location(block->first, NULL, NULL, start);
+ g_arch_instruction_get_location(block->last, NULL, NULL, end);
+
+}
diff --git a/src/analysis/blocks/flow.h b/src/analysis/blocks/flow.h
index cc2eb66..14f49ec 100644
--- a/src/analysis/blocks/flow.h
+++ b/src/analysis/blocks/flow.h
@@ -55,6 +55,9 @@ GType g_flow_block_get_type(void);
/* Crée un bloc d'exécution d'instructions. */
GInstrBlock *g_flow_block_new(GArchInstruction *, GArchInstruction *, GArchInstruction *);
+/* Fournit les adresses limites d'un bloc d'exécution. */
+void g_flow_block_get_boundary_addresses(const GFlowBlock *, vmpa_t *, vmpa_t *);
+
#endif /* _ANALYSIS_BLOCKS_FLOW_H */
diff --git a/src/analysis/blocks/virtual.c b/src/analysis/blocks/virtual.c
index 113e333..c981ece 100644
--- a/src/analysis/blocks/virtual.c
+++ b/src/analysis/blocks/virtual.c
@@ -40,13 +40,13 @@ struct _GVirtualBlock
GArchInstruction *first; /* Première instruction */
GArchInstruction *last; /* Dernière instruction */
+ GInstrBlock **children; /* Sous-blocs intégrés */
+ size_t children_count; /* Nombre de ces sous-blocs */
+
reg_access *accesses; /* Commodités d'accès #1 */
size_t count; /* Commodités d'accès #2 */
- GInstrBlock **children; /* Sous-blocs intégrés */
- size_t children_count; /* Nombre de ces sous-blocs */
-
};
/* Description d'un bloc d'exécution d'instructions (classe) */
@@ -69,6 +69,9 @@ static void g_virtual_block_dispose(GVirtualBlock *);
/* Procède à la libération totale de la mémoire. */
static void g_virtual_block_finalize(GVirtualBlock *);
+/* Etablit la liste de tous les blocs présents. */
+static void g_virtual_block_list_all_blocks(const GVirtualBlock *, GInstrBlock ***, size_t *);
+
/* Fournit les différents accès aux registres. */
static const reg_access *g_virtual_block_list_regs_accesses(const GVirtualBlock *, size_t *);
@@ -120,6 +123,7 @@ static void g_virtual_block_init(GVirtualBlock *block)
parent = G_INSTR_BLOCK(block);
+ parent->list_blocks = (list_all_blocks_fc)g_virtual_block_list_all_blocks;
parent->list_regs = (list_regs_accesses_fc)g_virtual_block_list_regs_accesses;
}
@@ -200,6 +204,30 @@ GInstrBlock *g_virtual_block_new(void)
/******************************************************************************
* *
* Paramètres : block = bloc d'instructions à consulter. *
+* list = ensemble de blocs à compléter. [OUT] *
+* count = nombre de blocs au total. [OUT] *
+* *
+* Description : Etablit la liste de tous les blocs présents. *
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static void g_virtual_block_list_all_blocks(const GVirtualBlock *block, GInstrBlock ***list, size_t *count)
+{
+ size_t i; /* Boucle de parcours */
+
+ for (i = 0; i < block->children_count; i++)
+ g_instr_block_list_all_blocks(block->children[i], list, count);
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : block = bloc d'instructions à consulter. *
* count = nombre de registres consignés. [OUT] *
* *
* Description : Fournit les différents accès aux registres. *