Ejemplo n.º 1
0
def create_out_test_txt(path, out_test_path_dir, TESTCOUNT):
    out_test_path_comp = out_test_path_dir + str("out_test") + str(
        TESTCOUNT) + str(".txt")
    out_test_fp = open(out_test_path_comp, 'w')

    stm_main.init_reg_por()
    data_index = 0
    for flow in path.flow_list:
        if (flow.typ == FLOW.new):
            # Output all Regs info after previous instruction execution complete
            out_all_regs(data_index, out_test_fp)
            current_data = path.data_example[data_index]
            current_data_stp = solver.bitvecval(32, current_data)
            data_index = data_index + 1

        elif (flow.typ == FLOW.instr):
            reg = flow.element.reg
            write_reg_with_mask(reg, current_data_stp)

        elif (flow.typ == FLOW.constraint):
            pass
        elif (flow.typ == FLOW.stmt):
            (flow.element.stmt)(current_data)

    out_all_regs(data_index, out_test_fp)

    out_test_fp.close()
    pass
Ejemplo n.º 2
0
def create_out_test_txt(path, out_test_path_dir, TESTCOUNT):
    out_test_path_comp = out_test_path_dir + str("out_test") + str(TESTCOUNT) + str(".txt")
    out_test_fp = open(out_test_path_comp, "w")

    stm_main.init_reg_por()
    data_index = 0
    for flow in path.flow_list:
        if flow.typ == FLOW.new:
            # Output all Regs info after previous instruction execution complete
            out_all_regs(data_index, out_test_fp)
            current_data = path.data_example[data_index]
            current_data_stp = solver.bitvecval(32, current_data)
            data_index = data_index + 1

        elif flow.typ == FLOW.instr:
            reg = flow.element.reg
            write_reg_with_mask(reg, current_data_stp)

        elif flow.typ == FLOW.constraint:
            pass
        elif flow.typ == FLOW.stmt:
            (flow.element.stmt)(current_data)

    out_all_regs(data_index, out_test_fp)

    out_test_fp.close()
    pass
Ejemplo n.º 3
0
def check_path_possible(path, do_model):
    global solver

    solver.push()
    stm_main.init_reg_por()
    data_index = 0
    current_data = None
    for flow in path.flow_list:
        if (flow.typ == FLOW.new):
            if (do_model != None):
                if (data_index > 0):
                    path.data_example.insert(data_index - 1,
                                             solver.model()[current_data.name])
            solver.pop()
            solver.push()
            current_data = path.data_list[data_index]
            data_index = data_index + 1

        elif (flow.typ == FLOW.instr):
            reg = flow.element.reg
            write_reg_with_mask(reg, current_data)

        elif (flow.typ == FLOW.constraint):
            solver.add((flow.element.constraint)(current_data))
            if (solver.check() != True):
                return False
        elif (flow.typ == FLOW.stmt):
            (flow.element.stmt)(current_data)

    if (do_model != None):
        if (data_index > 0):
            path.data_example.insert(data_index - 1,
                                     int(solver.model()[current_data.name]))
    solver.pop()
    return True
Ejemplo n.º 4
0
def check_path_possible(path, do_model):
    global solver

    solver.push()
    stm_main.init_reg_por()
    data_index = 0
    current_data = None
    for flow in path.flow_list:
        if flow.typ == FLOW.new:
            if do_model != None:
                if data_index > 0:
                    path.data_example.insert(data_index - 1, solver.model()[current_data.name])
            solver.pop()
            solver.push()
            current_data = path.data_list[data_index]
            data_index = data_index + 1

        elif flow.typ == FLOW.instr:
            reg = flow.element.reg
            write_reg_with_mask(reg, current_data)

        elif flow.typ == FLOW.constraint:
            solver.add((flow.element.constraint)(current_data))
            if solver.check() != True:
                return False
        elif flow.typ == FLOW.stmt:
            (flow.element.stmt)(current_data)

    if do_model != None:
        if data_index > 0:
            path.data_example.insert(data_index - 1, int(solver.model()[current_data.name]))
    solver.pop()
    return True