# Path: sibyl/engine/engine.py
# class Engine(object):
#     """Wrapper on execution engine"""
# 
#     def __init__(self, machine):
#         """Instanciate an Engine
#         @machine: miasm2.analysis.machine:Machine instance"""
#         self.logger = init_logger(self.__class__.__name__)
# 
#     def take_snapshot(self):
#         self.vm_mem = self.jitter.vm.get_all_memory()
#         self.vm_regs = self.jitter.cpu.get_gpreg()
# 
#     def restore_snapshot(self, memory=True):
#         raise NotImplementedError("Abstract method")
# 
#     def run(self, address, timeout_seconds):
#         raise NotImplementedError("Abstract method")
# 
#     def prepare_run(self):
#         pass
# 
#     def restore_snapshot(self, memory=True):
#         raise NotImplementedError("Abstract method")
# 
# Path: sibyl/commons.py
# class TimeoutException(Exception):
#     """Exception to be called on timeouts"""
#     pass
# 
# END_ADDR = 0x1337babe


import signal
from sibyl.engine.engine import Engine
from sibyl.commons import TimeoutException, END_ADDR
        #
        # Due to Python signal handling implementation, signals aren't handled
        # nor passed to Jitted code in case of registration with signal API
        if jit_engine == "python":
            signal.signal(signal.SIGALRM, MiasmEngine._timeout)
        elif jit_engine in ["llvm", "tcc", "gcc"]:
            self.jitter.vm.set_alarm()
        else:
            raise ValueError("Unknown engine: %s" % jit_engine)

        super(MiasmEngine, self).__init__(machine)


    @staticmethod
    def _code_sentinelle(jitter):
        jitter.run = False
        jitter.pc = 0
        return True

    @staticmethod
    def _timeout(signum, frame):
        raise TimeoutException()

    def run(self, address, timeout_seconds):
        self.jitter.init_run(address)

        try:
            signal.alarm(timeout_seconds)
            self.jitter.continue_run()
        except (AssertionError, RuntimeError, ValueError,

# Path: sibyl/engine/engine.py
# class Engine(object):
#     """Wrapper on execution engine"""
# 
#     def __init__(self, machine):
#         """Instanciate an Engine
#         @machine: miasm2.analysis.machine:Machine instance"""
#         self.logger = init_logger(self.__class__.__name__)
# 
#     def take_snapshot(self):
#         self.vm_mem = self.jitter.vm.get_all_memory()
#         self.vm_regs = self.jitter.cpu.get_gpreg()
# 
#     def restore_snapshot(self, memory=True):
#         raise NotImplementedError("Abstract method")
# 
#     def run(self, address, timeout_seconds):
#         raise NotImplementedError("Abstract method")
# 
#     def prepare_run(self):
#         pass
# 
#     def restore_snapshot(self, memory=True):
#         raise NotImplementedError("Abstract method")
# 
# Path: sibyl/commons.py
# class TimeoutException(Exception):
#     """Exception to be called on timeouts"""
#     pass
# 
# END_ADDR = 0x1337babe


# Path: sibyl/engine/miasm.py
import signal
from sibyl.engine.engine import Engine
from sibyl.commons import TimeoutException, END_ADDR

        #
        # Due to Python signal handling implementation, signals aren't handled
        # nor passed to Jitted code in case of registration with signal API
        if jit_engine == "python":
            signal.signal(signal.SIGALRM, MiasmEngine._timeout)
        elif jit_engine in ["llvm", "tcc", "gcc"]:
            self.jitter.vm.set_alarm()
        else:
            raise ValueError("Unknown engine: %s" % jit_engine)

        super(MiasmEngine, self).__init__(machine)


    @staticmethod
    def _code_sentinelle(jitter):
        jitter.run = False
        jitter.pc = 0
        return True

    @staticmethod
    def _timeout(signum, frame):
        raise TimeoutException()

    def run(self, address, timeout_seconds):
        self.jitter.init_run(address)

        try:
            signal.alarm(timeout_seconds)
            self.jitter.continue_run()
        except (AssertionError, RuntimeError, ValueError,

                KeyError, IndexError, TimeoutException) as _: