diff options
Diffstat (limited to 'miasm2/jitter/jitload.py')
| -rw-r--r-- | miasm2/jitter/jitload.py | 48 |
1 files changed, 42 insertions, 6 deletions
diff --git a/miasm2/jitter/jitload.py b/miasm2/jitter/jitload.py index db486b4f..288e737a 100644 --- a/miasm2/jitter/jitload.py +++ b/miasm2/jitter/jitload.py @@ -1,5 +1,6 @@ import logging +import warnings from functools import wraps from collections import Sequence, namedtuple, Iterator @@ -160,7 +161,7 @@ class ExceptionHandle(): return not self.__eq__(to_cmp) -class jitter(object): +class Jitter(object): "Main class for JIT handling" @@ -204,8 +205,11 @@ class jitter(object): self.cpu = jcore.JitCpu() self.ir_arch = ir_arch self.bs = bin_stream_vm(self.vm) + self.ircfg = self.ir_arch.new_ircfg() - self.symbexec = EmulatedSymbExec(self.cpu, self.vm, self.ir_arch, {}) + self.symbexec = EmulatedSymbExec( + self.cpu, self.vm, self.ir_arch, {} + ) self.symbexec.reset_regs() try: @@ -302,18 +306,20 @@ class jitter(object): """ self.exceptions_handler.add_callback(flag, callback) - def runbloc(self, pc): + def run_at(self, pc): """Wrapper on JiT backend. Run the code at PC and return the next PC. @pc: address of code to run""" - return self.jit.runbloc(self.cpu, pc, self.breakpoints_handler.callbacks) + return self.jit.run_at( + self.cpu, pc, + set(self.breakpoints_handler.callbacks.keys()) + ) def runiter_once(self, pc): """Iterator on callbacks results on code running from PC. Check exceptions before breakpoints.""" self.pc = pc - # Callback called before exec if self.exec_cb is not None: res = self.exec_cb(self) @@ -349,7 +355,7 @@ class jitter(object): assert(self.get_exception() == 0) # Run the bloc at PC - self.pc = self.runbloc(self.pc) + self.pc = self.run_at(self.pc) # Check exceptions (raised by the execution of the block) exception_flag = self.get_exception() @@ -485,3 +491,33 @@ class jitter(object): self.symbexec.update_cpu_from_engine() return ret + + def set_trace_log(self, + trace_instr=True, trace_regs=True, + trace_new_blocks=False): + """ + Activate/Deactivate trace log options + + @trace_instr: activate instructions tracing log + @trace_regs: activate registers tracing log + @trace_new_blocks: dump new code blocks log + """ + + # As trace state changes, clear already jitted blocks + self.jit.clear_jitted_blocks() + + self.jit.log_mn = trace_instr + self.jit.log_regs = trace_regs + self.jit.log_newbloc = trace_new_blocks + + +class jitter(Jitter): + """ + DEPRECATED object + Use Jitter instead of jitter + """ + + + def __init__(self, *args, **kwargs): + warnings.warn("Deprecated API: use Jitter") + super(jitter, self).__init__(*args, **kwargs) |