summaryrefslogtreecommitdiff
path: root/src/analysis
diff options
context:
space:
mode:
Diffstat (limited to 'src/analysis')
-rw-r--r--src/analysis/blocks/flow.c6
-rw-r--r--src/analysis/disass/dragon.c10
-rw-r--r--src/analysis/disass/links.c13
-rw-r--r--src/analysis/disass/loop.c4
-rw-r--r--src/analysis/disass/macro.c2
-rw-r--r--src/analysis/disass/rank.c4
6 files changed, 36 insertions, 3 deletions
diff --git a/src/analysis/blocks/flow.c b/src/analysis/blocks/flow.c
index 9eb9de8..bc14648 100644
--- a/src/analysis/blocks/flow.c
+++ b/src/analysis/blocks/flow.c
@@ -574,6 +574,7 @@ bool g_flow_block_is_looping_to(GFlowBlock *block, const GInstrBlock *list, GFlo
result = (block == target);
+ g_arch_instruction_rlock_dest(block->last);
dcount = g_arch_instruction_get_destinations(block->last, &dests, &types, NULL);
for (i = 0; i < dcount && !result; i++)
@@ -598,6 +599,8 @@ bool g_flow_block_is_looping_to(GFlowBlock *block, const GInstrBlock *list, GFlo
}
+ g_arch_instruction_runlock_dest(block->last);
+
return result;
}
@@ -634,6 +637,7 @@ bool g_flow_block_follow(GFlowBlock *block, const GInstrBlock *list, BlockFollow
if (mask & BFP_ENTER)
result = callback(block, BFP_ENTER, data);
+ g_arch_instruction_rlock_dest(block->last);
dcount = g_arch_instruction_get_destinations(block->last, &dests, &types, NULL);
for (i = 0; i < dcount && result; i++)
@@ -661,6 +665,8 @@ bool g_flow_block_follow(GFlowBlock *block, const GInstrBlock *list, BlockFollow
}
+ g_arch_instruction_runlock_dest(block->last);
+
if (mask & BFP_EXIT)
result &= callback(block, BFP_EXIT, data);
diff --git a/src/analysis/disass/dragon.c b/src/analysis/disass/dragon.c
index fbdecd8..75b8bb7 100644
--- a/src/analysis/disass/dragon.c
+++ b/src/analysis/disass/dragon.c
@@ -146,8 +146,8 @@ static dragon_node *create_dragon_nodes(const GArchProcessor *proc, const instr_
else
{
+ g_arch_instruction_rlock_src(iter);
scount = g_arch_instruction_get_sources(iter, NULL, &types);
- if (scount == 0) continue;
for (i = 0; i < scount; i++)
switch (types[i])
@@ -190,6 +190,8 @@ static dragon_node *create_dragon_nodes(const GArchProcessor *proc, const instr_
}
+ g_arch_instruction_runlock_src(iter);
+
}
@@ -408,6 +410,7 @@ void compute_all_paths(dragon_node *nodes, size_t count)
dragon_node *next; /* Noeud suivant dans le code */
size_t id; /* Indice du bit associé */
+ g_arch_instruction_rlock_dest(node->last);
dcount = g_arch_instruction_get_destinations(node->last, &dests, &types, NULL);
for (i = 0; i < dcount; i++)
@@ -435,6 +438,8 @@ void compute_all_paths(dragon_node *nodes, size_t count)
}
+ g_arch_instruction_runlock_dest(node->last);
+
}
follow_flow_in_nodes(&nodes[0]);
@@ -498,6 +503,7 @@ void compute_all_dominators(dragon_node *nodes, size_t count)
set_all_in_bit_field(inter);
+ g_arch_instruction_rlock_src(node->first);
scount = g_arch_instruction_get_sources(node->first, &srcs, &types);
//assert(scount > 0); // un 'ret' coupe, le suivant n'a pas de source
@@ -530,6 +536,8 @@ void compute_all_dominators(dragon_node *nodes, size_t count)
}
+ g_arch_instruction_runlock_src(node->first);
+
set_in_bit_field(inter, k, 1);
if (!is_bit_field_equal_to(node->bits, inter))
diff --git a/src/analysis/disass/links.c b/src/analysis/disass/links.c
index 86663cc..f52029b 100644
--- a/src/analysis/disass/links.c
+++ b/src/analysis/disass/links.c
@@ -51,6 +51,7 @@ static void convert_immediate_into_target(GArchInstruction *, size_t, const GBin
void establish_natural_link(GArchInstruction *instr, GArchInstruction *prev)
{
+ bool has_src; /* Présence de sources ? */
GArchInstruction **others; /* Instructions diverses liées */
InstructionLinkType *types; /* Types de lien existants */
size_t count; /* Nbre de sources affichées */
@@ -61,7 +62,11 @@ void establish_natural_link(GArchInstruction *instr, GArchInstruction *prev)
* on ne peut pas créer de lien plus naturel que l'existant.
*/
- if (!g_arch_instruction_has_sources(instr))
+ g_arch_instruction_rlock_src(instr);
+ has_src = g_arch_instruction_has_sources(instr);
+ g_arch_instruction_runlock_src(instr);
+
+ if (!has_src)
return;
/**
@@ -79,6 +84,7 @@ void establish_natural_link(GArchInstruction *instr, GArchInstruction *prev)
* On s'assure que le lien naturel est valide.
*/
+ g_arch_instruction_rlock_dest(prev);
count = g_arch_instruction_get_destinations(prev, &others, &types, NULL);
for (i = 0; i < count; i++)
@@ -89,12 +95,15 @@ void establish_natural_link(GArchInstruction *instr, GArchInstruction *prev)
if (types[i] == ILT_LOOP) break;
}
+ g_arch_instruction_runlock_dest(prev);
+
if (count > 0 && i < count) return;
/**
* On vérifie que le lien n'existe pas déjà avant d'en créer un...
*/
+ g_arch_instruction_rlock_src(instr);
count = g_arch_instruction_get_sources(instr, &others, &types);
for (i = 0; i < count; i++)
@@ -103,6 +112,8 @@ void establish_natural_link(GArchInstruction *instr, GArchInstruction *prev)
if (others[i] == prev && types[i] == ILT_JUMP_IF_FALSE) break;
}
+ g_arch_instruction_runlock_src(instr);
+
if (i == count)
g_arch_instruction_link_with(prev, instr, ILT_EXEC_FLOW);
diff --git a/src/analysis/disass/loop.c b/src/analysis/disass/loop.c
index e7dbbd7..89a4bc9 100644
--- a/src/analysis/disass/loop.c
+++ b/src/analysis/disass/loop.c
@@ -64,8 +64,8 @@ static void detect_back_edges(dragon_node *nodes, size_t count)
get_dragon_node_bounding_instructions(node, NULL, &last);
+ g_arch_instruction_wlock_dest(last);
dcount = g_arch_instruction_get_destinations(last, &dests, &types, NULL);
- if (dcount == 0) continue;
for (i = 0; i < dcount; i++)
switch (types[i])
@@ -102,6 +102,8 @@ static void detect_back_edges(dragon_node *nodes, size_t count)
}
+ g_arch_instruction_wunlock_dest(last);
+
}
}
diff --git a/src/analysis/disass/macro.c b/src/analysis/disass/macro.c
index d9d20ee..6ac1fb2 100644
--- a/src/analysis/disass/macro.c
+++ b/src/analysis/disass/macro.c
@@ -227,6 +227,7 @@ static GInstrBlock *build_instruction_blocks(GArchProcessor *proc, const dragon_
others = NULL;
+ g_arch_instruction_rlock_dest(last);
dcount = g_arch_instruction_get_destinations(last, &dests, &types, NULL);
for (i = 0; i < dcount && others == NULL; i++)
@@ -283,6 +284,7 @@ static GInstrBlock *build_instruction_blocks(GArchProcessor *proc, const dragon_
}
+ g_arch_instruction_runlock_dest(last);
if (others != NULL)
{
diff --git a/src/analysis/disass/rank.c b/src/analysis/disass/rank.c
index 9b9f29e..85d9e66 100644
--- a/src/analysis/disass/rank.c
+++ b/src/analysis/disass/rank.c
@@ -73,6 +73,8 @@ static bool rank_flow_block(GFlowBlock *block, BlockVisitOrder order, const GIns
links = g_instr_block_get_links_block(G_INSTR_BLOCK(block));
g_flow_block_get_boundary(block, NULL, &last);
+
+ g_arch_instruction_rlock_dest(last);
dcount = g_arch_instruction_get_destinations(last, &dests, &types, NULL);
for (i = 0; i < dcount; i++)
@@ -170,6 +172,8 @@ static bool rank_flow_block(GFlowBlock *block, BlockVisitOrder order, const GIns
}
+ g_arch_instruction_runlock_dest(last);
+
return true;
}