diff options
| author | serpilliere <fabrice.desclaux@cea.fr> | 2015-03-21 01:00:38 +0100 |
|---|---|---|
| committer | Fabrice Desclaux <fabrice.desclaux@cea.fr> | 2015-03-23 14:06:51 +0100 |
| commit | af01125f2caccfc8838c3fe5f8b3066f4ddc212f (patch) | |
| tree | 8ab972cd6506759039b898648d2b1f3893f956c1 | |
| parent | 12a9bed690f7f9fa5e30af13968e2ce52e965448 (diff) | |
| download | miasm-af01125f2caccfc8838c3fe5f8b3066f4ddc212f.tar.gz miasm-af01125f2caccfc8838c3fe5f8b3066f4ddc212f.zip | |
Example: add NoCallNoMem in ida/depgraph
| -rw-r--r-- | example/ida/depgraph.py | 21 | ||||
| -rw-r--r-- | test/analysis/depgraph.py | 12 |
2 files changed, 13 insertions, 20 deletions
diff --git a/example/ida/depgraph.py b/example/ida/depgraph.py index edf4ce0b..ae00c357 100644 --- a/example/ida/depgraph.py +++ b/example/ida/depgraph.py @@ -9,7 +9,7 @@ from miasm2.expression import expression as m2_expr from miasm2.expression.simplifications import expr_simp from miasm2.analysis.machine import Machine -from miasm2.analysis.depgraph import DependencyGraph, DependencyGraph_NoMemory +from miasm2.analysis.depgraph import DependencyGraph from utils import guess_machine @@ -49,8 +49,8 @@ Track the element: <Line number:{iLineNb}> Method to use: -<Best effort:{rBest}> -<No memory (sound & complete):{rNoMem}>{cMethod}> +<Follow Memory:{rNoMem}> +<Follow Call:{rNoCall}>{cMethod}> <Highlight color:{cColor}> """, { @@ -60,7 +60,7 @@ Method to use: selval=reg_default), 'cMode': Form.RadGroupControl(("rBeforeLine", "rAfterLine", "rEndBlock")), - 'cMethod': Form.RadGroupControl(("rBest", "rNoMem")), + 'cMethod': Form.ChkGroupControl(("rNoMem", "rNoCall")), 'iLineNb': Form.NumericInput(tp=Form.FT_RAWHEX, value=line_nb), 'cbBBL': Form.DropdownListControl( @@ -97,14 +97,11 @@ Method to use: return set([ir_arch.arch.regs.all_regs_ids_byname[value]]) @property - def method(self): + def depgraph(self): value = self.cMethod.value - if value == 0: - return DependencyGraph - elif value == 1: - return DependencyGraph_NoMemory - else: - raise ValueError("Unknown method") + return DependencyGraph(self.ira, + follow_mem=value & 1, + follow_call=value & 2) @property def color(self): @@ -148,7 +145,7 @@ settings = depGraphSettingsForm(ir_arch) settings.Execute() # Get dependency graphs -dg = (settings.method)(ir_arch) +dg = settings.depgraph graphs = dg.get(settings.label, settings.elements, settings.line_nb, set([ir_arch.symbol_pool.getby_offset(func.startEA)])) diff --git a/test/analysis/depgraph.py b/test/analysis/depgraph.py index 5484ec02..a661d785 100644 --- a/test/analysis/depgraph.py +++ b/test/analysis/depgraph.py @@ -3,7 +3,7 @@ from miasm2.core.asmbloc import asm_label from miasm2.ir.analysis import ira from miasm2.ir.ir import ir, irbloc from miasm2.core.graph import DiGraph -from miasm2.analysis.depgraph import DependencyNode, DependencyGraph, DependencyDict, DependencyGraph_NoMemory +from miasm2.analysis.depgraph import DependencyNode, DependencyGraph, DependencyDict from pdb import pm a = ExprId("a") @@ -58,9 +58,6 @@ class IRATest(ir, ira): ir.__init__(self, arch, 32, symbol_pool) self.IRDst = pc - def gen_graph(self): - return - class GraphTest(DiGraph): def __init__(self, ira): self.ira = ira @@ -73,9 +70,6 @@ class GraphTest(DiGraph): return False return True - def gen_graph(self): - return - def node2str(self, node): if not node in self.ira.blocs: return str(node) @@ -603,7 +597,9 @@ for i, test in enumerate([(g1_ira, g1_input, [g1_output1]), open("graph_%02d.dot" % (i+1), "w").write(g_ira.g.dot()) # Test classes for g_dep in [DependencyGraph(g_ira), - DependencyGraph_NoMemory(g_ira)]: + DependencyGraph(g_ira, apply_simp=False), + DependencyGraph(g_ira, follow_mem=False), + DependencyGraph(g_ira, follow_mem=False, follow_call=False)]: print " - Class %s" % g_dep.__class__.__name__ ## Test public APIs |