about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorserpilliere <serpilliere@users.noreply.github.com>2016-06-24 16:10:10 +0200
committerGitHub <noreply@github.com>2016-06-24 16:10:10 +0200
commit214024052d21c325eae7075f8965da5e244704dd (patch)
tree6e3a35c428d7631469dc98c4109f052f4c89c0f6
parent7d977f6fce3b36753dd5e689eac824ac0e1ed6e6 (diff)
parentaaa58042e3c7fc75e97ed7b9eaf4e4ce07b75d7d (diff)
downloadmiasm-214024052d21c325eae7075f8965da5e244704dd.tar.gz
miasm-214024052d21c325eae7075f8965da5e244704dd.zip
Merge pull request #383 from commial/fix/breakpoint-handling
Fix/breakpoint handling
-rw-r--r--miasm2/arch/x86/jit.py2
-rw-r--r--miasm2/jitter/jitload.py15
2 files changed, 14 insertions, 3 deletions
diff --git a/miasm2/arch/x86/jit.py b/miasm2/arch/x86/jit.py
index 5a9886c5..c4f6f128 100644
--- a/miasm2/arch/x86/jit.py
+++ b/miasm2/arch/x86/jit.py
@@ -81,7 +81,7 @@ class jitter_x86_32(jitter):
         return ret_ad, args
 
     def func_ret_stdcall(self, ret_addr, ret_value1=None, ret_value2=None):
-        self.cpu.EIP = ret_addr
+        self.pc = self.cpu.EIP = ret_addr
         if ret_value1 is not None:
             self.cpu.EAX = ret_value1
         if ret_value2 is not None:
diff --git a/miasm2/jitter/jitload.py b/miasm2/jitter/jitload.py
index cc92b0cf..2371067d 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,17 @@ 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
+
+        # Check exceptions (raised by breakpoints)
+        exception_flag = self.get_exception()
+        for res in self.exceptions_handler(exception_flag, self):
+            if res is not True:
                 yield res
 
         # If a callback changed pc, re call every callback
@@ -321,7 +332,7 @@ class jitter:
         # Run the bloc at PC
         self.pc = self.runbloc(self.pc)
 
-        # Check exceptions
+        # Check exceptions (raised by the execution of the block)
         exception_flag = self.get_exception()
         for res in self.exceptions_handler(exception_flag, self):
             if res is not True: