MCPcopy Create free account
hub / github.com/qilingframework/qiling / emu_start

Method emu_start

qiling/extensions/multitask.py:303–333  ·  view source on GitHub ↗

Emulate an area of code just once. This overwrites the original emu_start interface and provides extra cares when multitask is enabled. If no task is registerd, this call bahaves like the original emu_start. NOTE: Calling this method may cause current greenlet to

(self, begin: int, end: int, timeout: int, count: int)

Source from the content-addressed store, hash-verified

301 self._tasks[utk_id]._stop_request = True
302
303 def emu_start(self, begin: int, end: int, timeout: int, count: int):
304 """ Emulate an area of code just once. This overwrites the original emu_start interface and
305 provides extra cares when multitask is enabled. If no task is registerd, this call bahaves
306 like the original emu_start.
307 NOTE: Calling this method may cause current greenlet to be switched out.
308 begin, end, timeout, count: refer to Uc.emu_start
309 """
310 if self._multitask_enabled:
311 if self._nested_started > 0:
312 with NestedCounter(self):
313 pool = gevent.get_hub().threadpool # type: gevent.threadpool.ThreadPool
314 task = pool.spawn(self._emu_start_locked, begin, end, timeout, count)
315 ucerr = task.get()
316
317 if ucerr != UC_ERR_OK:
318 raise UcError(ucerr)
319
320 return ucerr
321 else:
322
323 # Assume users resume on the last thread (and that should be the case)
324 if self._cur_utk_id in self._tasks:
325 self._tasks[self._cur_utk_id]._begin = begin
326 self._tasks[self._cur_utk_id]._end = end
327 else:
328 print(f"Warning: Can't found last thread we scheduled")
329
330 # This translation is not accurate, though.
331 self.tasks_start(count, timeout)
332 else:
333 return super().emu_start(begin, end, timeout, count)
334
335 def emu_stop(self):
336 """ Stop the emulation. If no task is registerd, this call bahaves like the original emu_stop.

Callers 15

interrupt_handlerMethod · 0.45
_runMethod · 0.45
resume_emuMethod · 0.45
runMethod · 0.45
runMethod · 0.45
runMethod · 0.45
runMethod · 0.45
__invoke_callbackMethod · 0.45
runMethod · 0.45
runMethod · 0.45
runMethod · 0.45
runMethod · 0.45

Calls 3

tasks_startMethod · 0.95
NestedCounterClass · 0.85
getMethod · 0.45

Tested by

no test coverage detected