示例#1
0
 def setUp(self):
     import esbmc
     # cwd = regression/python
     self.ns, self.opts, self.po = esbmc.init_esbmc_process(
         ['test_data/00_big_endian_01/main.c', '--big-endian', '--bv'])
     self.funcs = self.po.goto_functions
     self.main = self.funcs.function_map[esbmc.irep_idt('c::main')].body
示例#2
0
文件: gotoinsns.py 项目: esbmc/esbmc
 def setUp(self):
     import esbmc
     # cwd = regression/python
     self.ns, self.opts, self.po = esbmc.init_esbmc_process(['test_data/00_big_endian_01/main.c', '--big-endian', '--bv'])
     self.funcs = self.po.goto_functions
     self.main = self.funcs.function_map[esbmc.irep_idt('main')].body
     self.insns = self.main.get_instructions()
 def test_args(self):
     import esbmc
     # Had a problem in the past with the arg list being reversed...
     ns, opts, po = esbmc.init_esbmc_process([
         './test_data/00_big_endian_01/main.c', '--timeout', '1m',
         '--memlimit', '1g'
     ])
     esbmc.kill_esbmc_process()
示例#4
0
文件: reachtree.py 项目: esbmc/esbmc
 def setUp(self):
     import esbmc
     # cwd = regression/python
     self.ns, self.opts, self.po = esbmc.init_esbmc_process(['test_data/00_big_endian_01/main.c', '--big-endian', '--bv'])
     self.funcs = self.po.goto_functions
     self.main = self.funcs.function_map[esbmc.irep_idt('main')].body
     self.eq = esbmc.symex.equation(self.ns)
     self.art = esbmc.symex.reachability_tree(self.po.goto_functions, self.ns, self.opts, self.eq, self.po.context, self.po.message_handler)
示例#5
0
 def setUp(self):
     import esbmc
     # cwd = regression/python
     self.ns, self.opts, self.po = esbmc.init_esbmc_process(
         ['test_data/00_big_endian_01/main.c', '--big-endian', '--bv'])
     self.funcs = self.po.goto_functions
     self.main = self.funcs.function_map[esbmc.irep_idt('c::main')].body
     self.eq = esbmc.symex.equation(self.ns)
     self.art = esbmc.symex.reachability_tree(self.po.goto_functions,
                                              self.ns, self.opts, self.eq,
                                              self.po.context,
                                              self.po.message_handler)
示例#6
0
文件: exstate.py 项目: esbmc/esbmc
 def setUp(self):
     import esbmc
     # cwd = regression/python
     self.ns, self.opts, self.po = esbmc.init_esbmc_process(['test_data/00_big_endian_01/main.c', '--big-endian', '--bv'])
     self.funcs = self.po.goto_functions
     self.main = self.funcs.function_map[esbmc.irep_idt('main')].body
     self.eq = esbmc.symex.equation(self.ns)
     self.art = esbmc.symex.reachability_tree(self.po.goto_functions, self.ns, self.opts, self.eq, self.po.context, self.po.message_handler)
     # Step that art once...
     self.art.setup_for_new_explore()
     self.art.get_cur_state().symex_step(self.art)
     self.curstate = self.art.get_cur_state()
示例#7
0
 def setUp(self):
     import esbmc
     # cwd = regression/python
     self.ns, self.opts, self.po = esbmc.init_esbmc_process(
         ['test_data/00_big_endian_01/main.c', '--big-endian', '--bv'])
     self.funcs = self.po.goto_functions
     self.main = self.funcs.function_map[esbmc.irep_idt('c::main')].body
     self.eq = esbmc.symex.equation(self.ns)
     self.art = esbmc.symex.reachability_tree(self.po.goto_functions,
                                              self.ns, self.opts, self.eq,
                                              self.po.context,
                                              self.po.message_handler)
     # Step that art once...
     self.art.setup_for_new_explore()
     self.art.get_cur_state().symex_step(self.art)
     self.curstate = self.art.get_cur_state()
示例#8
0
#!/usr/bin/python3
import sys
import esbmc

# Cruft for running below. Pass command line options through to esbmc.
# Hopefully this means we effectively wrap esbmc.

ns, opts, po = esbmc.init_esbmc_process(sys.argv[1:])
eq = esbmc.symex.equation(ns)
art = esbmc.symex.reachability_tree(po.goto_functions, ns, opts, eq, po.context, po.message_handler)

art.setup_for_new_explore()
result = art.get_next_formula()
if result.remaining_claims == 0:
    print('No remaining claims')
    print("VERIFICATION SUCCESSFUL")
    sys.exit(0)

esbmc.symex.slice(result.target)
lolsolve = esbmc.solve.solvers.z3.make(False, ns, opts)
result.target.convert(lolsolve)
issat = lolsolve.dec_solve()

if issat == esbmc.solve.smt_result.sat:
    trace = esbmc.symex.goto_tracet()
    esbmc.symex.build_goto_trace(result.target, lolsolve, trace)
    print(trace.to_string(ns))
    print("VERIFICATION FAILED")
elif issat == esbmc.solve.smt_result.unsat:
    print("VERIFICATION SUCCESSFUL")
else:
示例#9
0
文件: gotofuncs.py 项目: esbmc/esbmc
 def setUp(self):
     import esbmc
     # cwd = regression/python
     self.ns, self.opts, self.po = esbmc.init_esbmc_process(['test_data/00_big_endian_01/main.c', '--big-endian', '--bv'])
     self.funcs = self.po.goto_functions
示例#10
0
 def test_setup(self):
     import esbmc
     # Assumes cwd = python test dir
     ns, opts, po = esbmc.init_esbmc_process(
         ['./test_data/00_big_endian_01/main.c'])
     esbmc.kill_esbmc_process()
示例#11
0
#!/usr/bin/python3
import sys
import esbmc
from esbmc.goto_programs import goto_program_instruction_type as gptypes

# Arguments: Anything on the command line, and callintercept.c

args = sys.argv[1:] # This may be an empty list
args.append('callintercept.c')
ns, opts, po = esbmc.init_esbmc_process(args)

class ExState2(esbmc.symex.execution_state.dfs_execution_state):
    def __init__(self, *posargs):
        # Call superclass constructor
        super(ExState2, self).__init__(*posargs)

    def symex_step(self, art):
        # Pick out src obj
        gss = art.get_cur_state().get_active_state()
        src = gss.source
        # pc becomes an insn number, lookup insns. Select current insn
        insns = src.prog.get_instructions()
        localpc = src.pc - insns[0].location_number
        insn = src.prog.get_instructions()[localpc]

        normal = True
        if insn.type == gptypes.FUNCTION_CALL:
            # Pick out function calls
            call = esbmc.downcast_expr(insn.code)
            sym = esbmc.downcast_expr(call.function)