about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorAjax <commial@gmail.com>2016-06-23 17:19:07 +0200
committerAjax <commial@gmail.com>2016-06-23 17:19:07 +0200
commit655f7ec3f52ceb375b43a0f22f9a9af9ff1113ae (patch)
treec33d5f05515d565bf783e50ef82ee25be985ad26
parent484602ec143ce75ddfdda5f634e2a320339baf85 (diff)
downloadmiasm-655f7ec3f52ceb375b43a0f22f9a9af9ff1113ae.tar.gz
miasm-655f7ec3f52ceb375b43a0f22f9a9af9ff1113ae.zip
Allow breakpoints to act as generator
This act likes a basic Python 3 `yield from...`.
For instance, one can obtain a "stepping" breakpoint, yielding while a
given condition is not resolved and then blocking the execution at a
given state
-rw-r--r--miasm2/jitter/jitload.py8
1 files changed, 7 insertions, 1 deletions
diff --git a/miasm2/jitter/jitload.py b/miasm2/jitter/jitload.py
index cc92b0cf..abc31840 100644
--- a/miasm2/jitter/jitload.py
+++ b/miasm2/jitter/jitload.py
@@ -2,7 +2,7 @@
 
 import logging
 from functools import wraps
-from collections import Sequence, namedtuple
+from collections import Sequence, namedtuple, Iterator
 
 from miasm2.jitter.csts import *
 from miasm2.core.utils import *
@@ -309,6 +309,12 @@ class jitter:
         old_pc = self.pc
         for res in self.breakpoints_handler.call_callbacks(self.pc, self):
             if res is not True:
+                if isinstance(res, collections.Iterator):
+                    # If the breakpoint is a generator, yield it step by step
+                    for tmp in res:
+                        yield tmp
+                else:
+                    yield res
                 yield res
 
         # If a callback changed pc, re call every callback