about summary refs log tree commit diff stats
path: root/miasm2/jitter/jitload.py
diff options
context:
space:
mode:
authorserpilliere <serpilliere@users.noreply.github.com>2015-10-23 14:44:01 +0200
committerserpilliere <serpilliere@users.noreply.github.com>2015-10-23 14:44:01 +0200
commitfb32efb74e2dc1077586a2214de558db6940b70b (patch)
treed42a2e0744c5884b808e187eabf348a3f136afff /miasm2/jitter/jitload.py
parentbcd4822ab014156c4977667b165072ba396d1f17 (diff)
parent663a287f588719b0bc58c4d2a1f7e69f17ee986c (diff)
downloadmiasm-fb32efb74e2dc1077586a2214de558db6940b70b.tar.gz
miasm-fb32efb74e2dc1077586a2214de558db6940b70b.zip
Merge pull request #238 from commial/feature_cloop
Feature cloop
Diffstat (limited to 'miasm2/jitter/jitload.py')
-rw-r--r--miasm2/jitter/jitload.py18
1 files changed, 7 insertions, 11 deletions
diff --git a/miasm2/jitter/jitload.py b/miasm2/jitter/jitload.py
index 112920a1..7213d73c 100644
--- a/miasm2/jitter/jitload.py
+++ b/miasm2/jitter/jitload.py
@@ -137,11 +137,7 @@ class CallbackHandlerBitflag(CallbackHandler):
 
     "Handle a list of callback with conditions on bitflag"
 
-    # Overrides CallbackHandler's implem, but do not serve for optimization
-    def has_callbacks(self, bitflag):
-        return any(cb_mask & bitflag != 0 for cb_mask in self.callbacks)
-
-    def __call__(self, bitflag, *args):
+    def call_callbacks(self, bitflag, *args):
         """Call each callbacks associated with bit set in bitflag. While
         callbacks return True, continue with next callback.
         Iterator on other results"""
@@ -151,7 +147,8 @@ class CallbackHandlerBitflag(CallbackHandler):
 
             if b & bitflag != 0:
                 # If the flag matched
-                for res in self.call_callbacks(b, *args):
+                for res in super(CallbackHandlerBitflag,
+                                 self).call_callbacks(b, *args):
                     if res is not True:
                         yield res
 
@@ -292,7 +289,7 @@ class jitter:
         """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, self.vm, pc)
+        return self.jit.runbloc(self.cpu, self.vm, pc, self.breakpoints_handler.callbacks)
 
     def runiter_once(self, pc):
         """Iterator on callbacks results on code running from PC.
@@ -308,10 +305,9 @@ class jitter:
 
         # Check breakpoints
         old_pc = self.pc
-        if self.breakpoints_handler.has_callbacks(self.pc):
-            for res in self.breakpoints_handler(self.pc, self):
-                if res is not True:
-                    yield res
+        for res in self.breakpoints_handler.call_callbacks(self.pc, self):
+            if res is not True:
+                yield res
 
         # If a callback changed pc, re call every callback
         if old_pc != self.pc: