about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorFabrice Desclaux <fabrice.desclaux@cea.fr>2016-03-23 16:29:53 +0100
committerFabrice Desclaux <fabrice.desclaux@cea.fr>2016-03-23 16:38:34 +0100
commit8c436da764b0616976c74c43fefd5494d3889ebb (patch)
tree0c77d019f6ed232bb4815791047ad98f2039edb6
parent359357f4c5609cded790c5890c0c0dd7a2cf73d6 (diff)
downloadmiasm-8c436da764b0616976c74c43fefd5494d3889ebb.tar.gz
miasm-8c436da764b0616976c74c43fefd5494d3889ebb.zip
Depgraph: use has_loop algorithm to spot data flow loops; fix reg test
-rw-r--r--miasm2/analysis/depgraph.py6
-rw-r--r--test/analysis/dg_test_06_expected.json2
-rw-r--r--test/analysis/dg_test_06_implicit_expected.json2
3 files changed, 5 insertions, 5 deletions
diff --git a/miasm2/analysis/depgraph.py b/miasm2/analysis/depgraph.py
index aec159aa..b574e421 100644
--- a/miasm2/analysis/depgraph.py
+++ b/miasm2/analysis/depgraph.py
@@ -252,10 +252,10 @@ class DependencyResult(DependencyState):
 
     @property
     def has_loop(self):
-        """True if current dictionary has a loop"""
+        """True iff there is at least one data dependencies cycle (regarding
+        the associated depgraph)"""
         if self._has_loop is None:
-            self._has_loop = (len(self.relevant_labels) !=
-                              len(set(self.relevant_labels)))
+            self._has_loop = self.graph.has_loop()
         return self._has_loop
 
     def irblock_slice(self, irb):
diff --git a/test/analysis/dg_test_06_expected.json b/test/analysis/dg_test_06_expected.json
index 7d823131..c181cd2d 100644
--- a/test/analysis/dg_test_06_expected.json
+++ b/test/analysis/dg_test_06_expected.json
@@ -1 +1 @@
-[{"EAX": "0x1", "has_loop": false}, {"EAX": "0x2", "has_loop": true}]
+[{"EAX": "0x1", "has_loop": false}, {"EAX": "0x2", "has_loop": false}]
diff --git a/test/analysis/dg_test_06_implicit_expected.json b/test/analysis/dg_test_06_implicit_expected.json
index 050915c1..bda75296 100644
--- a/test/analysis/dg_test_06_implicit_expected.json
+++ b/test/analysis/dg_test_06_implicit_expected.json
@@ -1 +1 @@
-[{"has_loop": false, "EAX": "0x1", "satisfiability": true, "constraints": {"EAX_init": "0xffffffff"}}, {"has_loop": true, "EAX": "0x2", "satisfiability": false, "constraints": {}}]
+[{"has_loop": false, "EAX": "0x1", "satisfiability": true, "constraints": {"EAX_init": "0xffffffff"}}, {"has_loop": false, "EAX": "0x2", "satisfiability": false, "constraints": {}}]