diff options
Diffstat (limited to 'test')
| -rw-r--r-- | test/analysis/data_flow.py | 28 | ||||
| -rw-r--r-- | test/analysis/depgraph.py | 72 | ||||
| -rw-r--r-- | test/core/sembuilder.py | 12 | ||||
| -rw-r--r-- | test/expression/expression.py | 2 | ||||
| -rwxr-xr-x | test/expression/expression_helper.py | 4 | ||||
| -rw-r--r-- | test/expression/simplifications.py | 28 | ||||
| -rw-r--r-- | test/ir/ir.py | 4 | ||||
| -rwxr-xr-x | test/ir/symbexec.py | 6 |
8 files changed, 78 insertions, 78 deletions
diff --git a/test/analysis/data_flow.py b/test/analysis/data_flow.py index 2c24773a..dff88470 100644 --- a/test/analysis/data_flow.py +++ b/test/analysis/data_flow.py @@ -5,20 +5,20 @@ from miasm2.analysis.data_flow import * from miasm2.ir.analysis import ira from miasm2.ir.ir import IRBlock, AssignBlock -a = ExprId("a") -b = ExprId("b") -c = ExprId("c") -d = ExprId("d") -r = ExprId("r") +a = ExprId("a", 32) +b = ExprId("b", 32) +c = ExprId("c", 32) +d = ExprId("d", 32) +r = ExprId("r", 32) -a_init = ExprId("a_init") -b_init = ExprId("b_init") -c_init = ExprId("c_init") -d_init = ExprId("d_init") -r_init = ExprId("r_init") # Return register +a_init = ExprId("a_init", 32) +b_init = ExprId("b_init", 32) +c_init = ExprId("c_init", 32) +d_init = ExprId("d_init", 32) +r_init = ExprId("r_init", 32) # Return register -pc = ExprId("pc") -sp = ExprId("sp") +pc = ExprId("pc", 32) +sp = ExprId("sp", 32) CST1 = ExprInt(0x11, 32) CST2 = ExprInt(0x12, 32) @@ -635,7 +635,7 @@ G17_EXP_IRB0 = gen_irblock(LBL0, [[], ExprAff(b, a), ExprAff(c, b)], - G17_IRB0.irs[14] + G17_IRB0[14] # Trick because a+b+c != ((a+b)+c) ]) @@ -684,4 +684,4 @@ for test_nb, test in enumerate([(G1_IRA, G1_EXP_IRA), # Check that each expr in the blocks are the same for lbl, irb in g_ira.blocks.iteritems(): exp_irb = g_exp_ira.blocks[lbl] - assert exp_irb.irs == irb.irs + assert exp_irb.assignblks == irb.assignblks diff --git a/test/analysis/depgraph.py b/test/analysis/depgraph.py index 63313861..9fb046d0 100644 --- a/test/analysis/depgraph.py +++ b/test/analysis/depgraph.py @@ -16,19 +16,19 @@ except ImportError: EMULATION = False STEP_COUNTER = count() -A = ExprId("a") -B = ExprId("b") -C = ExprId("c") -D = ExprId("d") -R = ExprId("r") +A = ExprId("a", 32) +B = ExprId("b", 32) +C = ExprId("c", 32) +D = ExprId("d", 32) +R = ExprId("r", 32) -A_INIT = ExprId("a_init") -B_INIT = ExprId("b_init") -C_INIT = ExprId("c_init") -D_INIT = ExprId("d_init") +A_INIT = ExprId("a_init", 32) +B_INIT = ExprId("b_init", 32) +C_INIT = ExprId("c_init", 32) +D_INIT = ExprId("d_init", 32) -PC = ExprId("pc") -SP = ExprId("sp") +PC = ExprId("pc", 32) +SP = ExprId("sp", 32) CST0 = ExprInt(0x0, 32) CST1 = ExprInt(0x1, 32) @@ -132,7 +132,7 @@ def bloc2graph(irgraph, label=False, lines=True): label_attr, label_name) block_html_lines = [] if lines and irblock is not None: - for assignblk in irblock.irs: + for assignblk in irblock: for dst, src in assignblk.iteritems(): if False: out_render = "%.8X</td><td %s> " % (0, td_attr) @@ -277,8 +277,8 @@ G4_IRA = IRATest() G4_IRB0 = gen_irblock(LBL0, [[ExprAff(C, CST1)]]) G4_IRB1 = gen_irblock(LBL1, [[ExprAff(C, C + CST2)], [ExprAff(G4_IRA.IRDst, - ExprCond(C, ExprId(LBL2), - ExprId(LBL1)))]]) + ExprCond(C, ExprId(LBL2, 32), + ExprId(LBL1, 32)))]]) G4_IRB2 = gen_irblock(LBL2, [[ExprAff(A, B)]]) @@ -296,8 +296,8 @@ G5_IRA = IRATest() G5_IRB0 = gen_irblock(LBL0, [[ExprAff(B, CST1)]]) G5_IRB1 = gen_irblock(LBL1, [[ExprAff(B, B + CST2)], [ExprAff(G5_IRA.IRDst, - ExprCond(B, ExprId(LBL2), - ExprId(LBL1)))]]) + ExprCond(B, ExprId(LBL2, 32), + ExprId(LBL1, 32)))]]) G5_IRB2 = gen_irblock(LBL2, [[ExprAff(A, B)]]) @@ -400,16 +400,16 @@ G13_IRA = IRATest() G13_IRB0 = gen_irblock(LBL0, [[ExprAff(A, CST1)], #[ExprAff(B, A)], [ExprAff(G13_IRA.IRDst, - ExprId(LBL1))]]) + ExprId(LBL1, 32))]]) G13_IRB1 = gen_irblock(LBL1, [[ExprAff(C, A)], #[ExprAff(A, A + CST1)], [ExprAff(G13_IRA.IRDst, - ExprCond(R, ExprId(LBL2), - ExprId(LBL1)))]]) + ExprCond(R, ExprId(LBL2, 32), + ExprId(LBL1, 32)))]]) G13_IRB2 = gen_irblock(LBL2, [[ExprAff(B, A + CST3)], [ExprAff(A, B + CST3)], [ExprAff(G13_IRA.IRDst, - ExprId(LBL1))]]) + ExprId(LBL1, 32))]]) G13_IRB3 = gen_irblock(LBL3, [[ExprAff(R, C)]]) @@ -427,18 +427,18 @@ G14_IRA = IRATest() G14_IRB0 = gen_irblock(LBL0, [[ExprAff(A, CST1)], [ExprAff(G14_IRA.IRDst, - ExprId(LBL1))] + ExprId(LBL1, 32))] ]) G14_IRB1 = gen_irblock(LBL1, [[ExprAff(B, A)], [ExprAff(G14_IRA.IRDst, - ExprCond(C, ExprId(LBL2), - ExprId(LBL3)))] + ExprCond(C, ExprId(LBL2, 32), + ExprId(LBL3, 32)))] ]) G14_IRB2 = gen_irblock(LBL2, [[ExprAff(D, A)], [ExprAff(A, D + CST1)], [ExprAff(G14_IRA.IRDst, - ExprId(LBL1))] + ExprId(LBL1, 32))] ]) G14_IRB3 = gen_irblock(LBL3, [[ExprAff(R, D + B)]]) @@ -510,72 +510,72 @@ G17_IRA.blocks = dict([(irb.label, irb) for irb in [G17_IRB0, G17_IRB1, # Test graph 1 G1_TEST1_DN1 = DependencyNode( - G1_IRB2.label, A, len(G1_IRB2.irs)) + G1_IRB2.label, A, len(G1_IRB2)) G1_INPUT = (set([G1_TEST1_DN1]), set([G1_IRB0.label])) # Test graph 2 G2_TEST1_DN1 = DependencyNode( - G2_IRB2.label, A, len(G2_IRB2.irs)) + G2_IRB2.label, A, len(G2_IRB2)) G2_INPUT = (set([G2_TEST1_DN1]), set([G2_IRB0.label])) # Test graph 3 G3_TEST1_0_DN1 = DependencyNode( - G3_IRB3.label, A, len(G3_IRB3.irs)) + G3_IRB3.label, A, len(G3_IRB3)) G3_INPUT = (set([G3_TEST1_0_DN1]), set([G3_IRB0.label])) # Test graph 4 G4_TEST1_DN1 = DependencyNode( - G4_IRB2.label, A, len(G2_IRB0.irs)) + G4_IRB2.label, A, len(G2_IRB0)) G4_INPUT = (set([G4_TEST1_DN1]), set([G4_IRB0.label])) # Test graph 5 G5_TEST1_0_DN1 = DependencyNode( - G5_IRB2.label, A, len(G5_IRB2.irs)) + G5_IRB2.label, A, len(G5_IRB2)) G5_INPUT = (set([G5_TEST1_0_DN1]), set([G5_IRB0.label])) # Test graph 6 G6_TEST1_0_DN1 = DependencyNode( - G6_IRB1.label, A, len(G6_IRB1.irs)) + G6_IRB1.label, A, len(G6_IRB1)) G6_INPUT = (set([G6_TEST1_0_DN1]), set([G6_IRB0.label])) # Test graph 7 G7_TEST1_0_DN1 = DependencyNode( - G7_IRB2.label, D, len(G7_IRB2.irs)) + G7_IRB2.label, D, len(G7_IRB2)) G7_INPUT = (set([G7_TEST1_0_DN1]), set([G7_IRB0.label])) # Test graph 8 G8_TEST1_0_DN1 = DependencyNode( - G8_IRB2.label, A, len(G8_IRB2.irs)) + G8_IRB2.label, A, len(G8_IRB2)) G8_INPUT = (set([G8_TEST1_0_DN1]), set([G3_IRB0.label])) # Test 9: Multi elements G9_TEST1_0_DN1 = DependencyNode( - G8_IRB2.label, A, len(G8_IRB2.irs)) + G8_IRB2.label, A, len(G8_IRB2)) G9_TEST1_0_DN5 = DependencyNode( - G8_IRB2.label, C, len(G8_IRB2.irs)) + G8_IRB2.label, C, len(G8_IRB2)) G9_INPUT = (set([G9_TEST1_0_DN1, G9_TEST1_0_DN5]), set([G8_IRB0.label])) # Test 10: loop at beginning G10_TEST1_0_DN1 = DependencyNode( - G10_IRB2.label, A, len(G10_IRB2.irs)) + G10_IRB2.label, A, len(G10_IRB2)) G10_INPUT = (set([G10_TEST1_0_DN1]), set([G10_IRB1.label])) @@ -583,7 +583,7 @@ G10_INPUT = (set([G10_TEST1_0_DN1]), set([G10_IRB1.label])) # Test 11: no dual bloc emulation G11_TEST1_DN1 = DependencyNode( - G11_IRB2.label, A, len(G11_IRB2.irs)) + G11_IRB2.label, A, len(G11_IRB2)) G11_INPUT = (set([G11_TEST1_DN1]), set([G11_IRB0.label])) diff --git a/test/core/sembuilder.py b/test/core/sembuilder.py index d8fdb6c4..ebf9f385 100644 --- a/test/core/sembuilder.py +++ b/test/core/sembuilder.py @@ -8,7 +8,7 @@ from miasm2.core.asmblock import AsmLabel # Test classes class IR(object): - IRDst = m2_expr.ExprId("IRDst") + IRDst = m2_expr.ExprId("IRDst", 32) def get_next_instr(self, _): return AsmLabel("NEXT") @@ -41,9 +41,9 @@ def test(Arg1, Arg2, Arg3): else: alias = {i16(4), i8(5)} -a = m2_expr.ExprId('A') -b = m2_expr.ExprId('B') -c = m2_expr.ExprId('C') +a = m2_expr.ExprId('A', 32) +b = m2_expr.ExprId('B', 32) +c = m2_expr.ExprId('C', 32) ir = IR() instr = Instr() res = test(ir, instr, a, b, c) @@ -59,7 +59,7 @@ for statement in res[0]: print "[+] Blocks:" for irb in res[1]: print irb.label - for exprs in irb.irs: - for expr in exprs: + for assignblk in irb: + for expr in assignblk: print expr print diff --git a/test/expression/expression.py b/test/expression/expression.py index ac145a04..6bb6d94c 100644 --- a/test/expression/expression.py +++ b/test/expression/expression.py @@ -15,7 +15,7 @@ assert big_cst.size == 0x1000 # Possible values #- Common constants -A = ExprId("A") +A = ExprId("A", 32) cond1 = ExprId("cond1", 1) cond2 = ExprId("cond2", 16) cst1 = ExprInt(1, 32) diff --git a/test/expression/expression_helper.py b/test/expression/expression_helper.py index a4c221e9..35873ca4 100755 --- a/test/expression/expression_helper.py +++ b/test/expression/expression_helper.py @@ -12,8 +12,8 @@ class TestExpressionExpressionHelper(unittest.TestCase): # Build a complex expression cst = m2_expr.ExprInt(0x100, 16) - eax = m2_expr.ExprId("EAX") - ebx = m2_expr.ExprId("EBX") + eax = m2_expr.ExprId("EAX", 32) + ebx = m2_expr.ExprId("EBX", 32) ax = eax[0:16] expr = eax + ebx expr = m2_expr.ExprCompose(ax, expr[16:32]) diff --git a/test/expression/simplifications.py b/test/expression/simplifications.py index ad420621..1e8e73ba 100644 --- a/test/expression/simplifications.py +++ b/test/expression/simplifications.py @@ -8,11 +8,11 @@ from miasm2.expression.simplifications import expr_simp, ExpressionSimplifier from miasm2.expression.simplifications_cond import ExprOp_inf_signed, ExprOp_inf_unsigned, ExprOp_equal # Define example objects -a = ExprId('a') -b = ExprId('b') -c = ExprId('c') -d = ExprId('d') -e = ExprId('e') +a = ExprId('a', 32) +b = ExprId('b', 32) +c = ExprId('c', 32) +d = ExprId('d', 32) +e = ExprId('e', 32) f = ExprId('f', size=64) m = ExprMem(a) @@ -378,17 +378,17 @@ for e, e_check in to_test[:]: -x = ExprId('x') -y = ExprId('y') -z = ExprId('z') -a = ExprId('a') -b = ExprId('b') -c = ExprId('c') +x = ExprId('x', 32) +y = ExprId('y', 32) +z = ExprId('z', 32) +a = ExprId('a', 32) +b = ExprId('b', 32) +c = ExprId('c', 32) -jra = ExprId('jra') -jrb = ExprId('jrb') -jrint1 = ExprId('jrint1') +jra = ExprId('jra', 32) +jrb = ExprId('jrb', 32) +jrint1 = ExprId('jrint1', 32) e1 = ExprMem((a & ExprInt(0xFFFFFFFC, 32)) + ExprInt(0x10, 32), 32) diff --git a/test/ir/ir.py b/test/ir/ir.py index 05936d75..3774e4e9 100644 --- a/test/ir/ir.py +++ b/test/ir/ir.py @@ -2,8 +2,8 @@ from miasm2.expression.expression import * from miasm2.ir.ir import AssignBlock from miasm2.expression.simplifications import expr_simp -id_a = ExprId("a") -id_b = ExprId("b") +id_a = ExprId("a", 32) +id_b = ExprId("b", 32) int0 = ExprInt(0, id_a.size) # Test AssignBlock diff --git a/test/ir/symbexec.py b/test/ir/symbexec.py index f8d8c7bf..492dcfec 100755 --- a/test/ir/symbexec.py +++ b/test/ir/symbexec.py @@ -30,10 +30,10 @@ class TestSymbExec(unittest.TestCase): mem40w = ExprMem(addr40, 16) mem50v = ExprMem(addr50, 8) mem50w = ExprMem(addr50, 16) - id_x = ExprId('x') + id_x = ExprId('x', 32) id_y = ExprId('y', 8) - id_a = ExprId('a') - id_eax = ExprId('eax_init') + id_a = ExprId('a', 32) + id_eax = ExprId('eax_init', 32) e = SymbolicExecutionEngine(ir_x86_32(), {mem0: id_x, mem1: id_y, mem9: id_x, |