diff options
| -rw-r--r-- | miasm2/jitter/Jitgcc.c | 8 | ||||
| -rw-r--r-- | miasm2/jitter/Jitllvm.c | 8 | ||||
| -rw-r--r-- | miasm2/jitter/jitcore.py | 15 | ||||
| -rw-r--r-- | miasm2/jitter/jitcore_python.py | 2 | ||||
| -rw-r--r-- | miasm2/jitter/jitload.py | 5 |
5 files changed, 24 insertions, 14 deletions
diff --git a/miasm2/jitter/Jitgcc.c b/miasm2/jitter/Jitgcc.c index 6273627a..329b7db4 100644 --- a/miasm2/jitter/Jitgcc.c +++ b/miasm2/jitter/Jitgcc.c @@ -16,7 +16,7 @@ PyObject* gcc_exec_block(PyObject* self, PyObject* args) PyObject* jitcpu; PyObject* func_py; PyObject* lbl2ptr; - PyObject* breakpoints; + PyObject* stop_offsets; PyObject* retaddr = NULL; int status; block_id BlockDst; @@ -26,7 +26,7 @@ PyObject* gcc_exec_block(PyObject* self, PyObject* args) if (!PyArg_ParseTuple(args, "OOOO|K", - &retaddr, &jitcpu, &lbl2ptr, &breakpoints, + &retaddr, &jitcpu, &lbl2ptr, &stop_offsets, &max_exec_per_call)) return NULL; @@ -73,8 +73,8 @@ PyObject* gcc_exec_block(PyObject* self, PyObject* args) if (status) return retaddr; - // Check breakpoint - if (PyDict_Contains(breakpoints, retaddr)) + // Check stop offsets + if (PySet_Contains(stop_offsets, retaddr)) return retaddr; } } diff --git a/miasm2/jitter/Jitllvm.c b/miasm2/jitter/Jitllvm.c index 325e6606..6ecbd483 100644 --- a/miasm2/jitter/Jitllvm.c +++ b/miasm2/jitter/Jitllvm.c @@ -20,14 +20,14 @@ PyObject* llvm_exec_block(PyObject* self, PyObject* args) uint8_t status; PyObject* func_py; PyObject* lbl2ptr; - PyObject* breakpoints; + PyObject* stop_offsets; PyObject* retaddr = NULL; uint64_t max_exec_per_call = 0; uint64_t cpt; int do_cpt; if (!PyArg_ParseTuple(args, "OOOO|K", - &retaddr, &jitcpu, &lbl2ptr, &breakpoints, + &retaddr, &jitcpu, &lbl2ptr, &stop_offsets, &max_exec_per_call)) return NULL; @@ -68,8 +68,8 @@ PyObject* llvm_exec_block(PyObject* self, PyObject* args) if (status) return retaddr; - // Check breakpoint - if (PyDict_Contains(breakpoints, retaddr)) + // Check stop offsets + if (PySet_Contains(stop_offsets, retaddr)) return retaddr; } } diff --git a/miasm2/jitter/jitcore.py b/miasm2/jitter/jitcore.py index 77defa30..b636782d 100644 --- a/miasm2/jitter/jitcore.py +++ b/miasm2/jitter/jitcore.py @@ -166,10 +166,16 @@ class JitCore(object): self.add_block_to_mem_interval(vm, cur_block) return cur_block - def run_at(self, cpu, offset, breakpoints): - """Run from the starting address @offset + def run_at(self, cpu, offset, stop_offsets): + """Run from the starting address @offset. + Execution will stop if: + - max_exec_per_call option is reached + - a new, yet unknown, block is reached after the execution of block at + address @offset + - an address in @stop_offsets is reached @cpu: JitCpu instance - @offset: target offset + @offset: starting address (int) + @stop_offsets: set of address on which the jitter must stop """ if offset is None: @@ -189,7 +195,8 @@ class JitCore(object): return offset # Run the block and update cpu/vmmngr state - return self.exec_wrapper(offset, cpu, self.offset_to_jitted_func.data, breakpoints, + return self.exec_wrapper(offset, cpu, self.offset_to_jitted_func.data, + stop_offsets, self.options["max_exec_per_call"]) def blocks_to_memrange(self, blocks): diff --git a/miasm2/jitter/jitcore_python.py b/miasm2/jitter/jitcore_python.py index 1f753b07..45b418b5 100644 --- a/miasm2/jitter/jitcore_python.py +++ b/miasm2/jitter/jitcore_python.py @@ -131,7 +131,7 @@ class JitCore_Python(jitcore.JitCore): assert offset is not None self.offset_to_jitted_func[offset] = myfunc - def exec_wrapper(self, loc_key, cpu, _offset_to_jitted_func, _breakpoints, + def exec_wrapper(self, loc_key, cpu, _offset_to_jitted_func, _stop_offsets, _max_exec_per_call): """Call the function @loc_key with @cpu @loc_key: function's loc_key diff --git a/miasm2/jitter/jitload.py b/miasm2/jitter/jitload.py index 097826bf..5f8b4ad6 100644 --- a/miasm2/jitter/jitload.py +++ b/miasm2/jitter/jitload.py @@ -307,7 +307,10 @@ class Jitter(object): """Wrapper on JiT backend. Run the code at PC and return the next PC. @pc: address of code to run""" - return self.jit.run_at(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. |