about summary refs log tree commit diff stats
path: root/example
diff options
context:
space:
mode:
authorFabrice Desclaux <fabrice.desclaux@cea.fr>2016-01-22 13:03:30 +0100
committerFabrice Desclaux <fabrice.desclaux@cea.fr>2016-03-17 15:11:11 +0100
commit096e0a678badd6c508e8f1c2d0e02d4f0efc21a8 (patch)
treefb44280c5ae8017901743b8c5958a41e552f0575 /example
parent7a52dbc03a726741f703d6183a1ed808752ba3a2 (diff)
downloadmiasm-096e0a678badd6c508e8f1c2d0e02d4f0efc21a8.tar.gz
miasm-096e0a678badd6c508e8f1c2d0e02d4f0efc21a8.zip
Test/depgraph: autopep
Diffstat (limited to 'example')
-rw-r--r--example/symbol_exec/depgraph.py57
1 files changed, 29 insertions, 28 deletions
diff --git a/example/symbol_exec/depgraph.py b/example/symbol_exec/depgraph.py
index a870b275..c0eeb134 100644
--- a/example/symbol_exec/depgraph.py
+++ b/example/symbol_exec/depgraph.py
@@ -12,18 +12,18 @@ parser.add_argument("func_addr", help="Function address")
 parser.add_argument("target_addr", help="Address to start")
 parser.add_argument("element", nargs="+", help="Elements to track")
 parser.add_argument("-m", "--architecture",
-		    help="Architecture (%s)" % Machine.available_machine())
+                    help="Architecture (%s)" % Machine.available_machine())
 parser.add_argument("-i", "--implicit", help="Use implicit tracking",
-		    action="store_true")
+                    action="store_true")
 parser.add_argument("--unfollow-mem", help="Stop on memory statements",
-		    action="store_true")
+                    action="store_true")
 parser.add_argument("--unfollow-call", help="Stop on call statements",
-		    action="store_true")
+                    action="store_true")
 parser.add_argument("--do-not-simplify", help="Do not simplify expressions",
-		    action="store_true")
+                    action="store_true")
 parser.add_argument("--rename-args",
                     help="Rename common arguments (@32[ESP_init] -> Arg1)",
-		    action="store_true")
+                    action="store_true")
 args = parser.parse_args()
 
 # Get architecture
@@ -38,9 +38,9 @@ elements = set()
 regs = machine.mn.regs.all_regs_ids_byname
 for element in args.element:
     try:
-	elements.add(regs[element.upper()])
+        elements.add(regs[element.upper()])
     except KeyError:
-	raise ValueError("Unknown element '%s'" % element)
+        raise ValueError("Unknown element '%s'" % element)
 
 mdis = machine.dis_engine(cont.bin_stream, dont_dis_nulstart_bloc=True)
 ir_arch = machine.ira(mdis.symbol_pool)
@@ -63,9 +63,9 @@ for block in blocks:
 
 # Get the instance
 dg = DependencyGraph(ir_arch, implicit=args.implicit,
-		     apply_simp=not(args.do_not_simplify),
-		     follow_mem=not(args.unfollow_mem),
-		     follow_call=not(args.unfollow_call))
+                     apply_simp=not args.do_not_simplify,
+                     follow_mem=not args.unfollow_mem,
+                     follow_call=not args.unfollow_call)
 
 # Build information
 target_addr = int(args.target_addr, 0)
@@ -73,23 +73,24 @@ current_block = list(ir_arch.getby_offset(target_addr))[0]
 line_nb = 0
 for line_nb, line in enumerate(current_block.lines):
     if line.offset == target_addr:
-	break
+        break
 
 # Enumerate solutions
 for sol_nb, sol in enumerate(dg.get(current_block.label, elements, line_nb, set())):
-	fname = "sol_%d.dot" % sol_nb
-	with open(fname, "w") as fdesc:
-		fdesc.write(sol.graph.dot())
-	result = ", ".join("%s: %s" % (k, v)
-			   for k, v in sol.emul(ctx=init_ctx).iteritems())
-	print "Solution %d: %s -> %s" % (sol_nb,
-					 result,
-					 fname)
-        if args.implicit:
-            sat = sol.is_satisfiable
-            constraints = ""
-            if sat:
-                constraints = {}
-                for element in sol.constraints:
-                    constraints[element] = hex(sol.constraints[element].as_long())
-            print "\tSatisfiability: %s %s" % (sat, constraints)
+    fname = "sol_%d.dot" % sol_nb
+    with open(fname, "w") as fdesc:
+            fdesc.write(sol.graph.dot())
+    result = ", ".join("%s: %s" % (k, v)
+                       for k, v in sol.emul(ctx=init_ctx).iteritems())
+    print "Solution %d: %s -> %s" % (sol_nb,
+                                     result,
+                                     fname)
+    if args.implicit:
+        sat = sol.is_satisfiable
+        constraints = ""
+        if sat:
+            constraints = {}
+            for element in sol.constraints:
+                constraints[element] = hex(
+                    sol.constraints[element].as_long())
+        print "\tSatisfiability: %s %s" % (sat, constraints)