diff options
Diffstat (limited to 'miasm2/jitter/jitload.py')
| -rw-r--r-- | miasm2/jitter/jitload.py | 18 |
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: |