diff options
| author | Camille Mougey <commial@gmail.com> | 2016-11-10 12:23:50 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2016-11-10 12:23:50 +0100 |
| commit | 5f728a282520b5b98de64053d98b935b206b61c1 (patch) | |
| tree | 6bd503d3012265613d06d47191bd6c5144fa166a /miasm2/jitter/Jitgcc.c | |
| parent | c106fd74add334b24533156820072a3558b1a725 (diff) | |
| parent | 0aa399dd85f33de8334e2ebc579cc336acf9a7d3 (diff) | |
| download | miasm-5f728a282520b5b98de64053d98b935b206b61c1.tar.gz miasm-5f728a282520b5b98de64053d98b935b206b61c1.zip | |
Merge pull request #450 from serpilliere/add_emul_block_limit
Jitter: Add max exec per jit call option
Diffstat (limited to 'miasm2/jitter/Jitgcc.c')
| -rw-r--r-- | miasm2/jitter/Jitgcc.c | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/miasm2/jitter/Jitgcc.c b/miasm2/jitter/Jitgcc.c index 8b789f70..71023902 100644 --- a/miasm2/jitter/Jitgcc.c +++ b/miasm2/jitter/Jitgcc.c @@ -20,14 +20,34 @@ PyObject* gcc_exec_bloc(PyObject* self, PyObject* args) PyObject* retaddr = NULL; int status; block_id BlockDst; + uint64_t max_exec_per_call = 0; + uint64_t cpt; + int do_cpt; - if (!PyArg_ParseTuple(args, "OOOO", &retaddr, &jitcpu, &lbl2ptr, &breakpoints)) + + if (!PyArg_ParseTuple(args, "OOOO|K", + &retaddr, &jitcpu, &lbl2ptr, &breakpoints, + &max_exec_per_call)) return NULL; /* The loop will decref retaddr always once */ Py_INCREF(retaddr); + if (max_exec_per_call == 0) { + do_cpt = 0; + cpt = 1; + } else { + do_cpt = 1; + cpt = max_exec_per_call; + } + + + for (;;) { + if (cpt == 0) + return retaddr; + if (do_cpt) + cpt --; // Init BlockDst.is_local = 0; BlockDst.address = 0; |